meshagent-agents 0.5.8b5__tar.gz → 0.5.13__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 meshagent-agents might be problematic. Click here for more details.
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/CHANGELOG.md +4 -1
- {meshagent_agents-0.5.8b5/meshagent_agents.egg-info → meshagent_agents-0.5.13}/PKG-INFO +7 -7
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/agent.py +6 -11
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/chat.py +2 -2
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/development.py +1 -3
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/hosting.py +2 -2
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/mail.py +4 -1
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/utils.py +2 -0
- meshagent_agents-0.5.13/meshagent/agents/version.py +1 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13/meshagent_agents.egg-info}/PKG-INFO +7 -7
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/SOURCES.txt +0 -1
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/requires.txt +5 -5
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/pyproject.toml +6 -6
- meshagent_agents-0.5.8b5/meshagent/agents/llmrunner.py +0 -169
- meshagent_agents-0.5.8b5/meshagent/agents/version.py +0 -1
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/LICENSE +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/MANIFEST.in +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/README.md +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/__init__.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/adapter.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/context.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/indexer.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/listener.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/planning.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/prompt.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/pydantic.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/__init__.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/document.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/gallery.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/presentation.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/schema.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/super_editor_document.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/single_shot_writer.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/thread_schema.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/worker.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/writer.py +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/dependency_links.txt +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/top_level.txt +0 -0
- {meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/setup.cfg +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-agents
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.13
|
|
4
4
|
Summary: Agent Building Blocks for Meshagent
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Documentation, https://docs.meshagent.com
|
|
7
7
|
Project-URL: Website, https://www.meshagent.com
|
|
8
8
|
Project-URL: Source, https://www.meshagent.com
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: pyjwt~=2.10
|
|
13
13
|
Requires-Dist: pytest~=8.4
|
|
14
14
|
Requires-Dist: pytest-asyncio~=0.26
|
|
15
|
-
Requires-Dist: meshagent-api~=0.5.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.5.
|
|
17
|
-
Requires-Dist: meshagent-openai~=0.5.
|
|
15
|
+
Requires-Dist: meshagent-api~=0.5.13
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.5.13
|
|
17
|
+
Requires-Dist: meshagent-openai~=0.5.13
|
|
18
18
|
Requires-Dist: pydantic~=2.11
|
|
19
19
|
Requires-Dist: opentelemetry-distro~=0.54b1
|
|
20
20
|
Provides-Extra: all
|
|
21
|
-
Requires-Dist: meshagent-api[all]~=0.5.
|
|
21
|
+
Requires-Dist: meshagent-api[all]~=0.5.13; extra == "all"
|
|
22
22
|
Requires-Dist: chonkie~=0.5.1; extra == "all"
|
|
23
23
|
Requires-Dist: chonkie[semantic]~=0.5.1; extra == "all"
|
|
24
24
|
Requires-Dist: chonkie[openai]~=0.5.1; extra == "all"
|
|
25
25
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "all"
|
|
26
26
|
Provides-Extra: sync
|
|
27
|
-
Requires-Dist: meshagent-api[sync]~=0.5.
|
|
27
|
+
Requires-Dist: meshagent-api[sync]~=0.5.13; extra == "sync"
|
|
28
28
|
Provides-Extra: mail
|
|
29
29
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
|
|
30
30
|
Provides-Extra: rag
|
|
@@ -12,6 +12,7 @@ from meshagent.api import (
|
|
|
12
12
|
ToolkitDescription,
|
|
13
13
|
Participant,
|
|
14
14
|
RemoteParticipant,
|
|
15
|
+
meshagent_base_url,
|
|
15
16
|
StorageEntry,
|
|
16
17
|
)
|
|
17
18
|
from meshagent.api.protocol import Protocol
|
|
@@ -193,8 +194,6 @@ class SingleRoomAgent(Agent):
|
|
|
193
194
|
|
|
194
195
|
installed = False
|
|
195
196
|
|
|
196
|
-
builtin_agents_url = "http://localhost:8080"
|
|
197
|
-
|
|
198
197
|
for requirement in self.requires:
|
|
199
198
|
if isinstance(requirement, RequiredToolkit):
|
|
200
199
|
if toolkit_factory(requirement.name) is not None:
|
|
@@ -208,14 +207,12 @@ class SingleRoomAgent(Agent):
|
|
|
208
207
|
if requirement.name not in toolkits_by_name:
|
|
209
208
|
installed = True
|
|
210
209
|
|
|
211
|
-
logger.info(f"
|
|
210
|
+
logger.info(f"Installing required tool {requirement.name}")
|
|
212
211
|
|
|
213
|
-
if requirement.name.startswith(
|
|
214
|
-
"https://"
|
|
215
|
-
) or requirement.name.startswith("http://"):
|
|
212
|
+
if requirement.name.startswith("https://"):
|
|
216
213
|
url = requirement.name
|
|
217
214
|
else:
|
|
218
|
-
url = f"{
|
|
215
|
+
url = f"{meshagent_base_url()}/toolkits/{requirement.name}"
|
|
219
216
|
|
|
220
217
|
await self._room.agents.make_call(
|
|
221
218
|
url=url, name=requirement.name, arguments={}
|
|
@@ -227,12 +224,10 @@ class SingleRoomAgent(Agent):
|
|
|
227
224
|
|
|
228
225
|
logger.info(f"Installing required schema {requirement.name}")
|
|
229
226
|
|
|
230
|
-
if requirement.name.startswith(
|
|
231
|
-
"https://"
|
|
232
|
-
) or requirement.name.startswith("http://"):
|
|
227
|
+
if requirement.name.startswith("https://"):
|
|
233
228
|
url = requirement.name
|
|
234
229
|
else:
|
|
235
|
-
url = f"{
|
|
230
|
+
url = f"{meshagent_base_url()}/schemas/{requirement.name}"
|
|
236
231
|
|
|
237
232
|
await self._room.agents.make_call(
|
|
238
233
|
url=url, name=requirement.name, arguments={}
|
|
@@ -448,7 +448,7 @@ class ChatBot(SingleRoomAgent):
|
|
|
448
448
|
if doc_messages is None:
|
|
449
449
|
raise Exception("thread was not properly initialized")
|
|
450
450
|
|
|
451
|
-
async def prepare_llm_context(self, *,
|
|
451
|
+
async def prepare_llm_context(self, *, context: ChatThreadContext):
|
|
452
452
|
"""
|
|
453
453
|
called prior to sending the request to the LLM in case the agent needs to modify the context prior to sending
|
|
454
454
|
"""
|
|
@@ -736,7 +736,7 @@ class ChatBot(SingleRoomAgent):
|
|
|
736
736
|
)
|
|
737
737
|
|
|
738
738
|
await self.prepare_llm_context(
|
|
739
|
-
|
|
739
|
+
context=thread_context
|
|
740
740
|
)
|
|
741
741
|
|
|
742
742
|
llm_messages = asyncio.Queue[ResponseStreamEvent]()
|
|
@@ -2,10 +2,8 @@ from .agent import SingleRoomAgent
|
|
|
2
2
|
from meshagent.api import websocket_protocol, RoomClient
|
|
3
3
|
import asyncio
|
|
4
4
|
import signal
|
|
5
|
-
from warnings import deprecated
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
@deprecated("use ServiceHost and the cli to connect agents to the room")
|
|
9
7
|
async def connect_development_agent(*, room_name: str, agent: SingleRoomAgent):
|
|
10
8
|
async with RoomClient(
|
|
11
9
|
protocol=websocket_protocol(
|
|
@@ -24,7 +22,7 @@ async def connect_development_agent(*, room_name: str, agent: SingleRoomAgent):
|
|
|
24
22
|
signal.signal(signal.SIGABRT, clean_termination)
|
|
25
23
|
|
|
26
24
|
await asyncio.wait(
|
|
27
|
-
[asyncio.
|
|
25
|
+
[asyncio.ensure_future(room.protocol.wait_for_close()), term],
|
|
28
26
|
return_when=asyncio.FIRST_COMPLETED,
|
|
29
27
|
)
|
|
30
28
|
|
|
@@ -74,7 +74,7 @@ class RemoteTaskRunnerServer[T: TaskRunner](WebhookServer):
|
|
|
74
74
|
await agent.start(room=room)
|
|
75
75
|
|
|
76
76
|
done, pending = await asyncio.wait(
|
|
77
|
-
[dismissed, asyncio.
|
|
77
|
+
[dismissed, asyncio.ensure_future(room.protocol.wait_for_close())],
|
|
78
78
|
return_when=asyncio.FIRST_COMPLETED,
|
|
79
79
|
)
|
|
80
80
|
|
|
@@ -158,7 +158,7 @@ class RemoteAgentServer[T: SingleRoomAgent](WebhookServer):
|
|
|
158
158
|
await agent.start(room=room)
|
|
159
159
|
|
|
160
160
|
done, pending = await asyncio.wait(
|
|
161
|
-
[dismissed, asyncio.
|
|
161
|
+
[dismissed, asyncio.ensure_future(room.protocol.wait_for_close())],
|
|
162
162
|
return_when=asyncio.FIRST_COMPLETED,
|
|
163
163
|
)
|
|
164
164
|
|
|
@@ -284,7 +284,10 @@ class MailWorker(Worker):
|
|
|
284
284
|
|
|
285
285
|
async def process_message(self, *, chat_context, room, message, toolkits):
|
|
286
286
|
thread_context = MailThreadContext(chat=chat_context, room_address=message)
|
|
287
|
-
toolkits =
|
|
287
|
+
toolkits = [
|
|
288
|
+
*toolkits,
|
|
289
|
+
*await self.get_thread_toolkits(thread_context=thread_context),
|
|
290
|
+
]
|
|
288
291
|
|
|
289
292
|
logger.info(f"processing message {message}")
|
|
290
293
|
reply = await super().process_message(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from meshagent.api import RoomClient, Requirement, RoomException, Participant
|
|
2
|
+
from meshagent.tools import validate_openai_schema
|
|
2
3
|
import json
|
|
3
4
|
from typing import Optional
|
|
4
5
|
import asyncio
|
|
@@ -34,6 +35,7 @@ async def generate_json(
|
|
|
34
35
|
if prompt is None:
|
|
35
36
|
prompt = f"ask me a series of questions to completely fill out the data structure described by this JSON schema ${json.dumps(output_schema)}. If you need to ask multiple questions, try to include all of them in a single form."
|
|
36
37
|
|
|
38
|
+
validate_openai_schema(output_schema)
|
|
37
39
|
return await room.agents.ask(
|
|
38
40
|
on_behalf_of=on_behalf_of,
|
|
39
41
|
agent="meshagent.schema_planner",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.13"
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-agents
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.13
|
|
4
4
|
Summary: Agent Building Blocks for Meshagent
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Project-URL: Documentation, https://docs.meshagent.com
|
|
7
7
|
Project-URL: Website, https://www.meshagent.com
|
|
8
8
|
Project-URL: Source, https://www.meshagent.com
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
Requires-Dist: pyjwt~=2.10
|
|
13
13
|
Requires-Dist: pytest~=8.4
|
|
14
14
|
Requires-Dist: pytest-asyncio~=0.26
|
|
15
|
-
Requires-Dist: meshagent-api~=0.5.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.5.
|
|
17
|
-
Requires-Dist: meshagent-openai~=0.5.
|
|
15
|
+
Requires-Dist: meshagent-api~=0.5.13
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.5.13
|
|
17
|
+
Requires-Dist: meshagent-openai~=0.5.13
|
|
18
18
|
Requires-Dist: pydantic~=2.11
|
|
19
19
|
Requires-Dist: opentelemetry-distro~=0.54b1
|
|
20
20
|
Provides-Extra: all
|
|
21
|
-
Requires-Dist: meshagent-api[all]~=0.5.
|
|
21
|
+
Requires-Dist: meshagent-api[all]~=0.5.13; extra == "all"
|
|
22
22
|
Requires-Dist: chonkie~=0.5.1; extra == "all"
|
|
23
23
|
Requires-Dist: chonkie[semantic]~=0.5.1; extra == "all"
|
|
24
24
|
Requires-Dist: chonkie[openai]~=0.5.1; extra == "all"
|
|
25
25
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "all"
|
|
26
26
|
Provides-Extra: sync
|
|
27
|
-
Requires-Dist: meshagent-api[sync]~=0.5.
|
|
27
|
+
Requires-Dist: meshagent-api[sync]~=0.5.13; extra == "sync"
|
|
28
28
|
Provides-Extra: mail
|
|
29
29
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
|
|
30
30
|
Provides-Extra: rag
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
pyjwt~=2.10
|
|
2
2
|
pytest~=8.4
|
|
3
3
|
pytest-asyncio~=0.26
|
|
4
|
-
meshagent-api~=0.5.
|
|
5
|
-
meshagent-tools~=0.5.
|
|
6
|
-
meshagent-openai~=0.5.
|
|
4
|
+
meshagent-api~=0.5.13
|
|
5
|
+
meshagent-tools~=0.5.13
|
|
6
|
+
meshagent-openai~=0.5.13
|
|
7
7
|
pydantic~=2.11
|
|
8
8
|
opentelemetry-distro~=0.54b1
|
|
9
9
|
|
|
10
10
|
[all]
|
|
11
|
-
meshagent-api[all]~=0.5.
|
|
11
|
+
meshagent-api[all]~=0.5.13
|
|
12
12
|
chonkie~=0.5.1
|
|
13
13
|
chonkie[semantic]~=0.5.1
|
|
14
14
|
chonkie[openai]~=0.5.1
|
|
@@ -23,4 +23,4 @@ chonkie[semantic]~=0.5.1
|
|
|
23
23
|
chonkie[openai]~=0.5.1
|
|
24
24
|
|
|
25
25
|
[sync]
|
|
26
|
-
meshagent-api[sync]~=0.5.
|
|
26
|
+
meshagent-api[sync]~=0.5.13
|
|
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
|
|
|
9
9
|
name = "meshagent-agents"
|
|
10
10
|
dynamic = ["version", "readme"]
|
|
11
11
|
description = "Agent Building Blocks for Meshagent"
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.12"
|
|
13
13
|
license = "Apache-2.0"
|
|
14
14
|
classifiers = []
|
|
15
15
|
keywords = []
|
|
@@ -17,16 +17,16 @@ dependencies = [
|
|
|
17
17
|
"pyjwt~=2.10",
|
|
18
18
|
"pytest~=8.4",
|
|
19
19
|
"pytest-asyncio~=0.26",
|
|
20
|
-
"meshagent-api~=0.5.
|
|
21
|
-
"meshagent-tools~=0.5.
|
|
22
|
-
"meshagent-openai~=0.5.
|
|
20
|
+
"meshagent-api~=0.5.13",
|
|
21
|
+
"meshagent-tools~=0.5.13",
|
|
22
|
+
"meshagent-openai~=0.5.13",
|
|
23
23
|
"pydantic~=2.11",
|
|
24
24
|
"opentelemetry-distro~=0.54b1"
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
all = [
|
|
29
|
-
"meshagent-api[all]~=0.5.
|
|
29
|
+
"meshagent-api[all]~=0.5.13",
|
|
30
30
|
"chonkie~=0.5.1",
|
|
31
31
|
"chonkie[semantic]~=0.5.1",
|
|
32
32
|
"chonkie[openai]~=0.5.1",
|
|
@@ -34,7 +34,7 @@ all = [
|
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
sync = [
|
|
37
|
-
"meshagent-api[sync]~=0.5.
|
|
37
|
+
"meshagent-api[sync]~=0.5.13",
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
mail = [
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
|
-
from jsonschema import validate, ValidationError
|
|
4
|
-
from meshagent.api.schema_util import prompt_schema, merge
|
|
5
|
-
from meshagent.api import Requirement
|
|
6
|
-
from meshagent.tools import Toolkit
|
|
7
|
-
from meshagent.agents import TaskRunner
|
|
8
|
-
from meshagent.agents.agent import AgentCallContext
|
|
9
|
-
from meshagent.agents.adapter import LLMAdapter, ToolResponseAdapter
|
|
10
|
-
from meshagent.api.messaging import TextResponse
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class LLMTaskRunner(TaskRunner):
|
|
14
|
-
"""
|
|
15
|
-
A Task Runner that uses an LLM execution loop until the task is complete.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(
|
|
19
|
-
self,
|
|
20
|
-
*,
|
|
21
|
-
name: str,
|
|
22
|
-
llm_adapter: LLMAdapter,
|
|
23
|
-
title: Optional[str] = None,
|
|
24
|
-
description: Optional[str] = None,
|
|
25
|
-
tool_adapter: Optional[ToolResponseAdapter] = None,
|
|
26
|
-
toolkits: Optional[list[Toolkit]] = None,
|
|
27
|
-
requires: Optional[list[Requirement]] = None,
|
|
28
|
-
supports_tools: bool = True,
|
|
29
|
-
input_prompt: bool = True,
|
|
30
|
-
input_schema: Optional[dict] = None,
|
|
31
|
-
output_schema: Optional[dict] = None,
|
|
32
|
-
rules: Optional[list[str]] = None,
|
|
33
|
-
labels: Optional[list[str]] = None,
|
|
34
|
-
):
|
|
35
|
-
if input_schema is None:
|
|
36
|
-
if input_prompt:
|
|
37
|
-
input_schema = prompt_schema(
|
|
38
|
-
description="use a prompt to generate content"
|
|
39
|
-
)
|
|
40
|
-
else:
|
|
41
|
-
input_schema = {
|
|
42
|
-
"type": "object",
|
|
43
|
-
"additionalProperties": False,
|
|
44
|
-
"required": [],
|
|
45
|
-
"properties": {},
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
static_toolkits = list(toolkits or [])
|
|
49
|
-
|
|
50
|
-
super().__init__(
|
|
51
|
-
name=name,
|
|
52
|
-
title=title,
|
|
53
|
-
description=description,
|
|
54
|
-
input_schema=input_schema,
|
|
55
|
-
output_schema=output_schema,
|
|
56
|
-
requires=requires,
|
|
57
|
-
supports_tools=supports_tools,
|
|
58
|
-
labels=labels,
|
|
59
|
-
toolkits=static_toolkits,
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
self._extra_rules = rules or []
|
|
63
|
-
self._llm_adapter = llm_adapter
|
|
64
|
-
self._tool_adapter = tool_adapter
|
|
65
|
-
self.toolkits = static_toolkits
|
|
66
|
-
|
|
67
|
-
async def init_chat_context(self):
|
|
68
|
-
chat = self._llm_adapter.create_chat_context()
|
|
69
|
-
if self._extra_rules:
|
|
70
|
-
chat.append_rules(self._extra_rules)
|
|
71
|
-
return chat
|
|
72
|
-
|
|
73
|
-
async def ask(self, *, context: AgentCallContext, arguments: dict):
|
|
74
|
-
prompt = arguments.get("prompt")
|
|
75
|
-
if prompt is None:
|
|
76
|
-
raise ValueError("`prompt` is required")
|
|
77
|
-
|
|
78
|
-
context.chat.append_user_message(prompt)
|
|
79
|
-
|
|
80
|
-
combined_toolkits: list[Toolkit] = [*self.toolkits, *context.toolkits]
|
|
81
|
-
|
|
82
|
-
resp = await self._llm_adapter.next(
|
|
83
|
-
context=context.chat,
|
|
84
|
-
room=context.room,
|
|
85
|
-
toolkits=combined_toolkits,
|
|
86
|
-
tool_adapter=self._tool_adapter,
|
|
87
|
-
output_schema=self.output_schema,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
# Validate the LLM output against the declared output schema if one was provided
|
|
91
|
-
if self.output_schema:
|
|
92
|
-
try:
|
|
93
|
-
validate(instance=resp, schema=self.output_schema)
|
|
94
|
-
except ValidationError as exc:
|
|
95
|
-
raise RuntimeError("LLM output failed schema validation") from exc
|
|
96
|
-
# If no output schema was provided return a TextResponse
|
|
97
|
-
else:
|
|
98
|
-
resp = TextResponse(text=resp)
|
|
99
|
-
|
|
100
|
-
return resp
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class DynamicLLMTaskRunner(LLMTaskRunner):
|
|
104
|
-
"""
|
|
105
|
-
Same capabilities as LLMTaskRunner, but the caller supplies an arbitrary JSON-schema (`output_schema`) at runtime
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
def __init__(
|
|
109
|
-
self,
|
|
110
|
-
*,
|
|
111
|
-
name: str,
|
|
112
|
-
llm_adapter: LLMAdapter,
|
|
113
|
-
supports_tools: bool = True,
|
|
114
|
-
title: Optional[str] = None,
|
|
115
|
-
description: Optional[str] = None,
|
|
116
|
-
tool_adapter: Optional[ToolResponseAdapter] = None,
|
|
117
|
-
toolkits: Optional[list[Toolkit]] = None,
|
|
118
|
-
rules: Optional[list[str]] = None,
|
|
119
|
-
):
|
|
120
|
-
input_schema = merge(
|
|
121
|
-
schema=prompt_schema(description="use a prompt to generate content"),
|
|
122
|
-
additional_properties={"output_schema": {"type": "object"}},
|
|
123
|
-
)
|
|
124
|
-
super().__init__(
|
|
125
|
-
name=name,
|
|
126
|
-
llm_adapter=llm_adapter,
|
|
127
|
-
supports_tools=supports_tools,
|
|
128
|
-
title=title,
|
|
129
|
-
description=description,
|
|
130
|
-
tool_adapter=tool_adapter,
|
|
131
|
-
toolkits=toolkits,
|
|
132
|
-
rules=rules,
|
|
133
|
-
input_prompt=True,
|
|
134
|
-
input_schema=input_schema,
|
|
135
|
-
output_schema=None,
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
async def ask(self, *, context: AgentCallContext, arguments: dict):
|
|
139
|
-
prompt = arguments.get("prompt")
|
|
140
|
-
if prompt is None:
|
|
141
|
-
raise ValueError("`prompt` is required")
|
|
142
|
-
|
|
143
|
-
# Parse and pass JSON output schema provided at runtime
|
|
144
|
-
output_schema_raw = arguments.get("output_schema")
|
|
145
|
-
if output_schema_raw is None:
|
|
146
|
-
raise ValueError("`output_schema` is required for DynamicLLMTaskRunner")
|
|
147
|
-
|
|
148
|
-
# Make sure provided schema is a dict
|
|
149
|
-
if not isinstance(output_schema_raw, dict):
|
|
150
|
-
raise TypeError("`output_schema` must be a dict (JSON-schema object)")
|
|
151
|
-
|
|
152
|
-
context.chat.append_user_message(prompt)
|
|
153
|
-
|
|
154
|
-
combined_toolkits: list[Toolkit] = [*self.toolkits, *context.toolkits]
|
|
155
|
-
|
|
156
|
-
resp = await self._llm_adapter.next(
|
|
157
|
-
context=context.chat,
|
|
158
|
-
room=context.room,
|
|
159
|
-
toolkits=combined_toolkits,
|
|
160
|
-
tool_adapter=self._tool_adapter,
|
|
161
|
-
output_schema=output_schema_raw,
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
try:
|
|
165
|
-
validate(instance=resp, schema=output_schema_raw)
|
|
166
|
-
except ValidationError as exc:
|
|
167
|
-
raise RuntimeError("LLM output failed caller schema validation") from exc
|
|
168
|
-
|
|
169
|
-
return resp
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.8b5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent/agents/schemas/presentation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{meshagent_agents-0.5.8b5 → meshagent_agents-0.5.13}/meshagent_agents.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|