meshagent-agents 0.5.18__py3-none-any.whl → 0.6.0__py3-none-any.whl
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/__init__.py +0 -2
- meshagent/agents/adapter.py +22 -5
- meshagent/agents/agent.py +28 -29
- meshagent/agents/chat.py +519 -175
- meshagent/agents/context.py +16 -1
- meshagent/agents/development.py +3 -1
- meshagent/agents/indexer.py +2 -2
- meshagent/agents/llmrunner.py +169 -0
- meshagent/agents/mail.py +15 -17
- meshagent/agents/planning.py +3 -3
- meshagent/agents/pydantic.py +1 -1
- meshagent/agents/schemas/transcript.py +77 -0
- meshagent/agents/thread_schema.py +58 -7
- meshagent/agents/utils.py +0 -2
- meshagent/agents/version.py +1 -1
- meshagent/agents/worker.py +8 -4
- meshagent/agents/writer.py +1 -1
- {meshagent_agents-0.5.18.dist-info → meshagent_agents-0.6.0.dist-info}/METADATA +8 -8
- meshagent_agents-0.6.0.dist-info/RECORD +31 -0
- meshagent/agents/hosting.py +0 -182
- meshagent_agents-0.5.18.dist-info/RECORD +0 -30
- {meshagent_agents-0.5.18.dist-info → meshagent_agents-0.6.0.dist-info}/WHEEL +0 -0
- {meshagent_agents-0.5.18.dist-info → meshagent_agents-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {meshagent_agents-0.5.18.dist-info → meshagent_agents-0.6.0.dist-info}/top_level.txt +0 -0
meshagent/agents/context.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
from meshagent.api import RoomClient
|
|
4
|
-
from meshagent.tools
|
|
4
|
+
from meshagent.tools import Toolkit
|
|
5
5
|
from meshagent.api.participant import Participant
|
|
6
6
|
|
|
7
7
|
import uuid
|
|
@@ -51,6 +51,21 @@ class AgentChatContext:
|
|
|
51
51
|
self._previous_messages.extend(self.messages)
|
|
52
52
|
self.messages.clear()
|
|
53
53
|
|
|
54
|
+
def replace_rules(self, rules: list[str]):
|
|
55
|
+
system_message = None
|
|
56
|
+
|
|
57
|
+
for m in self.messages:
|
|
58
|
+
if m["role"] == self.system_role:
|
|
59
|
+
system_message = m
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
if system_message is None:
|
|
63
|
+
system_message = {"role": self.system_role, "content": ""}
|
|
64
|
+
self.messages.insert(0, system_message)
|
|
65
|
+
|
|
66
|
+
plan = f"Rules:\n-{'\n-'.join(rules)}\n"
|
|
67
|
+
system_message["content"] = plan
|
|
68
|
+
|
|
54
69
|
def append_rules(self, rules: list[str]):
|
|
55
70
|
system_message = None
|
|
56
71
|
|
meshagent/agents/development.py
CHANGED
|
@@ -2,8 +2,10 @@ 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
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
@deprecated("use ServiceHost and the cli to connect agents to the room")
|
|
7
9
|
async def connect_development_agent(*, room_name: str, agent: SingleRoomAgent):
|
|
8
10
|
async with RoomClient(
|
|
9
11
|
protocol=websocket_protocol(
|
|
@@ -22,7 +24,7 @@ async def connect_development_agent(*, room_name: str, agent: SingleRoomAgent):
|
|
|
22
24
|
signal.signal(signal.SIGABRT, clean_termination)
|
|
23
25
|
|
|
24
26
|
await asyncio.wait(
|
|
25
|
-
[asyncio.
|
|
27
|
+
[asyncio.create_task(room.protocol.wait_for_close()), term],
|
|
26
28
|
return_when=asyncio.FIRST_COMPLETED,
|
|
27
29
|
)
|
|
28
30
|
|
meshagent/agents/indexer.py
CHANGED
|
@@ -245,10 +245,10 @@ class StorageIndexer(SingleRoomAgent):
|
|
|
245
245
|
logger.info(f"existing indexes {indexes}")
|
|
246
246
|
|
|
247
247
|
for index in indexes:
|
|
248
|
-
if "embedding" in index
|
|
248
|
+
if "embedding" in index.columns:
|
|
249
249
|
self._vector_index_created = True
|
|
250
250
|
|
|
251
|
-
if "text" in index
|
|
251
|
+
if "text" in index.columns:
|
|
252
252
|
self._fts_created = True
|
|
253
253
|
|
|
254
254
|
if not self._vector_index_created:
|
|
@@ -0,0 +1,169 @@
|
|
|
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
|
meshagent/agents/mail.py
CHANGED
|
@@ -5,11 +5,10 @@ from email.message import EmailMessage
|
|
|
5
5
|
from email.policy import default
|
|
6
6
|
from meshagent.tools import ToolContext, Toolkit
|
|
7
7
|
import email.utils
|
|
8
|
-
from meshagent.api import ParticipantToken
|
|
9
8
|
from meshagent.api import RoomClient
|
|
10
9
|
from meshagent.agents import AgentChatContext
|
|
11
10
|
from datetime import datetime, timezone
|
|
12
|
-
|
|
11
|
+
import base64
|
|
13
12
|
import secrets
|
|
14
13
|
|
|
15
14
|
from typing import Literal, Optional
|
|
@@ -27,9 +26,9 @@ type MessageRole = Literal["user", "agent"]
|
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
class MailThreadContext:
|
|
30
|
-
def __init__(self, *, chat: AgentChatContext,
|
|
29
|
+
def __init__(self, *, chat: AgentChatContext, message: dict):
|
|
31
30
|
self.chat = chat
|
|
32
|
-
self.
|
|
31
|
+
self.message = message
|
|
33
32
|
|
|
34
33
|
|
|
35
34
|
def create_reply_email_message(
|
|
@@ -237,6 +236,7 @@ class MailWorker(Worker):
|
|
|
237
236
|
tool_adapter=None,
|
|
238
237
|
toolkits=None,
|
|
239
238
|
rules=None,
|
|
239
|
+
email_address: str,
|
|
240
240
|
domain: str = os.getenv("MESHAGENT_MAIL_DOMAIN", "mail.meshagent.com"),
|
|
241
241
|
smtp: Optional[SmtpConfiguration] = None,
|
|
242
242
|
):
|
|
@@ -256,14 +256,7 @@ class MailWorker(Worker):
|
|
|
256
256
|
toolkits=toolkits,
|
|
257
257
|
rules=rules,
|
|
258
258
|
)
|
|
259
|
-
|
|
260
|
-
async def start(self, *, room):
|
|
261
|
-
await super().start(room=room)
|
|
262
|
-
|
|
263
|
-
token = ParticipantToken.from_jwt(room.protocol.token, validate=False)
|
|
264
|
-
self._email_address = room_address(
|
|
265
|
-
project_id=token.project_id, room_name=room.room_name, domain=self._domain
|
|
266
|
-
)
|
|
259
|
+
self._email_address = email_address
|
|
267
260
|
|
|
268
261
|
async def append_message_context(self, *, room, message, chat_context):
|
|
269
262
|
thread = [message]
|
|
@@ -283,12 +276,17 @@ class MailWorker(Worker):
|
|
|
283
276
|
)
|
|
284
277
|
|
|
285
278
|
async def process_message(self, *, chat_context, room, message, toolkits):
|
|
286
|
-
|
|
287
|
-
toolkits = [
|
|
288
|
-
*toolkits,
|
|
289
|
-
*await self.get_thread_toolkits(thread_context=thread_context),
|
|
290
|
-
]
|
|
279
|
+
message_bytes = base64.b64decode(message["base64"])
|
|
291
280
|
|
|
281
|
+
message = await save_email_message(
|
|
282
|
+
room=room, content=message_bytes, role="agent"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
thread_context = MailThreadContext(chat=chat_context, message=message)
|
|
286
|
+
toolkits = await self.get_thread_toolkits(thread_context=thread_context)
|
|
287
|
+
await self.append_message_context(
|
|
288
|
+
room=room, message=message, chat_context=chat_context
|
|
289
|
+
)
|
|
292
290
|
logger.info(f"processing message {message}")
|
|
293
291
|
reply = await super().process_message(
|
|
294
292
|
chat_context=thread_context.chat,
|
meshagent/agents/planning.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from meshagent.agents.agent import AgentCallContext, AgentException
|
|
2
2
|
from meshagent.api import Requirement
|
|
3
3
|
from meshagent.api.messaging import TextResponse
|
|
4
|
-
from meshagent.tools
|
|
4
|
+
from meshagent.tools import Toolkit, Tool, ToolContext
|
|
5
5
|
from meshagent.api.schema import MeshSchema
|
|
6
6
|
from meshagent.agents.writer import Writer, WriterContext
|
|
7
7
|
from meshagent.agents.adapter import LLMAdapter, ToolResponseAdapter
|
|
@@ -247,7 +247,7 @@ class PlanningWriter(Writer):
|
|
|
247
247
|
i += 1
|
|
248
248
|
|
|
249
249
|
try:
|
|
250
|
-
logger.info("
|
|
250
|
+
logger.info("Working on step %s", i)
|
|
251
251
|
|
|
252
252
|
base_args = arguments.copy()
|
|
253
253
|
base_args.pop("path")
|
|
@@ -598,7 +598,7 @@ class DynamicPlanningResponder(TaskRunner):
|
|
|
598
598
|
i += 1
|
|
599
599
|
|
|
600
600
|
try:
|
|
601
|
-
logger.info("
|
|
601
|
+
logger.info("Working on step %s", i)
|
|
602
602
|
|
|
603
603
|
toolkits = [*self.toolkits, *context.toolkits]
|
|
604
604
|
|
meshagent/agents/pydantic.py
CHANGED
|
@@ -11,7 +11,7 @@ from meshagent.api import RoomClient
|
|
|
11
11
|
from .agent import TaskRunner, Requirement
|
|
12
12
|
|
|
13
13
|
from .adapter import ToolResponseAdapter
|
|
14
|
-
from meshagent.tools
|
|
14
|
+
from meshagent.tools import Tool, ToolContext
|
|
15
15
|
from meshagent.tools.pydantic import get_pydantic_ai_tool_definition
|
|
16
16
|
|
|
17
17
|
from typing import Sequence
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# transcript_schema.py
|
|
2
|
+
"""Schema definition for transcription documents produced by the Transcriber agent.
|
|
3
|
+
|
|
4
|
+
The schema captures high-level session metadata alongside a chronological list
|
|
5
|
+
of speech segments. Downstream tools can rely on the ordered <segments>
|
|
6
|
+
container to iterate through transcription results in the sequence they were
|
|
7
|
+
observed.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from meshagent.api.schema import (
|
|
11
|
+
MeshSchema,
|
|
12
|
+
ElementType,
|
|
13
|
+
ChildProperty,
|
|
14
|
+
ValueProperty,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
transcript_schema = MeshSchema(
|
|
18
|
+
root_tag_name="transcript",
|
|
19
|
+
elements=[
|
|
20
|
+
ElementType(
|
|
21
|
+
tag_name="transcript",
|
|
22
|
+
description=(
|
|
23
|
+
"Root element describing a transcription session generated by "
|
|
24
|
+
"the Transcriber agent."
|
|
25
|
+
),
|
|
26
|
+
properties=[
|
|
27
|
+
ValueProperty(
|
|
28
|
+
name="session_id",
|
|
29
|
+
description="Identifier for the transcription session or LiveKit room.",
|
|
30
|
+
type="string",
|
|
31
|
+
),
|
|
32
|
+
ValueProperty(
|
|
33
|
+
name="room_id",
|
|
34
|
+
description="MeshAgent room identifier backing this transcript.",
|
|
35
|
+
type="string",
|
|
36
|
+
),
|
|
37
|
+
ValueProperty(
|
|
38
|
+
name="created_at",
|
|
39
|
+
description="ISO-8601 timestamp indicating when the session began.",
|
|
40
|
+
type="string",
|
|
41
|
+
),
|
|
42
|
+
ChildProperty(
|
|
43
|
+
name="segments",
|
|
44
|
+
description="Ordered collection of speech segments captured during the session.",
|
|
45
|
+
child_tag_names=["segment"],
|
|
46
|
+
ordered=True,
|
|
47
|
+
),
|
|
48
|
+
],
|
|
49
|
+
),
|
|
50
|
+
ElementType(
|
|
51
|
+
tag_name="segment",
|
|
52
|
+
description="A contiguous span of speech transcribed from a participant.",
|
|
53
|
+
properties=[
|
|
54
|
+
ValueProperty(
|
|
55
|
+
name="participant_id",
|
|
56
|
+
description="MeshAgent participant identifier associated with the audio segment.",
|
|
57
|
+
type="string",
|
|
58
|
+
),
|
|
59
|
+
ValueProperty(
|
|
60
|
+
name="participant_name",
|
|
61
|
+
description="Human-friendly participant name when available.",
|
|
62
|
+
type="string",
|
|
63
|
+
),
|
|
64
|
+
ValueProperty(
|
|
65
|
+
name="time",
|
|
66
|
+
description="Segment start time as an ISO-8601 UTC timestamp.",
|
|
67
|
+
type="string",
|
|
68
|
+
),
|
|
69
|
+
ValueProperty(
|
|
70
|
+
name="text",
|
|
71
|
+
description="Transcript text emitted by the speech-to-text engine.",
|
|
72
|
+
type="string",
|
|
73
|
+
),
|
|
74
|
+
],
|
|
75
|
+
),
|
|
76
|
+
],
|
|
77
|
+
)
|
|
@@ -35,7 +35,7 @@ thread_schema = MeshSchema(
|
|
|
35
35
|
properties=[
|
|
36
36
|
ChildProperty(
|
|
37
37
|
name="items",
|
|
38
|
-
child_tag_names=["message", "exec"],
|
|
38
|
+
child_tag_names=["message", "exec", "ui", "reasoning"],
|
|
39
39
|
description="the messages in this thread",
|
|
40
40
|
)
|
|
41
41
|
],
|
|
@@ -47,12 +47,6 @@ thread_schema = MeshSchema(
|
|
|
47
47
|
ValueProperty(
|
|
48
48
|
name="name", description="the name of the member", type="string"
|
|
49
49
|
),
|
|
50
|
-
ValueProperty(
|
|
51
|
-
name="type",
|
|
52
|
-
description="the type of member",
|
|
53
|
-
type="string",
|
|
54
|
-
enum=["user", "agent"],
|
|
55
|
-
),
|
|
56
50
|
],
|
|
57
51
|
),
|
|
58
52
|
ElementType(
|
|
@@ -66,6 +60,22 @@ thread_schema = MeshSchema(
|
|
|
66
60
|
),
|
|
67
61
|
],
|
|
68
62
|
),
|
|
63
|
+
ElementType(
|
|
64
|
+
tag_name="reasoning",
|
|
65
|
+
description="a reasoning trace",
|
|
66
|
+
properties=[
|
|
67
|
+
ValueProperty(
|
|
68
|
+
name="summary",
|
|
69
|
+
description="a summary of the reasoning",
|
|
70
|
+
type="string",
|
|
71
|
+
),
|
|
72
|
+
ValueProperty(
|
|
73
|
+
name="created_at",
|
|
74
|
+
description="the time that the reasoning started",
|
|
75
|
+
type="string",
|
|
76
|
+
),
|
|
77
|
+
],
|
|
78
|
+
),
|
|
69
79
|
ElementType(
|
|
70
80
|
tag_name="exec",
|
|
71
81
|
description="a command execution",
|
|
@@ -85,6 +95,47 @@ thread_schema = MeshSchema(
|
|
|
85
95
|
description="the working directory the command was executed in",
|
|
86
96
|
type="string",
|
|
87
97
|
),
|
|
98
|
+
ValueProperty(
|
|
99
|
+
name="created_at",
|
|
100
|
+
description="the time that the reasoning started",
|
|
101
|
+
type="string",
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
),
|
|
105
|
+
ElementType(
|
|
106
|
+
tag_name="ui",
|
|
107
|
+
description="custom user interface data",
|
|
108
|
+
properties=[
|
|
109
|
+
ValueProperty(
|
|
110
|
+
name="data",
|
|
111
|
+
description="raw data to be renderered, usually in JSON format",
|
|
112
|
+
type="string",
|
|
113
|
+
),
|
|
114
|
+
ValueProperty(
|
|
115
|
+
name="renderer",
|
|
116
|
+
description="the renderer to use",
|
|
117
|
+
type="string",
|
|
118
|
+
),
|
|
119
|
+
ValueProperty(
|
|
120
|
+
name="widget",
|
|
121
|
+
description="the type of widget",
|
|
122
|
+
type="string",
|
|
123
|
+
),
|
|
124
|
+
ValueProperty(
|
|
125
|
+
name="width",
|
|
126
|
+
description="the width of widget",
|
|
127
|
+
type="number",
|
|
128
|
+
),
|
|
129
|
+
ValueProperty(
|
|
130
|
+
name="height",
|
|
131
|
+
description="the height of widget",
|
|
132
|
+
type="number",
|
|
133
|
+
),
|
|
134
|
+
ValueProperty(
|
|
135
|
+
name="created_at",
|
|
136
|
+
description="the time that the reasoning started",
|
|
137
|
+
type="string",
|
|
138
|
+
),
|
|
88
139
|
],
|
|
89
140
|
),
|
|
90
141
|
ElementType(
|
meshagent/agents/utils.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from meshagent.api import RoomClient, Requirement, RoomException, Participant
|
|
2
|
-
from meshagent.tools import validate_openai_schema
|
|
3
2
|
import json
|
|
4
3
|
from typing import Optional
|
|
5
4
|
import asyncio
|
|
@@ -35,7 +34,6 @@ async def generate_json(
|
|
|
35
34
|
if prompt is None:
|
|
36
35
|
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."
|
|
37
36
|
|
|
38
|
-
validate_openai_schema(output_schema)
|
|
39
37
|
return await room.agents.ask(
|
|
40
38
|
on_behalf_of=on_behalf_of,
|
|
41
39
|
agent="meshagent.schema_planner",
|
meshagent/agents/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.6.0"
|
meshagent/agents/worker.py
CHANGED
|
@@ -72,6 +72,9 @@ class Worker(SingleRoomAgent):
|
|
|
72
72
|
):
|
|
73
73
|
chat_context.append_user_message(message=json.dumps(message))
|
|
74
74
|
|
|
75
|
+
def decode_message(self, message: dict):
|
|
76
|
+
return message
|
|
77
|
+
|
|
75
78
|
async def process_message(
|
|
76
79
|
self,
|
|
77
80
|
*,
|
|
@@ -80,6 +83,10 @@ class Worker(SingleRoomAgent):
|
|
|
80
83
|
message: dict,
|
|
81
84
|
toolkits: list[Toolkit],
|
|
82
85
|
):
|
|
86
|
+
await self.append_message_context(
|
|
87
|
+
room=room, message=message, chat_context=chat_context
|
|
88
|
+
)
|
|
89
|
+
|
|
83
90
|
return await self._llm_adapter.next(
|
|
84
91
|
context=chat_context,
|
|
85
92
|
room=room,
|
|
@@ -101,6 +108,7 @@ class Worker(SingleRoomAgent):
|
|
|
101
108
|
message = await room.queues.receive(
|
|
102
109
|
name=self._queue, create=True, wait=True
|
|
103
110
|
)
|
|
111
|
+
|
|
104
112
|
backoff = 0
|
|
105
113
|
if message is not None:
|
|
106
114
|
logger.info(f"received message on worker queue {message}")
|
|
@@ -113,10 +121,6 @@ class Worker(SingleRoomAgent):
|
|
|
113
121
|
]
|
|
114
122
|
)
|
|
115
123
|
|
|
116
|
-
await self.append_message_context(
|
|
117
|
-
room=room, message=message, chat_context=chat_context
|
|
118
|
-
)
|
|
119
|
-
|
|
120
124
|
await self.process_message(
|
|
121
125
|
chat_context=chat_context,
|
|
122
126
|
room=room,
|
meshagent/agents/writer.py
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meshagent-agents
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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.13
|
|
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.
|
|
16
|
-
Requires-Dist: meshagent-tools~=0.
|
|
17
|
-
Requires-Dist: meshagent-openai~=0.
|
|
15
|
+
Requires-Dist: meshagent-api~=0.6.0
|
|
16
|
+
Requires-Dist: meshagent-tools~=0.6.0
|
|
17
|
+
Requires-Dist: meshagent-openai~=0.6.0
|
|
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.
|
|
21
|
+
Requires-Dist: meshagent-api[all]~=0.6.0; 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.
|
|
27
|
+
Requires-Dist: meshagent-api[sync]~=0.6.0; extra == "sync"
|
|
28
28
|
Provides-Extra: mail
|
|
29
29
|
Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
|
|
30
30
|
Provides-Extra: rag
|
|
@@ -54,7 +54,7 @@ The ``TaskRunner`` agent is useful when you want to invoke an agent with a well-
|
|
|
54
54
|
The ``Worker`` is a queue-based ``SingleRoomAgent`` that processes queued messages with an LLM and optional tools. This is particularly helpful for running asynchronous jobs. With the ``Worker`` agent you can create a set of tasks that need to run in a Room and the ``Worker`` will execute all of the tasks in the queue.
|
|
55
55
|
|
|
56
56
|
### ChatBot
|
|
57
|
-
The ``ChatBot`` is a conversational agent derived from the ``SingleRoomAgent``. It wires an LLMAdapter, optoinal tools, and manages chat threads for each user. This means multiple users can be in the same room interacting with a chat agent, but each user will have private messages with the agent. Check out the [Build
|
|
57
|
+
The ``ChatBot`` is a conversational agent derived from the ``SingleRoomAgent``. It wires an LLMAdapter, optoinal tools, and manages chat threads for each user. This means multiple users can be in the same room interacting with a chat agent, but each user will have private messages with the agent. Check out the [Build a Chat Agent](https://docs.meshagent.com/agents/standard/buildanddeploychatbot) example to learn how to create a simple Chat Agent without tools then add built-in MeshAgent tools and custom tools to the agent.
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
### Learn more about MeshAgent on our website or check out the docs for additional examples!
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
meshagent/agents/__init__.py,sha256=BcPxGW5__oLXEU2FQxWBAqSYUwXH99nIGaO2dTGyUxQ,634
|
|
2
|
+
meshagent/agents/adapter.py,sha256=enFUYMVaq3XZgqFIxOqeZxJp6YI0yLPQBd5VNQMhq8s,2097
|
|
3
|
+
meshagent/agents/agent.py,sha256=ibl2igR0WZofOnJp95WJghF7ktoQBZRViPhO5p4qbFg,20486
|
|
4
|
+
meshagent/agents/chat.py,sha256=SOkoJPOAQ4yVPc6ymPZNmXQOe1NvhQzSwI8mVHIqppo,43861
|
|
5
|
+
meshagent/agents/context.py,sha256=MNK3BwtVtFUnMeaUAPDt7tQLrHip39y7rqtOs3KFHv8,4491
|
|
6
|
+
meshagent/agents/development.py,sha256=uWKfwmPEE1Er4KgMtsEzdJEWE8H2c1S7l6q6a8OSDOw,997
|
|
7
|
+
meshagent/agents/indexer.py,sha256=8J_5f127J0jLKlQkPw955nHouqWlQUuRDm4bjyObZfE,19361
|
|
8
|
+
meshagent/agents/listener.py,sha256=q5z216FMVW-a7FBs706u3IuB81VArfucxEHaHvPFHEo,5139
|
|
9
|
+
meshagent/agents/llmrunner.py,sha256=ovHWsAsDqDCjmXLqXvx5B9Zwh9DaZMzvWU2dIL90syw,5739
|
|
10
|
+
meshagent/agents/mail.py,sha256=sck-j1sEdkV11k046fz3VkQyGAPdgxWIbcQmCamcAkk,12318
|
|
11
|
+
meshagent/agents/planning.py,sha256=npu29Z-lXgsJgMr7kXmlfz9gq5CcE0Q6RoZg4IBsfig,21952
|
|
12
|
+
meshagent/agents/prompt.py,sha256=OSSqbzaugyQtuvYxTY5UcZQWyeV73e3GUJz_iC5xZkA,1883
|
|
13
|
+
meshagent/agents/pydantic.py,sha256=Fnjx9fdKRHKeAKw1-Yqrm_emM3UVIpLBOj1tmeSJfwk,6270
|
|
14
|
+
meshagent/agents/single_shot_writer.py,sha256=miWVMo4NX8Hib0yHwDmiwuk8GraJwg1JzljsgFyTl4Y,3237
|
|
15
|
+
meshagent/agents/thread_schema.py,sha256=J5k3PLyrMKSxtmCTGoN3m81t_K_AiymtIqRGqHeOWjI,5987
|
|
16
|
+
meshagent/agents/utils.py,sha256=2Z3r7cUpKDZig8MVCrBwZRBUambeX4esZovDWme9uVE,1353
|
|
17
|
+
meshagent/agents/version.py,sha256=cID1jLnC_vj48GgMN6Yb1FA3JsQ95zNmCHmRYE8TFhY,22
|
|
18
|
+
meshagent/agents/worker.py,sha256=ACwV5Uq3_Dg0PrwahYQ8EiguW2sru2_Rvg0RwZB1DdE,3932
|
|
19
|
+
meshagent/agents/writer.py,sha256=DdM1YzZyHSh4Cl-OmzU0Hhqg7A8M1ES0hiNTYDu1BS4,2680
|
|
20
|
+
meshagent/agents/schemas/__init__.py,sha256=_xAhrkxvFdfer3NolrynragGxcLElGR51LSribT3deU,299
|
|
21
|
+
meshagent/agents/schemas/document.py,sha256=H-aolubkRHdTAH-rLI2SJ8y3JKwXvpNsR3ZCqghwAWI,1515
|
|
22
|
+
meshagent/agents/schemas/gallery.py,sha256=65IsrH2wiFIR-DNo8est-nCOC72i1Aa5EmVNUHtVnK0,1091
|
|
23
|
+
meshagent/agents/schemas/presentation.py,sha256=aaMzkFQryurbHd1fbzTQPdN7v8QIhsjXuvbE8ZiuXNY,1589
|
|
24
|
+
meshagent/agents/schemas/schema.py,sha256=8OXGCLVouoPg6eHBU9mgf1pTGTMvVZqiKNq15wkQJe0,5310
|
|
25
|
+
meshagent/agents/schemas/super_editor_document.py,sha256=iRv4Q-DE_5kUdsAD5Rm4GwHek8L_7ZEpxIZ1x2dWjdg,1813
|
|
26
|
+
meshagent/agents/schemas/transcript.py,sha256=kMc1vitL-eLdZxbx5pjZtjfRB8yNXQ_IcfZPfUUGXnA,2770
|
|
27
|
+
meshagent_agents-0.6.0.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
|
|
28
|
+
meshagent_agents-0.6.0.dist-info/METADATA,sha256=e9x0tHwOO9TbF5Gti95QudNs6wSeqUPgOX-s7Xp6JXk,3762
|
|
29
|
+
meshagent_agents-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
meshagent_agents-0.6.0.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
|
|
31
|
+
meshagent_agents-0.6.0.dist-info/RECORD,,
|