persona-sdk-python 0.1.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.
- persona_sdk_python-0.1.0/.gitignore +7 -0
- persona_sdk_python-0.1.0/PKG-INFO +7 -0
- persona_sdk_python-0.1.0/README.md +351 -0
- persona_sdk_python-0.1.0/persona_sdk/__init__.py +32 -0
- persona_sdk_python-0.1.0/persona_sdk/api/__init__.py +0 -0
- persona_sdk_python-0.1.0/persona_sdk/api/agents.py +27 -0
- persona_sdk_python-0.1.0/persona_sdk/api/credentials.py +21 -0
- persona_sdk_python-0.1.0/persona_sdk/api/features.py +27 -0
- persona_sdk_python-0.1.0/persona_sdk/api/knowledge_bases.py +34 -0
- persona_sdk_python-0.1.0/persona_sdk/api/missions.py +41 -0
- persona_sdk_python-0.1.0/persona_sdk/api/projects.py +27 -0
- persona_sdk_python-0.1.0/persona_sdk/api/service_prices.py +24 -0
- persona_sdk_python-0.1.0/persona_sdk/api/sessions.py +42 -0
- persona_sdk_python-0.1.0/persona_sdk/api/triggers.py +34 -0
- persona_sdk_python-0.1.0/persona_sdk/api/workflows.py +34 -0
- persona_sdk_python-0.1.0/persona_sdk/client.py +50 -0
- persona_sdk_python-0.1.0/persona_sdk/runners/__init__.py +3 -0
- persona_sdk_python-0.1.0/persona_sdk/runners/agent_runner.py +70 -0
- persona_sdk_python-0.1.0/persona_sdk/runners/resource_retriever.py +68 -0
- persona_sdk_python-0.1.0/persona_sdk/runners/tool_invoker.py +59 -0
- persona_sdk_python-0.1.0/pyproject.toml +16 -0
- persona_sdk_python-0.1.0/uv.lock +265 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# Persona Python SDK
|
|
2
|
+
|
|
3
|
+
Python SDK client for the Persona AI platform.
|
|
4
|
+
|
|
5
|
+
## Installation & Setup
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# Requirements: Python >= 3.10, httpx>=0.27.0, persona-models
|
|
9
|
+
from persona_sdk import PersonaSdk
|
|
10
|
+
|
|
11
|
+
sdk = PersonaSdk(
|
|
12
|
+
base_url="http://localhost:8000",
|
|
13
|
+
api_key="<api-key-or-jwt-token>",
|
|
14
|
+
workflows_url="http://...", # optional, defaults to base_url
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
# Always close the client when done
|
|
18
|
+
await sdk.close()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
All methods are **async**. The SDK exposes: `sdk.agents`, `sdk.sessions`, `sdk.workflows`, `sdk.knowledge_bases`, `sdk.triggers`, `sdk.credentials`, `sdk.projects`, `sdk.features`, `sdk.missions`, `sdk.service_prices`.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Sending Messages to an Agent — `AgentRunner`
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from persona_sdk.runners import AgentRunner
|
|
29
|
+
|
|
30
|
+
async with AgentRunner(
|
|
31
|
+
client=sdk.client,
|
|
32
|
+
agent_id="my-agent",
|
|
33
|
+
session_code="session-123", # optional, auto-generated if omitted
|
|
34
|
+
parent_session_id=None, # optional
|
|
35
|
+
user_id="user-456", # optional
|
|
36
|
+
session_type="async", # "async" | "realtime"
|
|
37
|
+
) as runner:
|
|
38
|
+
|
|
39
|
+
# Plain string
|
|
40
|
+
response = await runner.run("Hello!")
|
|
41
|
+
|
|
42
|
+
# Structured Message object
|
|
43
|
+
from persona_models.sessions import Message
|
|
44
|
+
response = await runner.run(Message(role="user", text="Hello!"))
|
|
45
|
+
|
|
46
|
+
# List of messages
|
|
47
|
+
response = await runner.run([Message(...), Message(...)])
|
|
48
|
+
|
|
49
|
+
# Force structured JSON output (Pydantic schema)
|
|
50
|
+
from pydantic import BaseModel
|
|
51
|
+
class MyOutput(BaseModel):
|
|
52
|
+
answer: str
|
|
53
|
+
response = await runner.run("Tell me something", response_schema=MyOutput)
|
|
54
|
+
|
|
55
|
+
# With initial context (data + optional files)
|
|
56
|
+
from persona_models.sessions import AgentContext
|
|
57
|
+
response = await runner.run("Hello!", context=AgentContext(data={"user_name": "Alice"}))
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `AgentResponse`
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
response.text # str — concatenated text from all messages
|
|
64
|
+
response.messages # List[Message]
|
|
65
|
+
response.is_json() # bool
|
|
66
|
+
response.to_json() # dict | list | None
|
|
67
|
+
response.function_calls # List[FunctionCall]
|
|
68
|
+
response.first_function_call # FunctionCall | None
|
|
69
|
+
response.is_transfer() # bool — True if agent delegated to another agent
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `Message` fields
|
|
73
|
+
|
|
74
|
+
| Field | Type | Notes |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `id` | `str` | auto-generated UUID |
|
|
77
|
+
| `role` | `"user"`, `"assistant"`, `"function"`, `"tool"` | |
|
|
78
|
+
| `text` | `str \| None` | |
|
|
79
|
+
| `image` | `Image \| None` | base64-encoded |
|
|
80
|
+
| `file` | `File \| None` | name, url or base64, content_type |
|
|
81
|
+
| `function_calls` | `List[FunctionCall] \| None` | |
|
|
82
|
+
| `function_response` | `FunctionResponse \| None` | |
|
|
83
|
+
| `finish_reason` | `"stop"`, `"function_call"`, `None` | |
|
|
84
|
+
| `thought` | `bool` | True for reasoning/thought messages |
|
|
85
|
+
| `sources` | `list \| None` | RAG sources |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Agent Schema — `AgentConfiguration`
|
|
90
|
+
|
|
91
|
+
Used when creating or updating agents via `sdk.agents.create(agent.model_dump(by_alias=True))`.
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from persona_models.agents import (
|
|
95
|
+
AgentConfiguration, ModelConfiguration, SynthesizerConfiguration,
|
|
96
|
+
TranscriberConfiguration, ToolkitConfiguration, Tool, ToolRemoteConfig,
|
|
97
|
+
KnowledgeConfiguration, CollaborationConfiguration,
|
|
98
|
+
WakeupConfiguration, TelegramConfiguration, WhatsAppConfiguration,
|
|
99
|
+
StmConfiguration, Variable, Collaborator,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
agent = AgentConfiguration(
|
|
103
|
+
name="MyAgent",
|
|
104
|
+
description="An assistant agent",
|
|
105
|
+
model=ModelConfiguration(
|
|
106
|
+
model_name="gemini-2.0-flash", # see supported models below
|
|
107
|
+
temperature=1.0,
|
|
108
|
+
reasoning_effort=None, # "minimal"|"low"|"medium"|"high"|None
|
|
109
|
+
),
|
|
110
|
+
system_instructions="You are a helpful assistant.",
|
|
111
|
+
language_code="en-US", # "en-US"|"it-IT"|"es-ES"|"fr-FR"|"de-DE"|"pt-BR"
|
|
112
|
+
initial_message="Hello! How can I help?",
|
|
113
|
+
enabled_protocols=["rest", "websocket"], # "webrtc"|"twilio"|"rest"|"websocket"|"telegram"
|
|
114
|
+
variables=[Variable(name="company", value="Acme", description="Company name")],
|
|
115
|
+
|
|
116
|
+
# Voice synthesis (optional)
|
|
117
|
+
synthesizer=SynthesizerConfiguration(
|
|
118
|
+
enabled=True,
|
|
119
|
+
synthesizer_name="gcloud", # "gcloud"|"elevenlabs"|"gtts"|"openai"
|
|
120
|
+
language_code="en-US",
|
|
121
|
+
voice="en-US-Neural2-A",
|
|
122
|
+
sample_rate_hertz=24000,
|
|
123
|
+
),
|
|
124
|
+
|
|
125
|
+
# Speech transcription (optional)
|
|
126
|
+
transcriber=TranscriberConfiguration(
|
|
127
|
+
enabled=True,
|
|
128
|
+
transcriber_name="gcloud", # "gcloud"|"deepgram"
|
|
129
|
+
language_code="en-US",
|
|
130
|
+
),
|
|
131
|
+
|
|
132
|
+
# Tools (optional)
|
|
133
|
+
toolkit=ToolkitConfiguration(tools=[
|
|
134
|
+
Tool(
|
|
135
|
+
type="remote", # "remote"|"local"
|
|
136
|
+
name="my_tool",
|
|
137
|
+
description="Does something",
|
|
138
|
+
config=ToolRemoteConfig(service_url="https://...", secret="s3cr3t", timeout=60),
|
|
139
|
+
)
|
|
140
|
+
]),
|
|
141
|
+
|
|
142
|
+
# Knowledge base / RAG (optional)
|
|
143
|
+
knowledge=KnowledgeConfiguration(
|
|
144
|
+
enabled=True,
|
|
145
|
+
knowledge_type="simple", # "simple"|"multi_hop"
|
|
146
|
+
knowledge_base_id="kb-id",
|
|
147
|
+
namespace="my-namespace",
|
|
148
|
+
number_of_entries=3,
|
|
149
|
+
),
|
|
150
|
+
|
|
151
|
+
# Multi-agent collaboration (optional)
|
|
152
|
+
collaboration=CollaborationConfiguration(
|
|
153
|
+
enabled=True,
|
|
154
|
+
mode="delegate_and_return", # "persistent_transfer"|"delegate_and_return"|"consult_then_respond"
|
|
155
|
+
max_number_of_iterations=10,
|
|
156
|
+
collaborators=[Collaborator(agent_id="other-agent-id", scope="handle billing questions")],
|
|
157
|
+
),
|
|
158
|
+
|
|
159
|
+
# Short-term memory (optional)
|
|
160
|
+
short_term_memory=StmConfiguration(
|
|
161
|
+
type="summary", # "simple"|"summary"
|
|
162
|
+
max_messages=10,
|
|
163
|
+
max_number_of_words=50,
|
|
164
|
+
include_tool_calls=False,
|
|
165
|
+
),
|
|
166
|
+
|
|
167
|
+
verbose_errors=False,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
result = await sdk.agents.create(agent.model_dump(by_alias=True))
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Supported `model_name` values
|
|
174
|
+
|
|
175
|
+
| Provider | Models |
|
|
176
|
+
|---|---|
|
|
177
|
+
| Google | `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2.5-flash-lite`, `gemini-2.0-flash`, `gemini-1.5-pro`, `gemini-1.5-flash`, … |
|
|
178
|
+
| OpenAI | `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o`, `gpt-4o-mini`, `o4-mini`, `o3-mini`, `o1`, `o1-mini`, … |
|
|
179
|
+
| Grok | `grok-4-0709`, `grok-3`, `grok-3-mini`, `grok-2-vision-1212`, … |
|
|
180
|
+
| Fireworks | `accounts/fireworks/models/deepseek-v3p2`, `accounts/fireworks/models/kimi-k2p5`, … |
|
|
181
|
+
| Other | `ollama` (requires `url` and `ollama_model_name` in `ModelConfiguration`) |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Agents API
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
agents = await sdk.agents.list(keyword="chatbot", page=1, size=20)
|
|
189
|
+
agent = await sdk.agents.get("agent-id")
|
|
190
|
+
agent = await sdk.agents.create({...}) # AgentConfiguration.model_dump(by_alias=True)
|
|
191
|
+
agent = await sdk.agents.update("agent-id", {...})
|
|
192
|
+
await sdk.agents.delete("agent-id")
|
|
193
|
+
voices = await sdk.agents.get_voices("elevenlabs") # "gcloud"|"elevenlabs"|"gtts"|"openai"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Sessions API
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
sessions = await sdk.sessions.list(keyword=None, status=None, agent_id=None, user_id=None, page=1, size=20)
|
|
202
|
+
session = await sdk.sessions.get("session-id")
|
|
203
|
+
usage = await sdk.sessions.get_usage("session-id")
|
|
204
|
+
messages = await sdk.sessions.get_messages("session-code", page=1, size=20)
|
|
205
|
+
result = await sdk.sessions.generate_message("session-code", request_dict)
|
|
206
|
+
await sdk.sessions.delete("session-code")
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Workflows API
|
|
212
|
+
|
|
213
|
+
### `Workflow` schema
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from persona_models.workflows import Workflow, Node, Connection
|
|
217
|
+
|
|
218
|
+
workflow = Workflow(
|
|
219
|
+
name="My Workflow",
|
|
220
|
+
description="Does something useful",
|
|
221
|
+
nodes=[
|
|
222
|
+
Node(id="node-1", type="agent", label="Step 1", data={"agentId": "agent-id"}),
|
|
223
|
+
Node(id="node-2", type="agent", label="Step 2", data={"agentId": "agent-id-2"}),
|
|
224
|
+
],
|
|
225
|
+
connections=[
|
|
226
|
+
Connection(source_id="node-1", target_id="node-2"),
|
|
227
|
+
],
|
|
228
|
+
root_node=Node(id="node-0", type="trigger", label="Start"),
|
|
229
|
+
)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
workflows = await sdk.workflows.list(keyword=None, page=1, size=20)
|
|
234
|
+
wf = await sdk.workflows.get("wf-id")
|
|
235
|
+
wf = await sdk.workflows.create(workflow.model_dump(by_alias=True))
|
|
236
|
+
wf = await sdk.workflows.update("wf-id", {...})
|
|
237
|
+
await sdk.workflows.delete("wf-id")
|
|
238
|
+
|
|
239
|
+
# Synchronous execution — waits for result
|
|
240
|
+
result = await sdk.workflows.execute("wf-id", data={"input": "value"})
|
|
241
|
+
|
|
242
|
+
# Async execution — enqueues, returns immediately
|
|
243
|
+
result = await sdk.workflows.queue("wf-id", data={"input": "value"})
|
|
244
|
+
|
|
245
|
+
# Past executions
|
|
246
|
+
execs = await sdk.workflows.list_executions("wf-id", page=1, size=20)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Knowledge Bases API
|
|
252
|
+
|
|
253
|
+
### `KnowledgeBase` schema
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
from persona_models.knowledge_bases import KnowledgeBase
|
|
257
|
+
|
|
258
|
+
kb = KnowledgeBase(
|
|
259
|
+
name="My KB",
|
|
260
|
+
description="Product documentation",
|
|
261
|
+
quality="high", # "extremely_high"|"very_high"|"high"|"medium"|"low"
|
|
262
|
+
chunk_size="medium", # "small"|"medium"|"large"
|
|
263
|
+
embedding_model="text-multilingual-embedding-002",
|
|
264
|
+
)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
kbs = await sdk.knowledge_bases.list()
|
|
269
|
+
kb = await sdk.knowledge_bases.get("kb-id")
|
|
270
|
+
kb = await sdk.knowledge_bases.create(kb.model_dump(by_alias=True))
|
|
271
|
+
kb = await sdk.knowledge_bases.update("kb-id", {...})
|
|
272
|
+
await sdk.knowledge_bases.delete("kb-id")
|
|
273
|
+
|
|
274
|
+
docs = await sdk.knowledge_bases.list_documents("kb-id", page=1, size=20)
|
|
275
|
+
await sdk.knowledge_bases.delete_document("kb-id", "doc-id")
|
|
276
|
+
|
|
277
|
+
# Semantic search
|
|
278
|
+
results = await sdk.knowledge_bases.search_chunks("kb-id", {
|
|
279
|
+
"query": "search text",
|
|
280
|
+
"topK": 5,
|
|
281
|
+
"threshold": 0.7, # optional, float 0-1
|
|
282
|
+
})
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## MCP Tools — `ToolInvoker`
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
from persona_sdk.runners import ToolInvoker
|
|
291
|
+
from persona_models.mcp import McpTransport
|
|
292
|
+
|
|
293
|
+
result = await ToolInvoker.invoke(
|
|
294
|
+
client=sdk.client,
|
|
295
|
+
mcp_server_name="my-mcp-server",
|
|
296
|
+
transport=McpTransport(...),
|
|
297
|
+
tool_name="my_tool",
|
|
298
|
+
args={"param1": "value1"},
|
|
299
|
+
session_id="session-123", # optional
|
|
300
|
+
user_id="user-456", # optional
|
|
301
|
+
billing_disabled=False,
|
|
302
|
+
)
|
|
303
|
+
# returns ToolInvokeResponse
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## MCP Resources — `ResourceRetriever`
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
from persona_sdk.runners import ResourceRetriever
|
|
310
|
+
|
|
311
|
+
content = await ResourceRetriever.retrieve(
|
|
312
|
+
client=sdk.client,
|
|
313
|
+
mcp_server_name="my-mcp-server",
|
|
314
|
+
transport=McpTransport(...),
|
|
315
|
+
uri="resource://...",
|
|
316
|
+
session_id="session-123",
|
|
317
|
+
)
|
|
318
|
+
# returns: str (text), dict {"content": ..., "content_type": ...} (blob), or None
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Complete Example
|
|
324
|
+
|
|
325
|
+
```python
|
|
326
|
+
import asyncio
|
|
327
|
+
from persona_sdk import PersonaSdk
|
|
328
|
+
from persona_sdk.runners import AgentRunner
|
|
329
|
+
from persona_models.agents import AgentConfiguration, ModelConfiguration
|
|
330
|
+
|
|
331
|
+
async def main():
|
|
332
|
+
sdk = PersonaSdk(base_url="http://localhost:8000", api_key="my-key")
|
|
333
|
+
try:
|
|
334
|
+
# Create an agent
|
|
335
|
+
agent = AgentConfiguration(
|
|
336
|
+
name="Assistant",
|
|
337
|
+
model=ModelConfiguration(model_name="gemini-2.0-flash"),
|
|
338
|
+
system_instructions="You are a helpful assistant.",
|
|
339
|
+
)
|
|
340
|
+
created = await sdk.agents.create(agent.model_dump(by_alias=True))
|
|
341
|
+
agent_id = created["id"]
|
|
342
|
+
|
|
343
|
+
# Run a conversation
|
|
344
|
+
async with AgentRunner(sdk.client, agent_id=agent_id) as runner:
|
|
345
|
+
response = await runner.run("What is the capital of France?")
|
|
346
|
+
print(response.text)
|
|
347
|
+
finally:
|
|
348
|
+
await sdk.close()
|
|
349
|
+
|
|
350
|
+
asyncio.run(main())
|
|
351
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
from persona_sdk.api.agents import AgentsApi
|
|
3
|
+
from persona_sdk.api.workflows import WorkflowsApi
|
|
4
|
+
from persona_sdk.api.triggers import TriggersApi
|
|
5
|
+
from persona_sdk.api.sessions import SessionsApi
|
|
6
|
+
from persona_sdk.api.credentials import CredentialsApi
|
|
7
|
+
from persona_sdk.api.knowledge_bases import KnowledgeBasesApi
|
|
8
|
+
from persona_sdk.api.projects import ProjectsApi
|
|
9
|
+
from persona_sdk.api.features import FeaturesApi
|
|
10
|
+
from persona_sdk.api.missions import MissionsApi
|
|
11
|
+
from persona_sdk.api.service_prices import ServicePricesApi
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PersonaSdk:
|
|
15
|
+
def __init__(self, base_url: str, api_key: str, workflows_url: str = None):
|
|
16
|
+
self.client = PersonaClient(base_url, api_key)
|
|
17
|
+
self.workflows_client = PersonaClient(workflows_url, api_key) if workflows_url else self.client
|
|
18
|
+
self.agents = AgentsApi(self.client)
|
|
19
|
+
self.workflows = WorkflowsApi(self.workflows_client)
|
|
20
|
+
self.triggers = TriggersApi(self.client)
|
|
21
|
+
self.sessions = SessionsApi(self.client)
|
|
22
|
+
self.credentials = CredentialsApi(self.client)
|
|
23
|
+
self.knowledge_bases = KnowledgeBasesApi(self.client)
|
|
24
|
+
self.projects = ProjectsApi(self.client)
|
|
25
|
+
self.features = FeaturesApi(self.client)
|
|
26
|
+
self.missions = MissionsApi(self.client)
|
|
27
|
+
self.service_prices = ServicePricesApi(self.client)
|
|
28
|
+
|
|
29
|
+
async def close(self):
|
|
30
|
+
await self.client.close()
|
|
31
|
+
if self.workflows_client is not self.client:
|
|
32
|
+
await self.workflows_client.close()
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AgentsApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
return await self._client.get("/agents", params=params)
|
|
13
|
+
|
|
14
|
+
async def get(self, agent_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/agents/{agent_id}")
|
|
16
|
+
|
|
17
|
+
async def create(self, agent: dict) -> dict:
|
|
18
|
+
return await self._client.post("/agents", json=agent)
|
|
19
|
+
|
|
20
|
+
async def update(self, agent_id: str, agent: dict) -> dict:
|
|
21
|
+
return await self._client.put(f"/agents/{agent_id}", json=agent)
|
|
22
|
+
|
|
23
|
+
async def delete(self, agent_id: str) -> dict:
|
|
24
|
+
return await self._client.delete(f"/agents/{agent_id}")
|
|
25
|
+
|
|
26
|
+
async def get_voices(self, synthesizer_type: str) -> dict:
|
|
27
|
+
return await self._client.get(f"/values/synthesizers/{synthesizer_type}/voices")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CredentialsApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self) -> dict:
|
|
9
|
+
return await self._client.get("/credentials")
|
|
10
|
+
|
|
11
|
+
async def list_by_provider(self, provider: str) -> dict:
|
|
12
|
+
return await self._client.get(f"/credentials/{provider}")
|
|
13
|
+
|
|
14
|
+
async def get(self, credentials_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/credentials/all/{credentials_id}")
|
|
16
|
+
|
|
17
|
+
async def authorize(self, provider: str, request: dict) -> dict:
|
|
18
|
+
return await self._client.post(f"/credentials/{provider}/authorize", json=request)
|
|
19
|
+
|
|
20
|
+
async def delete(self, credentials_id: str) -> dict:
|
|
21
|
+
return await self._client.delete(f"/credentials/all/{credentials_id}")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class FeaturesApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
return await self._client.get("/features/templates", params=params)
|
|
13
|
+
|
|
14
|
+
async def get(self, template_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/features/templates/{template_id}")
|
|
16
|
+
|
|
17
|
+
async def create(self, feature_template: dict) -> dict:
|
|
18
|
+
return await self._client.post("/features/templates", json=feature_template)
|
|
19
|
+
|
|
20
|
+
async def update(self, template_id: str, feature_template: dict) -> dict:
|
|
21
|
+
return await self._client.put(f"/features/templates/{template_id}", json=feature_template)
|
|
22
|
+
|
|
23
|
+
async def delete(self, template_id: str) -> dict:
|
|
24
|
+
return await self._client.delete(f"/features/templates/{template_id}")
|
|
25
|
+
|
|
26
|
+
async def get_mcp_tools(self, mcp_config: dict) -> dict:
|
|
27
|
+
return await self._client.post("/features/templates/mcp/available-tools", json=mcp_config)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class KnowledgeBasesApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
return await self._client.get("/knowledges", params=params)
|
|
13
|
+
|
|
14
|
+
async def get(self, knowledge_base_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/knowledges/{knowledge_base_id}")
|
|
16
|
+
|
|
17
|
+
async def create(self, knowledge_base: dict) -> dict:
|
|
18
|
+
return await self._client.post("/knowledges", json=knowledge_base)
|
|
19
|
+
|
|
20
|
+
async def update(self, knowledge_base_id: str, knowledge_base: dict) -> dict:
|
|
21
|
+
return await self._client.put(f"/knowledges/{knowledge_base_id}", json=knowledge_base)
|
|
22
|
+
|
|
23
|
+
async def delete(self, knowledge_base_id: str) -> dict:
|
|
24
|
+
return await self._client.delete(f"/knowledges/{knowledge_base_id}")
|
|
25
|
+
|
|
26
|
+
async def list_documents(self, knowledge_base_id: str, page: int = 1, size: int = 20) -> dict:
|
|
27
|
+
params = {"page": page, "size": size}
|
|
28
|
+
return await self._client.get(f"/knowledges/{knowledge_base_id}/documents", params=params)
|
|
29
|
+
|
|
30
|
+
async def delete_document(self, knowledge_base_id: str, document_id: str) -> dict:
|
|
31
|
+
return await self._client.delete(f"/knowledges/{knowledge_base_id}/documents/{document_id}")
|
|
32
|
+
|
|
33
|
+
async def search_chunks(self, knowledge_base_id: str, request: dict) -> dict:
|
|
34
|
+
return await self._client.post(f"/knowledges/{knowledge_base_id}/search", json=request)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MissionsApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, status: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
if status:
|
|
13
|
+
params["status"] = status
|
|
14
|
+
return await self._client.get("/missions", params=params)
|
|
15
|
+
|
|
16
|
+
async def get(self, mission_id: str) -> dict:
|
|
17
|
+
return await self._client.get(f"/missions/{mission_id}")
|
|
18
|
+
|
|
19
|
+
async def create(self, mission: dict) -> dict:
|
|
20
|
+
return await self._client.post("/missions", json=mission)
|
|
21
|
+
|
|
22
|
+
async def update(self, mission_id: str, mission: dict) -> dict:
|
|
23
|
+
return await self._client.put(f"/missions/{mission_id}", json=mission)
|
|
24
|
+
|
|
25
|
+
async def delete(self, mission_id: str) -> dict:
|
|
26
|
+
return await self._client.delete(f"/missions/{mission_id}")
|
|
27
|
+
|
|
28
|
+
async def generate(self, mission_id: str) -> dict:
|
|
29
|
+
return await self._client.post(f"/missions/{mission_id}/generate")
|
|
30
|
+
|
|
31
|
+
async def execute(self, mission_id: str) -> dict:
|
|
32
|
+
return await self._client.post(f"/missions/{mission_id}/execute")
|
|
33
|
+
|
|
34
|
+
async def continue_mission(self, mission_id: str) -> dict:
|
|
35
|
+
return await self._client.post(f"/missions/{mission_id}/continue")
|
|
36
|
+
|
|
37
|
+
async def stop(self, mission_id: str) -> dict:
|
|
38
|
+
return await self._client.post(f"/missions/{mission_id}/stop")
|
|
39
|
+
|
|
40
|
+
async def send_instructions(self, mission_id: str, instructions: dict) -> dict:
|
|
41
|
+
return await self._client.post(f"/missions/{mission_id}/instructions", json=instructions)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ProjectsApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
return await self._client.get("/projects", params=params)
|
|
13
|
+
|
|
14
|
+
async def get(self, project_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/projects/{project_id}")
|
|
16
|
+
|
|
17
|
+
async def get_mine(self) -> dict:
|
|
18
|
+
return await self._client.get("/projects/mine")
|
|
19
|
+
|
|
20
|
+
async def create(self, project: dict) -> dict:
|
|
21
|
+
return await self._client.post("/projects", json=project)
|
|
22
|
+
|
|
23
|
+
async def update(self, project_id: str, project: dict) -> dict:
|
|
24
|
+
return await self._client.put(f"/projects/{project_id}", json=project)
|
|
25
|
+
|
|
26
|
+
async def delete(self, project_id: str) -> dict:
|
|
27
|
+
return await self._client.delete(f"/projects/{project_id}")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ServicePricesApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(self, keyword: str = None, page: int = 1, size: int = 20) -> dict:
|
|
9
|
+
params = {"page": page, "size": size}
|
|
10
|
+
if keyword:
|
|
11
|
+
params["keyword"] = keyword
|
|
12
|
+
return await self._client.get("/service-prices", params=params)
|
|
13
|
+
|
|
14
|
+
async def get(self, service_price_id: str) -> dict:
|
|
15
|
+
return await self._client.get(f"/service-prices/{service_price_id}")
|
|
16
|
+
|
|
17
|
+
async def create(self, service_price: dict) -> dict:
|
|
18
|
+
return await self._client.post("/service-prices", json=service_price)
|
|
19
|
+
|
|
20
|
+
async def update(self, service_price_id: str, service_price: dict) -> dict:
|
|
21
|
+
return await self._client.put(f"/service-prices/{service_price_id}", json=service_price)
|
|
22
|
+
|
|
23
|
+
async def delete(self, service_price_id: str) -> dict:
|
|
24
|
+
return await self._client.delete(f"/service-prices/{service_price_id}")
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from persona_sdk.client import PersonaClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SessionsApi:
|
|
5
|
+
def __init__(self, client: PersonaClient):
|
|
6
|
+
self._client = client
|
|
7
|
+
|
|
8
|
+
async def list(
|
|
9
|
+
self,
|
|
10
|
+
keyword: str = None,
|
|
11
|
+
status: str = None,
|
|
12
|
+
agent_id: str = None,
|
|
13
|
+
user_id: str = None,
|
|
14
|
+
page: int = 1,
|
|
15
|
+
size: int = 20,
|
|
16
|
+
) -> dict:
|
|
17
|
+
params = {"page": page, "size": size}
|
|
18
|
+
if keyword:
|
|
19
|
+
params["keyword"] = keyword
|
|
20
|
+
if status:
|
|
21
|
+
params["status"] = status
|
|
22
|
+
if agent_id:
|
|
23
|
+
params["agentId"] = agent_id
|
|
24
|
+
if user_id:
|
|
25
|
+
params["userId"] = user_id
|
|
26
|
+
return await self._client.get("/sessions", params=params)
|
|
27
|
+
|
|
28
|
+
async def get(self, session_id: str) -> dict:
|
|
29
|
+
return await self._client.get(f"/sessions/{session_id}")
|
|
30
|
+
|
|
31
|
+
async def get_usage(self, session_id: str) -> dict:
|
|
32
|
+
return await self._client.get(f"/sessions/{session_id}/usage")
|
|
33
|
+
|
|
34
|
+
async def generate_message(self, code: str, request: dict) -> dict:
|
|
35
|
+
return await self._client.post(f"/sessions/{code}/messages", json=request)
|
|
36
|
+
|
|
37
|
+
async def get_messages(self, code: str, page: int = 1, size: int = 20) -> dict:
|
|
38
|
+
params = {"page": page, "size": size}
|
|
39
|
+
return await self._client.get(f"/sessions/{code}/messages", params=params)
|
|
40
|
+
|
|
41
|
+
async def delete(self, code: str) -> dict:
|
|
42
|
+
return await self._client.delete(f"/sessions/{code}")
|