agentx-python 0.1__tar.gz → 0.3.1__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.
- agentx_python-0.3.1/PKG-INFO +80 -0
- agentx_python-0.3.1/README.md +55 -0
- {agentx-python-0.1/agentx_python → agentx_python-0.3.1/agentx}/__init__.py +3 -9
- agentx_python-0.3.1/agentx/agentx.py +51 -0
- agentx_python-0.3.1/agentx/resources/__init__.py +0 -0
- agentx_python-0.3.1/agentx/resources/agent.py +46 -0
- agentx_python-0.3.1/agentx/resources/conversation.py +128 -0
- agentx_python-0.3.1/agentx/util.py +5 -0
- agentx_python-0.3.1/agentx/version.py +1 -0
- agentx_python-0.3.1/agentx_python.egg-info/PKG-INFO +80 -0
- agentx_python-0.3.1/agentx_python.egg-info/SOURCES.txt +15 -0
- agentx_python-0.3.1/agentx_python.egg-info/top_level.txt +1 -0
- {agentx-python-0.1 → agentx_python-0.3.1}/setup.py +1 -1
- agentx-python-0.1/PKG-INFO +0 -30
- agentx-python-0.1/README.md +0 -16
- agentx-python-0.1/agentx_python/agent.py +0 -55
- agentx-python-0.1/agentx_python/version.py +0 -1
- agentx-python-0.1/agentx_python.egg-info/PKG-INFO +0 -30
- agentx-python-0.1/agentx_python.egg-info/SOURCES.txt +0 -11
- agentx-python-0.1/agentx_python.egg-info/top_level.txt +0 -1
- {agentx-python-0.1 → agentx_python-0.3.1}/LICENSE +0 -0
- {agentx-python-0.1 → agentx_python-0.3.1}/agentx_python.egg-info/dependency_links.txt +0 -0
- {agentx-python-0.1 → agentx_python-0.3.1}/agentx_python.egg-info/requires.txt +0 -0
- {agentx-python-0.1 → agentx_python-0.3.1}/setup.cfg +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: agentx-python
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
|
|
5
|
+
Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
|
|
6
|
+
Author: Robin Wang and AgentX Team
|
|
7
|
+
Author-email: contact@agentx.so
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: urllib3>=1.26.11
|
|
15
|
+
Requires-Dist: certifi
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# AgentX Python SDK API library
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/agentx-python/)
|
|
29
|
+
|
|
30
|
+
The AgentX Python SDK provides a convenient way to access to your Agent programmatically.
|
|
31
|
+
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install --upgrade agentx-python
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Provide an `api_key` inline or set `AGENTX_API_KEY` as an environment variable.
|
|
42
|
+
You can get an API key from https://app.agentx.so
|
|
43
|
+
|
|
44
|
+
### Agent
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from agentx_python import AgentX
|
|
48
|
+
|
|
49
|
+
client = AgentX(api_key="<your api key here>")
|
|
50
|
+
|
|
51
|
+
# Get the list of agents you have
|
|
52
|
+
print(client.list_agents())
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Conversation
|
|
56
|
+
|
|
57
|
+
Each Conversation has `agents` and `users` tied to it.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# get agent
|
|
61
|
+
my_agent = client.get_agent(id="<agent id here>")
|
|
62
|
+
|
|
63
|
+
# Get the list of conversation from this agent
|
|
64
|
+
print(my_agent.list_conversations())
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Chat
|
|
68
|
+
|
|
69
|
+
A `chat` needs to happen in the conversation. You can do `stream` response too, default `False`.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
a_conversation = my_agent.get_conversation(id="<conversation id here>")
|
|
73
|
+
|
|
74
|
+
response = a_conversation.chat("Hello, what is your name?", stream=True)
|
|
75
|
+
for chunk in response:
|
|
76
|
+
print(chunk, end="")
|
|
77
|
+
|
|
78
|
+
# output:
|
|
79
|
+
# My name is Rosita. I'm an AI assistant created by AgentX. It's nice to meet you! How can I help you today?
|
|
80
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# AgentX Python SDK API library
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/agentx-python/)
|
|
4
|
+
|
|
5
|
+
The AgentX Python SDK provides a convenient way to access to your Agent programmatically.
|
|
6
|
+
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install --upgrade agentx-python
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Provide an `api_key` inline or set `AGENTX_API_KEY` as an environment variable.
|
|
17
|
+
You can get an API key from https://app.agentx.so
|
|
18
|
+
|
|
19
|
+
### Agent
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from agentx_python import AgentX
|
|
23
|
+
|
|
24
|
+
client = AgentX(api_key="<your api key here>")
|
|
25
|
+
|
|
26
|
+
# Get the list of agents you have
|
|
27
|
+
print(client.list_agents())
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Conversation
|
|
31
|
+
|
|
32
|
+
Each Conversation has `agents` and `users` tied to it.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# get agent
|
|
36
|
+
my_agent = client.get_agent(id="<agent id here>")
|
|
37
|
+
|
|
38
|
+
# Get the list of conversation from this agent
|
|
39
|
+
print(my_agent.list_conversations())
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Chat
|
|
43
|
+
|
|
44
|
+
A `chat` needs to happen in the conversation. You can do `stream` response too, default `False`.
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
a_conversation = my_agent.get_conversation(id="<conversation id here>")
|
|
48
|
+
|
|
49
|
+
response = a_conversation.chat("Hello, what is your name?", stream=True)
|
|
50
|
+
for chunk in response:
|
|
51
|
+
print(chunk, end="")
|
|
52
|
+
|
|
53
|
+
# output:
|
|
54
|
+
# My name is Rosita. I'm an AI assistant created by AgentX. It's nice to meet you! How can I help you today?
|
|
55
|
+
```
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
import os
|
|
3
2
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
3
|
+
from agentx.agentx import AgentX
|
|
4
|
+
from agentx.version import VERSION
|
|
6
5
|
|
|
7
6
|
logging.basicConfig(
|
|
8
7
|
level=logging.INFO,
|
|
@@ -10,10 +9,5 @@ logging.basicConfig(
|
|
|
10
9
|
datefmt="%Y-%m-%d %H:%M:%S %Z",
|
|
11
10
|
)
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
api_key = os.environ.get("OPENAI_API_KEY")
|
|
15
|
-
|
|
16
|
-
Agent = Agent()
|
|
17
|
-
|
|
12
|
+
__all__ = ["AgentX"]
|
|
18
13
|
__version__ = VERSION
|
|
19
|
-
__all__ = ["api_key", "Agent"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
import requests
|
|
3
|
+
import os
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
from agentx.util import get_headers
|
|
7
|
+
from agentx.resources.agent import Agent
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AgentX:
|
|
11
|
+
|
|
12
|
+
def __init__(self, api_key: str = None):
|
|
13
|
+
self.api_key = api_key or os.getenv("AGENTX_API_KEY")
|
|
14
|
+
if self.api_key and not os.getenv("AGENTX_API_KEY"):
|
|
15
|
+
os.environ["AGENTX_API_KEY"] = self.api_key
|
|
16
|
+
|
|
17
|
+
def get_agent(self, id: str) -> Agent:
|
|
18
|
+
url = f"https://api.agentx.so/api/v1/access/agents/{id}"
|
|
19
|
+
# Make a GET request to the AgentX API
|
|
20
|
+
response = requests.get(url, headers=get_headers())
|
|
21
|
+
# Check if response was successful
|
|
22
|
+
if response.status_code == 200:
|
|
23
|
+
agent_res = response.json()
|
|
24
|
+
return Agent(
|
|
25
|
+
id=agent_res.get("_id"),
|
|
26
|
+
name=agent_res.get("name"),
|
|
27
|
+
avatar=agent_res.get("avatar"),
|
|
28
|
+
createdAt=agent_res.get("createdAt"),
|
|
29
|
+
updatedAt=agent_res.get("updatedAt"),
|
|
30
|
+
)
|
|
31
|
+
else:
|
|
32
|
+
raise Exception(f"Failed to retrieve agent: {response.reason}")
|
|
33
|
+
|
|
34
|
+
def list_agents(self) -> List[Agent]:
|
|
35
|
+
url = "https://api.agentx.so/api/v1/access/agents"
|
|
36
|
+
# Make a GET request to the AgentX API
|
|
37
|
+
response = requests.get(url, headers=get_headers())
|
|
38
|
+
# Check if response was successful
|
|
39
|
+
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
|
+
]
|
|
50
|
+
else:
|
|
51
|
+
raise Exception(f"Failed to list agents: {response.reason}")
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Optional, List
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
|
+
import requests
|
|
4
|
+
import os
|
|
5
|
+
import logging
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from agentx.util import get_headers
|
|
8
|
+
from .conversation import Conversation
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class Agent(BaseModel):
|
|
13
|
+
id: str
|
|
14
|
+
name: str
|
|
15
|
+
avatar: Optional[str]
|
|
16
|
+
createdAt: Optional[str]
|
|
17
|
+
updatedAt: Optional[str]
|
|
18
|
+
|
|
19
|
+
def __init__(self, **data):
|
|
20
|
+
super().__init__(**data)
|
|
21
|
+
|
|
22
|
+
def get_conversation(self, id: str) -> Conversation:
|
|
23
|
+
list_of_conversations = self.list_conversations()
|
|
24
|
+
return next(
|
|
25
|
+
(conv for conv in list_of_conversations if conv.id == id),
|
|
26
|
+
Exception("404 - Conversation not found"),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def list_conversations(self) -> List[Conversation]:
|
|
30
|
+
url = f"https://api.agentx.so/api/v1/access/agents/{self.id}/conversations"
|
|
31
|
+
response = requests.get(url, headers=get_headers())
|
|
32
|
+
if response.status_code == 200:
|
|
33
|
+
return [
|
|
34
|
+
Conversation(
|
|
35
|
+
agent_id=self.id,
|
|
36
|
+
id=conv_res.get("_id"),
|
|
37
|
+
title=conv_res.get("title"),
|
|
38
|
+
users=conv_res.get("users"),
|
|
39
|
+
agents=conv_res.get("bots"),
|
|
40
|
+
createdAt=conv_res.get("createdAt"),
|
|
41
|
+
updatedAt=conv_res.get("updatedAt"),
|
|
42
|
+
)
|
|
43
|
+
for conv_res in response.json()
|
|
44
|
+
]
|
|
45
|
+
else:
|
|
46
|
+
raise Exception(f"Failed to retrieve agent details: {response.reason}")
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Optional, List, Any, Iterator
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
from agentx.util import get_headers
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ChatResponse(BaseModel):
|
|
9
|
+
text: str | None
|
|
10
|
+
cot: str | None
|
|
11
|
+
botId: str
|
|
12
|
+
reference: Optional[Any]
|
|
13
|
+
tasks: Optional[Any]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Message(BaseModel):
|
|
17
|
+
id: str = Field(alias="_id")
|
|
18
|
+
conversationId: str
|
|
19
|
+
role: str # user or bot
|
|
20
|
+
botId: Optional[str] = Field(alias="bot", default=None)
|
|
21
|
+
userId: Optional[str] = Field(alias="user", default=None)
|
|
22
|
+
text: str | None
|
|
23
|
+
cot: str | None
|
|
24
|
+
createdAt: str
|
|
25
|
+
updatedAt: str
|
|
26
|
+
|
|
27
|
+
class Config:
|
|
28
|
+
populate_by_name = True
|
|
29
|
+
extra = "ignore"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Conversation(BaseModel):
|
|
33
|
+
agent_id: str
|
|
34
|
+
id: str = Field(alias="_id")
|
|
35
|
+
title: Optional[str] = Field(default=None) # conversation customized title
|
|
36
|
+
users: List[str]
|
|
37
|
+
agents: List[str] = Field(alias="bots")
|
|
38
|
+
createdAt: Optional[str]
|
|
39
|
+
updatedAt: Optional[str]
|
|
40
|
+
|
|
41
|
+
class Config:
|
|
42
|
+
populate_by_name = True
|
|
43
|
+
extra = "ignore"
|
|
44
|
+
|
|
45
|
+
def __init__(self, **data):
|
|
46
|
+
super().__init__(**data)
|
|
47
|
+
|
|
48
|
+
def new_conversation(self) -> "Conversation":
|
|
49
|
+
url = f"https://api.agentx.so/api/v1/access/agents/{self.agent_id}/conversations/new"
|
|
50
|
+
response = requests.post(
|
|
51
|
+
url,
|
|
52
|
+
headers=get_headers(),
|
|
53
|
+
json={"type": "chat"},
|
|
54
|
+
)
|
|
55
|
+
if response.status_code == 200:
|
|
56
|
+
new_conv = response.json()
|
|
57
|
+
new_conv["agent_id"] = self.agent_id
|
|
58
|
+
return Conversation(**new_conv)
|
|
59
|
+
else:
|
|
60
|
+
raise Exception(
|
|
61
|
+
f"Failed to create new conversation: {response.status_code} - {response.reason}"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def list_messages(self) -> List[Message]:
|
|
65
|
+
url = f"https://api.agentx.so/api/v1/access/agents/{self.agent_id}/conversations/{self.id}"
|
|
66
|
+
response = requests.get(url, headers=get_headers())
|
|
67
|
+
if response.status_code == 200:
|
|
68
|
+
res = response.json()
|
|
69
|
+
if res.get("messages"):
|
|
70
|
+
message_list = []
|
|
71
|
+
for message in res["messages"]:
|
|
72
|
+
if message.get("bot"):
|
|
73
|
+
message["role"] = "bot"
|
|
74
|
+
else:
|
|
75
|
+
message["role"] = "user"
|
|
76
|
+
message_list.append(Message(**message))
|
|
77
|
+
return message_list
|
|
78
|
+
else:
|
|
79
|
+
raise Exception("No messages found in the conversation.")
|
|
80
|
+
else:
|
|
81
|
+
raise Exception(
|
|
82
|
+
f"Failed to retrieve agent details: {response.status_code} - {response.reason}"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def chat(self, message: str, context: int = None):
|
|
86
|
+
url = f"https://api.agentx.so/api/v1/access/conversations/{self.id}/message"
|
|
87
|
+
response = requests.post(
|
|
88
|
+
url,
|
|
89
|
+
headers=get_headers(),
|
|
90
|
+
json={"message": message, "context": context},
|
|
91
|
+
)
|
|
92
|
+
return response.json()
|
|
93
|
+
|
|
94
|
+
def chat_stream(self, message: str, context: int = None) -> Iterator[ChatResponse]:
|
|
95
|
+
url = f"https://api.agentx.so/api/v1/access/conversations/{self.id}/jsonmessagesse"
|
|
96
|
+
response = requests.post(
|
|
97
|
+
url, headers=get_headers(), json={"message": message, "context": context}
|
|
98
|
+
)
|
|
99
|
+
result = ""
|
|
100
|
+
if response.status_code == 200:
|
|
101
|
+
buf = b""
|
|
102
|
+
for chunk in response.iter_content():
|
|
103
|
+
buf += chunk
|
|
104
|
+
try:
|
|
105
|
+
chunk = buf.decode("utf-8")
|
|
106
|
+
# yield chunk
|
|
107
|
+
except UnicodeDecodeError:
|
|
108
|
+
continue
|
|
109
|
+
result += chunk
|
|
110
|
+
buf = b""
|
|
111
|
+
try:
|
|
112
|
+
if result.count("{") == result.count("}"):
|
|
113
|
+
catch_json = json.loads(result)
|
|
114
|
+
if catch_json:
|
|
115
|
+
result = ""
|
|
116
|
+
yield ChatResponse(
|
|
117
|
+
text=catch_json.get("text"),
|
|
118
|
+
cot=catch_json.get("cot"),
|
|
119
|
+
botId=catch_json.get("botId"),
|
|
120
|
+
reference=catch_json.get("reference"),
|
|
121
|
+
tasks=catch_json.get("tasks"),
|
|
122
|
+
)
|
|
123
|
+
except json.JSONDecodeError:
|
|
124
|
+
continue
|
|
125
|
+
else:
|
|
126
|
+
raise Exception(
|
|
127
|
+
f"Failed to send message: {response.status_code} - {response.reason}"
|
|
128
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.3.0"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: agentx-python
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
|
|
5
|
+
Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
|
|
6
|
+
Author: Robin Wang and AgentX Team
|
|
7
|
+
Author-email: contact@agentx.so
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: urllib3>=1.26.11
|
|
15
|
+
Requires-Dist: certifi
|
|
16
|
+
Dynamic: author
|
|
17
|
+
Dynamic: author-email
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# AgentX Python SDK API library
|
|
27
|
+
|
|
28
|
+
[](https://pypi.org/project/agentx-python/)
|
|
29
|
+
|
|
30
|
+
The AgentX Python SDK provides a convenient way to access to your Agent programmatically.
|
|
31
|
+
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install --upgrade agentx-python
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Provide an `api_key` inline or set `AGENTX_API_KEY` as an environment variable.
|
|
42
|
+
You can get an API key from https://app.agentx.so
|
|
43
|
+
|
|
44
|
+
### Agent
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from agentx_python import AgentX
|
|
48
|
+
|
|
49
|
+
client = AgentX(api_key="<your api key here>")
|
|
50
|
+
|
|
51
|
+
# Get the list of agents you have
|
|
52
|
+
print(client.list_agents())
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Conversation
|
|
56
|
+
|
|
57
|
+
Each Conversation has `agents` and `users` tied to it.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# get agent
|
|
61
|
+
my_agent = client.get_agent(id="<agent id here>")
|
|
62
|
+
|
|
63
|
+
# Get the list of conversation from this agent
|
|
64
|
+
print(my_agent.list_conversations())
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Chat
|
|
68
|
+
|
|
69
|
+
A `chat` needs to happen in the conversation. You can do `stream` response too, default `False`.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
a_conversation = my_agent.get_conversation(id="<conversation id here>")
|
|
73
|
+
|
|
74
|
+
response = a_conversation.chat("Hello, what is your name?", stream=True)
|
|
75
|
+
for chunk in response:
|
|
76
|
+
print(chunk, end="")
|
|
77
|
+
|
|
78
|
+
# output:
|
|
79
|
+
# My name is Rosita. I'm an AI assistant created by AgentX. It's nice to meet you! How can I help you today?
|
|
80
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
agentx/__init__.py
|
|
5
|
+
agentx/agentx.py
|
|
6
|
+
agentx/util.py
|
|
7
|
+
agentx/version.py
|
|
8
|
+
agentx/resources/__init__.py
|
|
9
|
+
agentx/resources/agent.py
|
|
10
|
+
agentx/resources/conversation.py
|
|
11
|
+
agentx_python.egg-info/PKG-INFO
|
|
12
|
+
agentx_python.egg-info/SOURCES.txt
|
|
13
|
+
agentx_python.egg-info/dependency_links.txt
|
|
14
|
+
agentx_python.egg-info/requires.txt
|
|
15
|
+
agentx_python.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
agentx
|
agentx-python-0.1/PKG-INFO
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: agentx-python
|
|
3
|
-
Version: 0.1
|
|
4
|
-
Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
|
|
5
|
-
Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
|
|
6
|
-
Author: Robin Wang and AgentX Team
|
|
7
|
-
Author-email: contact@agentx.so
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.6
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
|
|
15
|
-
# AgentX Python SDK
|
|
16
|
-
|
|
17
|
-
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pip install --upgrade agentx-python
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
from agentx_python import agent
|
|
29
|
-
print(agent.get_agent("your-agent-id-here"))
|
|
30
|
-
```
|
agentx-python-0.1/README.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# AgentX Python SDK
|
|
2
|
-
|
|
3
|
-
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install --upgrade agentx-python
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
from agentx_python import agent
|
|
15
|
-
print(agent.get_agent("your-agent-id-here"))
|
|
16
|
-
```
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import os
|
|
3
|
-
import logging
|
|
4
|
-
import agentx_python as agentx
|
|
5
|
-
from functools import wraps
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def api_key_check_decorator(method):
|
|
9
|
-
@wraps(method)
|
|
10
|
-
def wrapper(self, *args, **kwargs):
|
|
11
|
-
self.middleware()
|
|
12
|
-
return method(self, *args, **kwargs)
|
|
13
|
-
|
|
14
|
-
return wrapper
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class Agent:
|
|
18
|
-
|
|
19
|
-
def middleware(self):
|
|
20
|
-
self.api_key = os.getenv("AGENTX_API_KEY") or agentx.api_key
|
|
21
|
-
if not self.api_key:
|
|
22
|
-
raise Exception(
|
|
23
|
-
"No API key provided. You can set your API key in code using 'agentx.api_key = <API-KEY>', or you can set the environment variable AGENTX_API_KEY=<API-KEY>). You can generate API keys in the AgentX https://app.agentx.so."
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
@api_key_check_decorator
|
|
27
|
-
def get_agent(self, id: str):
|
|
28
|
-
url = f"https://api.agentx.so/api/v1/access/agents/{id}"
|
|
29
|
-
headers = {"accept": "*/*", "x-api-key": self.api_key}
|
|
30
|
-
|
|
31
|
-
# Make a GET request to the AgentX API
|
|
32
|
-
response = requests.get(url, headers=headers)
|
|
33
|
-
# Check if response was successful
|
|
34
|
-
if response.status_code == 200:
|
|
35
|
-
return response.json()
|
|
36
|
-
else:
|
|
37
|
-
logging.info(
|
|
38
|
-
response.json()
|
|
39
|
-
) # Print text content of response (or process it as needed)
|
|
40
|
-
raise Exception(
|
|
41
|
-
f"Failed to retrieve agent details: {response.status_code} - {response.reason}"
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
@api_key_check_decorator
|
|
45
|
-
def list_agents(self):
|
|
46
|
-
url = "https://api.agentx.so/api/v1/access/agents"
|
|
47
|
-
headers = {"accept": "*/*", "x-api-key": self.api_key}
|
|
48
|
-
|
|
49
|
-
# Make a GET request to the AgentX API
|
|
50
|
-
response = requests.get(url, headers=headers)
|
|
51
|
-
# Check if response was successful
|
|
52
|
-
if response.status_code == 200:
|
|
53
|
-
return response.json()
|
|
54
|
-
else:
|
|
55
|
-
logging.info(response.json())
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.1.0"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: agentx-python
|
|
3
|
-
Version: 0.1
|
|
4
|
-
Summary: Offical Python SDK for AgentX (https://www.agentx.so/)
|
|
5
|
-
Home-page: https://github.com/AgentX-ai/AgentX-python-sdk
|
|
6
|
-
Author: Robin Wang and AgentX Team
|
|
7
|
-
Author-email: contact@agentx.so
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.6
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
|
|
15
|
-
# AgentX Python SDK
|
|
16
|
-
|
|
17
|
-
This is a python SDK for AgentX (https://www.agentx.so/)
|
|
18
|
-
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pip install --upgrade agentx-python
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
from agentx_python import agent
|
|
29
|
-
print(agent.get_agent("your-agent-id-here"))
|
|
30
|
-
```
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
setup.py
|
|
4
|
-
agentx_python/__init__.py
|
|
5
|
-
agentx_python/agent.py
|
|
6
|
-
agentx_python/version.py
|
|
7
|
-
agentx_python.egg-info/PKG-INFO
|
|
8
|
-
agentx_python.egg-info/SOURCES.txt
|
|
9
|
-
agentx_python.egg-info/dependency_links.txt
|
|
10
|
-
agentx_python.egg-info/requires.txt
|
|
11
|
-
agentx_python.egg-info/top_level.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
agentx_python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|