|
26 | 26 | from cachetools import TTLCache |
27 | 27 |
|
28 | 28 | from helpers.utils import format_stream_response |
29 | | -from helpers.azure_openai_helper import get_azure_openai_client |
30 | 29 | from common.config.config import Config |
31 | 30 | from agents.chart_agent_factory import ChartAgentFactory |
32 | 31 |
|
@@ -106,10 +105,6 @@ async def process_rag_response(self, rag_response, query): |
106 | 105 | content=combined_input |
107 | 106 | ) |
108 | 107 |
|
109 | | - print(f"thread with id:{thread.id}",flush=True) |
110 | | - print(f"agent id:{agent.id}",flush=True) |
111 | | - print(f"project clinet :{client}",flush=True) |
112 | | - |
113 | 108 | run = client.agents.runs.create_and_process( |
114 | 109 | thread_id=thread.id, |
115 | 110 | agent_id=agent.id |
@@ -143,62 +138,6 @@ async def process_rag_response(self, rag_response, query): |
143 | 138 | logger.error("Agent error in chart generation: %s", e) |
144 | 139 | return {"error": "Chart could not be generated from this data. Please ask a different question."} |
145 | 140 |
|
146 | | - |
147 | | - # async def run_agent(): |
148 | | - # chart_data = {"error": "Chart could not be generated."} |
149 | | - # try: |
150 | | - # agent_info = await ChartAgentFactory.get_agent() |
151 | | - # agent = agent_info["agent"] |
152 | | - # client = agent_info["client"] |
153 | | - |
154 | | - # thread = client.agents.threads.create() |
155 | | - # client.agents.messages.create( |
156 | | - # thread_id=thread.id, |
157 | | - # role=MessageRole.USER, |
158 | | - # content=combined_input |
159 | | - # ) |
160 | | - |
161 | | - # print(f"thread with id:{thread.id}",flush=True) |
162 | | - # print(f"agent id:{agent.id}",flush=True) |
163 | | - # print(f"project clinet :{client}",flush=True) |
164 | | - |
165 | | - # run = client.agents.runs.create_and_process( |
166 | | - # thread_id=thread.id, |
167 | | - # agent_id=agent.id |
168 | | - # ) |
169 | | - |
170 | | - # if run.status == "failed": |
171 | | - # print(f"[Chart Agent] Run failed: {run.last_error}") |
172 | | - # return {"error": "Chart could not be generated due to agent failure."} |
173 | | - |
174 | | - # chart_json = "" |
175 | | - # messages = client.agents.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING) |
176 | | - # for msg in messages: |
177 | | - # if msg.role == MessageRole.AGENT and msg.text_messages: |
178 | | - # chart_json = msg.text_messages[-1].text.value.strip() |
179 | | - # break |
180 | | - |
181 | | - # chart_json = chart_json.replace("```json", "").replace("```", "").strip() |
182 | | - # client.agents.threads.delete(thread_id=thread.id) |
183 | | - |
184 | | - # chart_data = json.loads(chart_json) |
185 | | - # except Exception as e: |
186 | | - # print(f"[Chart Agent Error]: {e}") |
187 | | - # return chart_data |
188 | | - |
189 | | - # # Run the async agent call synchronously |
190 | | - # loop = asyncio.get_event_loop() |
191 | | - # chart_data = loop.run_until_complete(run_agent()) |
192 | | - |
193 | | - # if not chart_data or "error" in chart_data: |
194 | | - # return {"error": "Chart could not be generated from this data. Please ask a different question."} |
195 | | - |
196 | | - # return chart_data |
197 | | - |
198 | | - # except Exception as e: |
199 | | - # logger.error("Agent error in chart generation: %s", e) |
200 | | - # return {"error": "Chart could not be generated from this data. Please ask a different question."} |
201 | | - |
202 | 141 | async def stream_openai_text(self, conversation_id: str, query: str) -> StreamingResponse: |
203 | 142 | """ |
204 | 143 | Get a streaming text response from OpenAI. |
|
0 commit comments