agentx-python 0.3.2__tar.gz → 0.4.0__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.
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: agentx-python
3
- Version: 0.3.2
4
- Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
3
+ Version: 0.4.0
4
+ Summary: Official Python SDK for AgentX (https://www.agentx.so/)
5
5
  Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
6
6
  Author: Robin Wang and AgentX Team
7
7
  Author-email: contact@agentx.so
@@ -19,11 +19,12 @@ Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
21
21
  Dynamic: home-page
22
+ Dynamic: license-file
22
23
  Dynamic: requires-dist
23
24
  Dynamic: requires-python
24
25
  Dynamic: summary
25
26
 
26
- ![Logo](agentx/images/LOGO.png)
27
+ ![Logo](https://agentx-resources.s3.us-west-1.amazonaws.com/AgentX-logo-387x60.png)
27
28
 
28
29
  [![PyPI version](https://img.shields.io/pypi/v/agentx-python)](https://pypi.org/project/agentx-python/)
29
30
 
@@ -42,6 +43,8 @@ Why build AI agent with AgentX?
42
43
  - Support all running MCP (model context protocol).
43
44
  - Support RAG with built-in re-rank.
44
45
  - Multi-agent workforce orchestration.
46
+ - Multiple agents working together with a designated manager agent.
47
+ - Cross vendor LLM orchestration.
45
48
 
46
49
  ## Installation
47
50
 
@@ -110,3 +113,50 @@ text=None cot=None botId='xxx'
110
113
  ```
111
114
 
112
115
  \*`cot` stands for chain-of-thoughts
116
+
117
+ ### Workforce
118
+
119
+ A Workforce (team) consists of multiple agents working together with a designated manager agent.
120
+
121
+ ```python
122
+ from agentx import AgentX
123
+
124
+ client = AgentX(api_key="<your api key here>")
125
+
126
+ # Get the list of workforces/teams you have
127
+ workforces = client.list_workforces()
128
+ print(workforces)
129
+
130
+ # Get a specific workforce
131
+ workforce = workforces[0] # or any specific workforce
132
+ print(f"Workforce: {workforce.name}")
133
+ print(f"Manager: {workforce.manager.name}")
134
+ print(f"Agents: {[agent.name for agent in workforce.agents]}")
135
+ ```
136
+
137
+ #### Workforce Conversations
138
+
139
+ ```python
140
+ # Create a new conversation with the workforce
141
+ conversation = workforce.new_conversation()
142
+
143
+ # List all existing conversations for the workforce
144
+ conversations = workforce.list_conversations()
145
+ print(conversations)
146
+ ```
147
+
148
+ #### Chat with Workforce
149
+
150
+ Chat with the entire workforce team and get streaming responses from all agents.
151
+
152
+ ```python
153
+ # Stream chat with the workforce
154
+ response = workforce.chat_stream(conversation.id, "How can you help me with this project?")
155
+ for chunk in response:
156
+ if chunk.text:
157
+ print(chunk.text, end="")
158
+ if chunk.cot:
159
+ print(f" [COT: {chunk.cot}]")
160
+ ```
161
+
162
+ The workforce chat allows you to leverage multiple specialized agents working together to provide comprehensive responses to your queries.
@@ -1,4 +1,4 @@
1
- ![Logo](agentx/images/LOGO.png)
1
+ ![Logo](https://agentx-resources.s3.us-west-1.amazonaws.com/AgentX-logo-387x60.png)
2
2
 
3
3
  [![PyPI version](https://img.shields.io/pypi/v/agentx-python)](https://pypi.org/project/agentx-python/)
4
4
 
@@ -17,6 +17,8 @@ Why build AI agent with AgentX?
17
17
  - Support all running MCP (model context protocol).
18
18
  - Support RAG with built-in re-rank.
19
19
  - Multi-agent workforce orchestration.
20
+ - Multiple agents working together with a designated manager agent.
21
+ - Cross vendor LLM orchestration.
20
22
 
21
23
  ## Installation
22
24
 
@@ -85,3 +87,50 @@ text=None cot=None botId='xxx'
85
87
  ```
86
88
 
87
89
  \*`cot` stands for chain-of-thoughts
90
+
91
+ ### Workforce
92
+
93
+ A Workforce (team) consists of multiple agents working together with a designated manager agent.
94
+
95
+ ```python
96
+ from agentx import AgentX
97
+
98
+ client = AgentX(api_key="<your api key here>")
99
+
100
+ # Get the list of workforces/teams you have
101
+ workforces = client.list_workforces()
102
+ print(workforces)
103
+
104
+ # Get a specific workforce
105
+ workforce = workforces[0] # or any specific workforce
106
+ print(f"Workforce: {workforce.name}")
107
+ print(f"Manager: {workforce.manager.name}")
108
+ print(f"Agents: {[agent.name for agent in workforce.agents]}")
109
+ ```
110
+
111
+ #### Workforce Conversations
112
+
113
+ ```python
114
+ # Create a new conversation with the workforce
115
+ conversation = workforce.new_conversation()
116
+
117
+ # List all existing conversations for the workforce
118
+ conversations = workforce.list_conversations()
119
+ print(conversations)
120
+ ```
121
+
122
+ #### Chat with Workforce
123
+
124
+ Chat with the entire workforce team and get streaming responses from all agents.
125
+
126
+ ```python
127
+ # Stream chat with the workforce
128
+ response = workforce.chat_stream(conversation.id, "How can you help me with this project?")
129
+ for chunk in response:
130
+ if chunk.text:
131
+ print(chunk.text, end="")
132
+ if chunk.cot:
133
+ print(f" [COT: {chunk.cot}]")
134
+ ```
135
+
136
+ The workforce chat allows you to leverage multiple specialized agents working together to provide comprehensive responses to your queries.
@@ -5,6 +5,7 @@ import logging
5
5
 
6
6
  from agentx.util import get_headers
7
7
  from agentx.resources.agent import Agent
8
+ from agentx.resources.workforce import Workforce
8
9
 
9
10
 
10
11
  class AgentX:
@@ -37,15 +38,29 @@ class AgentX:
37
38
  response = requests.get(url, headers=get_headers())
38
39
  # Check if response was successful
39
40
  if response.status_code == 200:
40
- return [
41
- Agent(
42
- id=agent_res.get("_id"),
43
- name=agent_res.get("name"),
44
- avatar=agent_res.get("avatar"),
45
- createdAt=agent_res.get("createdAt"),
46
- updatedAt=agent_res.get("updatedAt"),
47
- )
48
- for agent_res in response.json()
49
- ]
41
+ return [Agent(**agent) for agent in response.json()]
50
42
  else:
51
43
  raise Exception(f"Failed to list agents: {response.reason}")
44
+
45
+ @staticmethod
46
+ def list_workforces() -> List["Workforce"]:
47
+ """List all workforces/teams."""
48
+ url = "https://api.agentx.so/api/v1/access/teams"
49
+ response = requests.get(url, headers=get_headers())
50
+ if response.status_code == 200:
51
+ return [Workforce(**workforce) for workforce in response.json()]
52
+ else:
53
+ raise Exception(
54
+ f"Failed to list workforces: {response.status_code} - {response.reason}"
55
+ )
56
+
57
+ def get_profile(self):
58
+ """Get the current user's profile information."""
59
+ url = "https://api.agentx.so/api/v1/access/getProfile"
60
+ response = requests.get(url, headers=get_headers())
61
+ if response.status_code == 200:
62
+ return response.json()
63
+ else:
64
+ raise Exception(
65
+ f"Failed to get profile: {response.status_code} - {response.reason}"
66
+ )
@@ -10,7 +10,7 @@ from .conversation import Conversation
10
10
 
11
11
  @dataclass
12
12
  class Agent(BaseModel):
13
- id: str
13
+ id: str = Field(alias="_id")
14
14
  name: str
15
15
  avatar: Optional[str]
16
16
  createdAt: Optional[str]
@@ -0,0 +1,119 @@
1
+ from typing import Optional, List, Dict, Any, Iterator
2
+ from pydantic import BaseModel, Field
3
+ import requests
4
+ import os
5
+ import json
6
+ import logging
7
+ from agentx.util import get_headers
8
+ from agentx.resources.agent import Agent
9
+ from agentx.resources.conversation import Conversation, ChatResponse
10
+
11
+
12
+ class User(BaseModel):
13
+ id: str = Field(alias="_id")
14
+ name: str
15
+ email: str
16
+ deleted: bool
17
+ createdAt: str
18
+ updatedAt: str
19
+ avatar: str
20
+ status: int
21
+ customer: str
22
+ resetPwdToken: Optional[str] = None
23
+ defaultWorkspace: str
24
+ workspaces: List[str]
25
+
26
+ class Config:
27
+ populate_by_name = True
28
+ extra = "ignore"
29
+
30
+
31
+ class Workforce(BaseModel):
32
+ id: str = Field(alias="_id")
33
+ agents: List[Agent]
34
+ name: str
35
+ image: str
36
+ description: str
37
+ manager: Agent
38
+ creator: User
39
+ context: int
40
+ references: bool
41
+ workspace: str
42
+ createdAt: str
43
+ updatedAt: str
44
+
45
+ class Config:
46
+ populate_by_name = True
47
+ extra = "ignore"
48
+
49
+ def new_conversation(self) -> Conversation:
50
+ """Create a new conversation for this workforce."""
51
+ url = f"https://api.agentx.so/api/v1/access/teams/{self.id}/conversations/new"
52
+ response = requests.post(
53
+ url,
54
+ headers=get_headers(),
55
+ json={"type": "chat"},
56
+ )
57
+ if response.status_code == 200:
58
+ conv_data = response.json()
59
+ # Set the agent_id to the manager's ID since this is a workforce conversation
60
+ conv_data["agent_id"] = self.manager.id
61
+ return Conversation(**conv_data)
62
+ else:
63
+ raise Exception(
64
+ f"Failed to create new conversation: {response.status_code} - {response.reason}"
65
+ )
66
+
67
+ def list_conversations(self) -> List[Conversation]:
68
+ """List all conversations for this workforce."""
69
+ url = f"https://api.agentx.so/api/v1/access/teams/{self.id}/conversations"
70
+ response = requests.get(url, headers=get_headers())
71
+ if response.status_code == 200:
72
+ conversations = []
73
+ for conv_data in response.json():
74
+ # Set the agent_id to the manager's ID since this is a workforce conversation
75
+ conv_data["agent_id"] = self.manager.id
76
+ conversations.append(Conversation(**conv_data))
77
+ return conversations
78
+ else:
79
+ raise Exception(
80
+ f"Failed to list conversations: {response.status_code} - {response.reason}"
81
+ )
82
+
83
+ def chat_stream(
84
+ self, conversation_id: str, message: str, context: int = -1
85
+ ) -> Iterator[ChatResponse]:
86
+ """Send a message to a team conversation and stream the response."""
87
+ url = f"https://api.agentx.so/api/v1/access/teams/conversations/{conversation_id}/jsonmessagesse"
88
+ response = requests.post(
89
+ url, headers=get_headers(), json={"message": message, "context": context}
90
+ )
91
+ result = ""
92
+ if response.status_code == 200:
93
+ buf = b""
94
+ for chunk in response.iter_content():
95
+ buf += chunk
96
+ try:
97
+ chunk = buf.decode("utf-8")
98
+ except UnicodeDecodeError:
99
+ continue
100
+ result += chunk
101
+ buf = b""
102
+ try:
103
+ if result.count("{") == result.count("}"):
104
+ catch_json = json.loads(result)
105
+ if catch_json:
106
+ result = ""
107
+ yield ChatResponse(
108
+ text=catch_json.get("text"),
109
+ cot=catch_json.get("cot"),
110
+ botId=catch_json.get("botId"),
111
+ reference=catch_json.get("reference"),
112
+ tasks=catch_json.get("tasks"),
113
+ )
114
+ except json.JSONDecodeError:
115
+ continue
116
+ else:
117
+ raise Exception(
118
+ f"Failed to send message: {response.status_code} - {response.reason}"
119
+ )
@@ -0,0 +1 @@
1
+ VERSION = "0.4.0"
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: agentx-python
3
- Version: 0.3.2
4
- Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
3
+ Version: 0.4.0
4
+ Summary: Official Python SDK for AgentX (https://www.agentx.so/)
5
5
  Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
6
6
  Author: Robin Wang and AgentX Team
7
7
  Author-email: contact@agentx.so
@@ -19,11 +19,12 @@ Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
21
21
  Dynamic: home-page
22
+ Dynamic: license-file
22
23
  Dynamic: requires-dist
23
24
  Dynamic: requires-python
24
25
  Dynamic: summary
25
26
 
26
- ![Logo](agentx/images/LOGO.png)
27
+ ![Logo](https://agentx-resources.s3.us-west-1.amazonaws.com/AgentX-logo-387x60.png)
27
28
 
28
29
  [![PyPI version](https://img.shields.io/pypi/v/agentx-python)](https://pypi.org/project/agentx-python/)
29
30
 
@@ -42,6 +43,8 @@ Why build AI agent with AgentX?
42
43
  - Support all running MCP (model context protocol).
43
44
  - Support RAG with built-in re-rank.
44
45
  - Multi-agent workforce orchestration.
46
+ - Multiple agents working together with a designated manager agent.
47
+ - Cross vendor LLM orchestration.
45
48
 
46
49
  ## Installation
47
50
 
@@ -110,3 +113,50 @@ text=None cot=None botId='xxx'
110
113
  ```
111
114
 
112
115
  \*`cot` stands for chain-of-thoughts
116
+
117
+ ### Workforce
118
+
119
+ A Workforce (team) consists of multiple agents working together with a designated manager agent.
120
+
121
+ ```python
122
+ from agentx import AgentX
123
+
124
+ client = AgentX(api_key="<your api key here>")
125
+
126
+ # Get the list of workforces/teams you have
127
+ workforces = client.list_workforces()
128
+ print(workforces)
129
+
130
+ # Get a specific workforce
131
+ workforce = workforces[0] # or any specific workforce
132
+ print(f"Workforce: {workforce.name}")
133
+ print(f"Manager: {workforce.manager.name}")
134
+ print(f"Agents: {[agent.name for agent in workforce.agents]}")
135
+ ```
136
+
137
+ #### Workforce Conversations
138
+
139
+ ```python
140
+ # Create a new conversation with the workforce
141
+ conversation = workforce.new_conversation()
142
+
143
+ # List all existing conversations for the workforce
144
+ conversations = workforce.list_conversations()
145
+ print(conversations)
146
+ ```
147
+
148
+ #### Chat with Workforce
149
+
150
+ Chat with the entire workforce team and get streaming responses from all agents.
151
+
152
+ ```python
153
+ # Stream chat with the workforce
154
+ response = workforce.chat_stream(conversation.id, "How can you help me with this project?")
155
+ for chunk in response:
156
+ if chunk.text:
157
+ print(chunk.text, end="")
158
+ if chunk.cot:
159
+ print(f" [COT: {chunk.cot}]")
160
+ ```
161
+
162
+ The workforce chat allows you to leverage multiple specialized agents working together to provide comprehensive responses to your queries.
@@ -8,6 +8,7 @@ agentx/version.py
8
8
  agentx/resources/__init__.py
9
9
  agentx/resources/agent.py
10
10
  agentx/resources/conversation.py
11
+ agentx/resources/workforce.py
11
12
  agentx_python.egg-info/PKG-INFO
12
13
  agentx_python.egg-info/SOURCES.txt
13
14
  agentx_python.egg-info/dependency_links.txt
@@ -0,0 +1,40 @@
1
+ from setuptools import setup, find_packages
2
+
3
+
4
+ def get_version():
5
+ """Read version from version.py file"""
6
+ version_file = "agentx/version.py"
7
+ with open(version_file, "r", encoding="utf-8") as f:
8
+ for line in f:
9
+ if line.startswith("VERSION"):
10
+ return line.split("=")[1].strip().strip('"').strip("'")
11
+ raise RuntimeError("Unable to find version string.")
12
+
13
+
14
+ def get_long_description():
15
+ """Read README.md file"""
16
+ with open("README.md", "r", encoding="utf-8") as f:
17
+ return f.read()
18
+
19
+
20
+ setup(
21
+ name="agentx-python",
22
+ version=get_version(),
23
+ packages=find_packages(),
24
+ install_requires=[
25
+ "urllib3>=1.26.11",
26
+ "certifi",
27
+ ],
28
+ author="Robin Wang and AgentX Team",
29
+ author_email="contact@agentx.so",
30
+ description="Official Python SDK for AgentX (https://www.agentx.so/)",
31
+ long_description=get_long_description(),
32
+ long_description_content_type="text/markdown",
33
+ url="https://github.com/AgentX-ai/AgentX-python-sdk",
34
+ classifiers=[
35
+ "Programming Language :: Python :: 3",
36
+ "License :: OSI Approved :: MIT License",
37
+ "Operating System :: OS Independent",
38
+ ],
39
+ python_requires=">=3.6",
40
+ )
@@ -1 +0,0 @@
1
- VERSION = "0.3.0"
@@ -1,23 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- setup(
4
- name="agentx-python",
5
- version="0.3.2", # Update this version number each time you make a release
6
- packages=find_packages(),
7
- install_requires=[
8
- "urllib3>=1.26.11",
9
- "certifi",
10
- ],
11
- author="Robin Wang and AgentX Team",
12
- author_email="contact@agentx.so",
13
- description="Offical Python SDK for AgentX (https://www.agentx.so/)",
14
- long_description=open("README.md").read(),
15
- long_description_content_type="text/markdown",
16
- url="https://github.com/AgentX-ai/AgentX-python-sdk",
17
- classifiers=[
18
- "Programming Language :: Python :: 3",
19
- "License :: OSI Approved :: MIT License",
20
- "Operating System :: OS Independent",
21
- ],
22
- python_requires=">=3.6",
23
- )
File without changes
File without changes