xgae 0.2.1__tar.gz → 0.2.2__tar.gz

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.

Files changed (50) hide show
  1. {xgae-0.2.1 → xgae-0.2.2}/CHANGELOG.md +7 -1
  2. {xgae-0.2.1 → xgae-0.2.2}/PKG-INFO +1 -2
  3. {xgae-0.2.1 → xgae-0.2.2}/pyproject.toml +6 -3
  4. xgae-0.2.2/src/examples/agent/langgraph/react/custom_prompt_rag.py +107 -0
  5. {xgae-0.2.1 → xgae-0.2.2}/src/examples/agent/langgraph/react/run_react_agent.py +1 -1
  6. xgae-0.2.2/uv.lock +2438 -0
  7. xgae-0.2.1/src/examples/agent/langgraph/react/custom_prompt_rag.py +0 -68
  8. xgae-0.2.1/uv.lock +0 -2556
  9. {xgae-0.2.1 → xgae-0.2.2}/.env +0 -0
  10. {xgae-0.2.1 → xgae-0.2.2}/.python-version +0 -0
  11. {xgae-0.2.1 → xgae-0.2.2}/README.md +0 -0
  12. {xgae-0.2.1 → xgae-0.2.2}/mcpservers/custom_servers.json +0 -0
  13. {xgae-0.2.1 → xgae-0.2.2}/mcpservers/xga_server.json +0 -0
  14. {xgae-0.2.1 → xgae-0.2.2}/mcpservers/xga_server_sse.json +0 -0
  15. {xgae-0.2.1 → xgae-0.2.2}/src/examples/agent/langgraph/react/agent_base.py +0 -0
  16. {xgae-0.2.1 → xgae-0.2.2}/src/examples/agent/langgraph/react/react_agent.py +0 -0
  17. {xgae-0.2.1 → xgae-0.2.2}/src/examples/agent/langgraph/react/result_eval_agent.py +0 -0
  18. {xgae-0.2.1 → xgae-0.2.2}/src/examples/engine/run_custom_and_agent_tools.py +0 -0
  19. {xgae-0.2.1 → xgae-0.2.2}/src/examples/engine/run_general_tools.py +0 -0
  20. {xgae-0.2.1 → xgae-0.2.2}/src/examples/engine/run_human_in_loop.py +0 -0
  21. {xgae-0.2.1 → xgae-0.2.2}/src/examples/engine/run_simple.py +0 -0
  22. {xgae-0.2.1 → xgae-0.2.2}/src/examples/tools/custom_fault_tools_app.py +0 -0
  23. {xgae-0.2.1 → xgae-0.2.2}/src/examples/tools/simu_a2a_tools_app.py +0 -0
  24. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/__init__.py +0 -0
  25. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/engine_base.py +0 -0
  26. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/mcp_tool_box.py +0 -0
  27. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/prompt_builder.py +0 -0
  28. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/responser/non_stream_responser.py +0 -0
  29. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/responser/responser_base.py +0 -0
  30. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/responser/stream_responser.py +0 -0
  31. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/task_engine.py +0 -0
  32. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine/task_langfuse.py +0 -0
  33. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/engine_cli_app.py +0 -0
  34. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/tools/without_general_tools_app.py +0 -0
  35. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/__init__.py +0 -0
  36. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/json_helpers.py +0 -0
  37. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/llm_client.py +0 -0
  38. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/misc.py +0 -0
  39. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/setup_env.py +0 -0
  40. {xgae-0.2.1 → xgae-0.2.2}/src/xgae/utils/xml_tool_parser.py +0 -0
  41. {xgae-0.2.1 → xgae-0.2.2}/templates/agent_tool_prompt_template.txt +0 -0
  42. {xgae-0.2.1 → xgae-0.2.2}/templates/custom_tool_prompt_template.txt +0 -0
  43. {xgae-0.2.1 → xgae-0.2.2}/templates/example/fault_user_prompt.txt +0 -0
  44. {xgae-0.2.1 → xgae-0.2.2}/templates/example/result_eval_template.txt +0 -0
  45. {xgae-0.2.1 → xgae-0.2.2}/templates/gemini_system_prompt_template.txt +0 -0
  46. {xgae-0.2.1 → xgae-0.2.2}/templates/general_tool_prompt_template.txt +0 -0
  47. {xgae-0.2.1 → xgae-0.2.2}/templates/system_prompt_response_sample.txt +0 -0
  48. {xgae-0.2.1 → xgae-0.2.2}/templates/system_prompt_template.txt +0 -0
  49. {xgae-0.2.1 → xgae-0.2.2}/test/test_langfuse.py +0 -0
  50. {xgae-0.2.1 → xgae-0.2.2}/test/test_litellm_langfuse.py +0 -0
@@ -1,7 +1,13 @@
1
1
  # Release Changelog
2
+ ## [0.2.2] - 2025-9-18
3
+ ### Added
4
+ -
5
+ ### Modified
6
+ - CustomPromptRag: remove FastEmbedEmbeddings, use 'text-embedding-v3' model for chinese, avoid download 'bge-small-zh-v1.5'
7
+
2
8
  ## [0.2.1] - 2025-9-17
3
9
  ### Added
4
- - Example Langgraph ReactAgent: add Chromadb for custom prompt RAG
10
+ - Example Langgraph ReactAgent: add CustomPromptRag, use FastEmbedEmbeddings and 'BAAI/bge-small-zh-v1.5' model
5
11
  ### Modified
6
12
  - pyproject.toml: add [project.optional-dependencies] 'examples'
7
13
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xgae
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Extreme General Agent Engine
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: colorlog==6.9.0
@@ -11,6 +11,5 @@ Requires-Dist: litellm==1.74.15
11
11
  Requires-Dist: mcp==1.13.0
12
12
  Provides-Extra: examples
13
13
  Requires-Dist: chromadb==1.1.0; extra == 'examples'
14
- Requires-Dist: fastembed==0.7.3; extra == 'examples'
15
14
  Requires-Dist: langchain-community==0.3.29; extra == 'examples'
16
15
  Requires-Dist: langgraph==0.6.5; extra == 'examples'
@@ -1,33 +1,36 @@
1
1
  [project]
2
2
  name = "xgae"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Extreme General Agent Engine"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
8
8
  "colorlog==6.9.0",
9
- "langchain-mcp-adapters==0.1.9",
10
9
  "litellm==1.74.15",
11
10
  "mcp==1.13.0",
12
11
  "langfuse==2.60.9",
13
12
  "langchain==0.3.27",
13
+ "langchain-mcp-adapters==0.1.9",
14
14
  ]
15
15
 
16
+
16
17
  [project.optional-dependencies]
17
18
  examples = [
18
19
  "langgraph==0.6.5",
19
20
  "langchain-community==0.3.29",
20
- "fastembed==0.7.3",
21
21
  "chromadb==1.1.0",
22
22
  ]
23
23
 
24
+
24
25
  [build-system]
25
26
  requires = ["hatchling"]
26
27
  build-backend = "hatchling.build"
27
28
 
29
+
28
30
  [tool.hatch.build]
29
31
  exclude = ["log/*", ".idea/*"]
30
32
 
33
+
31
34
  [project.scripts]
32
35
  xgae = "xgae.engine_cli_app:main"
33
36
  xgae-tools = "xgae.tools.without_general_tools_app:main"
@@ -0,0 +1,107 @@
1
+ import logging
2
+ import os
3
+ from typing import override, List
4
+
5
+ from langchain_core.documents import Document
6
+ from langchain_core.embeddings import Embeddings
7
+ from langchain_core.vectorstores import VectorStore
8
+
9
+ from langchain_community.vectorstores import Chroma
10
+ from chromadb.utils import embedding_functions
11
+
12
+ class ChromaEmbedding(Embeddings):
13
+ embedding_model_name = "text-embedding-v3"
14
+
15
+ def __init__(self):
16
+ api_key = os.getenv('LLM_API_KEY')
17
+ api_base = os.getenv('LLM_API_BASE', "https://dashscope.aliyuncs.com/compatible-mode/v1")
18
+
19
+ self.embedding_function = embedding_functions.OpenAIEmbeddingFunction(
20
+ api_key = api_key,
21
+ api_base = api_base,
22
+ model_name = self.embedding_model_name,
23
+ )
24
+
25
+
26
+ @override
27
+ def embed_documents(self, texts: List[str]) -> List[List[float]]:
28
+ return self.embedding_function(texts)
29
+
30
+
31
+ @override
32
+ def embed_query(self, text: str) -> List[float]:
33
+ return self.embed_documents([text])[0]
34
+
35
+
36
+ class CustomPromptRag:
37
+ PROMPT_SIMILAR_SCORE = 0.85 # need tune-up score based on different embedding model
38
+
39
+ def __init__(self):
40
+ prompt_docs = self._load_prompts()
41
+ self.vector_store = self._init_vector_store(prompt_docs)
42
+
43
+
44
+ # should read from DB, load all custom prompt or COT
45
+ def _load_prompts(self) -> List[Document]:
46
+ prompt_docs = []
47
+ prompt_docs.append(self._create_prompt_doc(
48
+ prompt_summary="Fault location and analysis of fault causes",
49
+ prompt_path="templates/example/fault_user_prompt.txt"
50
+ ))
51
+ return prompt_docs
52
+
53
+
54
+ def _create_prompt_doc(self, prompt_summary: str, prompt_path: str)-> Document:
55
+ return Document(
56
+ page_content=prompt_summary,
57
+ metadata={
58
+ "source": prompt_path,
59
+ }
60
+ )
61
+
62
+
63
+ def _init_vector_store(self, docs: List[Document]) -> VectorStore:
64
+ embeddings = ChromaEmbedding()
65
+ return Chroma.from_documents(
66
+ documents=docs,
67
+ embedding=embeddings,
68
+ persist_directory=None
69
+ )
70
+
71
+
72
+ def search_prompt(self, query:str)-> str:
73
+ prompt_path = None
74
+ results = self.vector_store.similarity_search_with_score(query=query, k=1)
75
+ if results and len(results) > 0:
76
+ doc, score = results[0]
77
+ if score > self.PROMPT_SIMILAR_SCORE:
78
+ logging.info(f"CustomPromptRag search: SIMILAR_SCORE: {score} > {self.PROMPT_SIMILAR_SCORE}, "
79
+ f"\nquery: '{query}' \nprompt_summary: '{doc.page_content}'\n")
80
+ else:
81
+ prompt_path = doc.metadata['source']
82
+ logging.info(f"CustomPromptRag search: SIMILAR_SCORE: {score}, prompt_path: '{prompt_path}'")
83
+
84
+ return prompt_path
85
+
86
+
87
+ if __name__ == "__main__":
88
+ from xgae.utils.setup_env import setup_logging
89
+
90
+ setup_logging()
91
+
92
+ custom_prompt_rag = CustomPromptRag()
93
+
94
+ querys = ["locate 10.2.3.4 fault and solution", # 0.79
95
+ "定位 10.2.3.4 故障,并给出解决方案", # 0.81
96
+ "locate fault and solution", # 0.42
97
+ "locate fault", # 0.40
98
+ "定位故障", # 0.64
99
+ "fault solution", # 0.47
100
+ "locate", # 0.95
101
+ "5+7" # 1.12
102
+ ]
103
+
104
+ for query in querys:
105
+ logging.info("*"*50)
106
+ logging.info(f"query: '{query}'")
107
+ custom_prompt_rag.search_prompt(query)
@@ -17,7 +17,7 @@ async def main():
17
17
  ]
18
18
 
19
19
  for user_input in user_inputs:
20
- agent = XGAReactAgent(use_prompt_rag=False)
20
+ agent = XGAReactAgent(use_prompt_rag=True)
21
21
  task_no += 1
22
22
  context: AgentContext = {
23
23
  'task_id': f"agent_task_{uuid4()}", # can be set with request_id, must be unique