xgae 0.1.19__py3-none-any.whl → 0.1.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of xgae might be problematic. Click here for more details.

@@ -28,7 +28,8 @@ class XGATaskEngine:
28
28
  tool_exec_parallel: Optional[bool] = None,
29
29
  llm_config: Optional[LLMConfig] = None,
30
30
  prompt_builder: Optional[XGAPromptBuilder] = None,
31
- tool_box: Optional[XGAToolBox] = None):
31
+ tool_box: Optional[XGAToolBox] = None
32
+ ):
32
33
  self.task_id = task_id if task_id else f"xga_task_{uuid4()}"
33
34
  self.session_id = session_id
34
35
  self.user_id = user_id
@@ -213,7 +214,7 @@ class XGATaskEngine:
213
214
  auto_count = continuous_state.get("auto_continue_count")
214
215
  langfuse_metadata = self.task_langfuse.create_llm_langfuse_meta(auto_count)
215
216
 
216
- llm_response = await self.llm_client.create_completion(llm_messages, langfuse_metadata)
217
+ llm_response = await self.llm_client.acompletion(llm_messages, langfuse_metadata)
217
218
  response_processor = self._create_response_processer()
218
219
 
219
220
  async for chunk in response_processor.process_response(llm_response, llm_messages, continuous_state):
@@ -315,7 +316,7 @@ class XGATaskEngine:
315
316
  def get_history_llm_messages (self) -> List[Dict[str, Any]]:
316
317
  llm_messages = []
317
318
  for message in self.task_response_msgs:
318
- if message['is_llm_message']:
319
+ if message['is_llm_message'] and message['type'] != "assistant_chunk":
319
320
  llm_messages.append(message)
320
321
 
321
322
  response_llm_contents = []
@@ -51,10 +51,12 @@ class XGATaskLangFuse:
51
51
  'agent_id' : self.agent_id
52
52
  }
53
53
 
54
- self.root_span = trace.span(id=self.task_run_id,
55
- name=f"{root_span_name}[{self.task_no}]",
56
- input=task_input,
57
- metadata=metadata)
54
+ self.root_span = trace.span(
55
+ id = self.task_run_id,
56
+ name = f"{root_span_name}[{self.task_no}]",
57
+ input = task_input,
58
+ metadata = metadata
59
+ )
58
60
  self.root_span_name = root_span_name
59
61
 
60
62
  logging.info(f"{root_span_name} TASK_INPUT: {task_input}")
xgae/utils/llm_client.py CHANGED
@@ -226,7 +226,10 @@ class LLMClient:
226
226
  logging.debug(f"LLMClient: Waiting {delay} seconds before retry llm completion...")
227
227
  await asyncio.sleep(delay)
228
228
 
229
- async def create_completion(self, messages: List[Dict[str, Any]], langfuse_metadata: Optional[LangfuseMetadata]=None) -> Union[ModelResponse, CustomStreamWrapper]:
229
+ async def acompletion(self,
230
+ messages: List[Dict[str, Any]],
231
+ langfuse_metadata: Optional[LangfuseMetadata]=None
232
+ ) -> Union[ModelResponse, CustomStreamWrapper]:
230
233
  complete_params = self._prepare_complete_params(messages)
231
234
  if LLMClient.langfuse_enabled and langfuse_metadata:
232
235
  complete_params["metadata"] = langfuse_metadata
@@ -234,19 +237,38 @@ class LLMClient:
234
237
  last_error = None
235
238
  for attempt in range(self.max_retries):
236
239
  try:
237
- logging.info(f"*** LLMClient create_completion: LLM '{self.model_name}' completion attempt {attempt + 1}/{self.max_retries}")
240
+ logging.info(f"*** LLMClient acompletion: LLM '{self.model_name}' completion attempt {attempt + 1}/{self.max_retries}")
238
241
  response = await litellm.acompletion(**complete_params)
239
242
  return response
240
243
  except (litellm.exceptions.RateLimitError, OpenAIError, json.JSONDecodeError) as e:
241
244
  last_error = e
242
245
  await self._handle_llm_error(e, attempt)
243
246
  except Exception as e:
244
- logging.error(f"LLMClient create_completion: Unexpected error during LLM completion: {str(e)}", exc_info=True)
247
+ logging.error(f"LLMClient acompletion: Unexpected error during LLM completion: {str(e)}", exc_info=True)
245
248
  raise LLMError(f"LLMClient create completion failed: {e}")
246
249
 
247
- logging.error(f"LLMClient create_completion: LLM completion failed after {self.max_retries} attempts: {last_error}", exc_info=True)
250
+ logging.error(f"LLMClient acompletion: LLM completion failed after {self.max_retries} attempts: {last_error}", exc_info=True)
248
251
  raise LLMError(f"LLMClient create completion failed after {self.max_retries} attempts !")
249
252
 
253
+
254
+ async def get_response_result(self, response: Union[ModelResponse, CustomStreamWrapper]) -> str:
255
+ response_text: str = ""
256
+
257
+ if self.is_stream:
258
+ async for chunk in response:
259
+ choices = chunk.get("choices", [{}])
260
+ if not choices:
261
+ continue
262
+ delta = choices[0].get("delta", {})
263
+ content = delta.get("content", "")
264
+ if content:
265
+ response_text += content
266
+ else:
267
+ response_text = response.choices[0].message.content
268
+
269
+ return response_text
270
+
271
+
250
272
  if __name__ == "__main__":
251
273
  from xgae.utils.setup_env import setup_logging
252
274
 
@@ -267,7 +289,7 @@ if __name__ == "__main__":
267
289
  session_id="session_0",
268
290
  )
269
291
 
270
- response = await llm_client.create_completion(messages, meta)
292
+ response = await llm_client.acompletion(messages, meta)
271
293
  if llm_client.is_stream:
272
294
  async for chunk in response:
273
295
  choices = chunk.get("choices", [{}])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xgae
3
- Version: 0.1.19
3
+ Version: 0.1.20
4
4
  Summary: Extreme General Agent Engine
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: colorlog==6.9.0
@@ -3,19 +3,19 @@ xgae/engine_cli_app.py,sha256=FdmIpq8KDsgyZNfwCDgNX7FEZFeRFyGOt_H1oZF8aKs,2890
3
3
  xgae/engine/engine_base.py,sha256=RR1em2wHiM2jP-peHt77SKdHWjnYOjdIIzN93zT61cA,1715
4
4
  xgae/engine/mcp_tool_box.py,sha256=G4hKIMguwg1cO4Us2NMfdloYim8kuikVyVTIPucJr7o,10903
5
5
  xgae/engine/prompt_builder.py,sha256=6I5rjgvNJ27QJ8DDuBTplutoPZdGs9LYFv3TSgT7zmc,5045
6
- xgae/engine/task_engine.py,sha256=7B7nbERTh9HDgDH4lXS_s4KTsVU41AgR7rnN4jKLozQ,21588
7
- xgae/engine/task_langfuse.py,sha256=J9suOhlIGSJor-mZsggPZf3XQld9dTkfpHAS2fVirvM,2859
6
+ xgae/engine/task_engine.py,sha256=l0wOIIkyVUtyf95wSi4oXTHZjv15m9XB68pTk24baig,21641
7
+ xgae/engine/task_langfuse.py,sha256=ifkGrPBv2daLTKE-fCfEtOoI0n4Pd-lCwhyRRL0h308,2850
8
8
  xgae/engine/responser/non_stream_responser.py,sha256=zEJjqCgZVe2B8gkHYRFU7tmBV834f7w2a4Ws25P1N-c,5289
9
9
  xgae/engine/responser/responser_base.py,sha256=jhl1Bdz1Fs3KofGEymThNXlQuCORFTTkTAR_U47krds,24403
10
10
  xgae/engine/responser/stream_responser.py,sha256=cv4UGcxj8OksEogW7DUGTCvSJabu-DF6GceFyUwaXI4,7627
11
11
  xgae/tools/without_general_tools_app.py,sha256=KqsdhxD3hvTpiygaGUVHysRFjvv_1A8zOwMKN1J0J0U,3821
12
12
  xgae/utils/__init__.py,sha256=ElaGS-zdeZeu6is41u3Ny7lkvhg7BDSK-jMNg9j6K5A,499
13
13
  xgae/utils/json_helpers.py,sha256=WD4G5U9Dh8N6J9O0L5wGyqj-NHi09kcXHGdLD_26nlc,3607
14
- xgae/utils/llm_client.py,sha256=mWRtvtSMk_8NuzFReT9x52ayHlCNVZMZAltD6TQ-xZ8,14404
14
+ xgae/utils/llm_client.py,sha256=AphZ57n9VvaQBq6xu2_cRQE6DtIGN2PfQ2h7D50cATw,15056
15
15
  xgae/utils/misc.py,sha256=aMWOvJ9VW52q-L9Lkjl1hvXqLwpJAmyxA-Z8jzqFG0U,907
16
16
  xgae/utils/setup_env.py,sha256=MqNG0c2QQBDFU1kI8frxr9kB5d08Mmi3QZ1OoorgIa0,2662
17
17
  xgae/utils/xml_tool_parser.py,sha256=Mb0d8kBrfyAEvUwW1Nqir-3BgxZRr0ZX3WymQouuFSo,4859
18
- xgae-0.1.19.dist-info/METADATA,sha256=MHUqZkPIWB9Tn_sLyFkFBw4XZKPAQqC_z0QudI1s5hk,343
19
- xgae-0.1.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
- xgae-0.1.19.dist-info/entry_points.txt,sha256=wmvgtMQbtzTbDPETS-tbQJD7jVlcs4hp0w6wOB0ooCc,229
21
- xgae-0.1.19.dist-info/RECORD,,
18
+ xgae-0.1.20.dist-info/METADATA,sha256=H8uCaLYabJqLy0BCBC_tP8B0Ti-dKiefMWqkZ_d3ySs,343
19
+ xgae-0.1.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
20
+ xgae-0.1.20.dist-info/entry_points.txt,sha256=wmvgtMQbtzTbDPETS-tbQJD7jVlcs4hp0w6wOB0ooCc,229
21
+ xgae-0.1.20.dist-info/RECORD,,
File without changes