meshagent-agents 0.0.37__py3-none-any.whl → 0.0.38__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 +27 -2
- meshagent/agents/adapter.py +18 -9
- meshagent/agents/agent.py +317 -214
- meshagent/agents/chat.py +390 -267
- meshagent/agents/context.py +58 -30
- meshagent/agents/development.py +11 -13
- meshagent/agents/hosting.py +109 -46
- meshagent/agents/indexer.py +241 -224
- meshagent/agents/listener.py +55 -52
- meshagent/agents/mail.py +145 -109
- meshagent/agents/planning.py +294 -199
- meshagent/agents/prompt.py +14 -12
- meshagent/agents/pydantic.py +98 -61
- meshagent/agents/schemas/__init__.py +11 -0
- meshagent/agents/schemas/document.py +32 -21
- meshagent/agents/schemas/gallery.py +23 -14
- meshagent/agents/schemas/presentation.py +33 -17
- meshagent/agents/schemas/schema.py +99 -45
- meshagent/agents/schemas/super_editor_document.py +52 -46
- meshagent/agents/single_shot_writer.py +37 -31
- meshagent/agents/thread_schema.py +74 -32
- meshagent/agents/utils.py +20 -12
- meshagent/agents/version.py +1 -1
- meshagent/agents/worker.py +48 -28
- meshagent/agents/writer.py +36 -23
- meshagent_agents-0.0.38.dist-info/METADATA +64 -0
- meshagent_agents-0.0.38.dist-info/RECORD +30 -0
- meshagent_agents-0.0.37.dist-info/METADATA +0 -36
- meshagent_agents-0.0.37.dist-info/RECORD +0 -30
- {meshagent_agents-0.0.37.dist-info → meshagent_agents-0.0.38.dist-info}/WHEEL +0 -0
- {meshagent_agents-0.0.37.dist-info → meshagent_agents-0.0.38.dist-info}/licenses/LICENSE +0 -0
- {meshagent_agents-0.0.37.dist-info → meshagent_agents-0.0.38.dist-info}/top_level.txt +0 -0
|
@@ -1,74 +1,128 @@
|
|
|
1
|
-
from meshagent.api.schema import
|
|
1
|
+
from meshagent.api.schema import (
|
|
2
|
+
ElementProperty,
|
|
3
|
+
ValueProperty,
|
|
4
|
+
MeshSchema,
|
|
5
|
+
ChildProperty,
|
|
6
|
+
ElementType,
|
|
7
|
+
)
|
|
2
8
|
from meshagent.api.schema_document import Document
|
|
3
9
|
|
|
4
10
|
schema_schema = MeshSchema(
|
|
5
11
|
root_tag_name="schema",
|
|
6
12
|
elements=[
|
|
7
|
-
ElementType(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
ElementType(
|
|
14
|
+
tag_name="schema",
|
|
15
|
+
description="defines an xml document representing a json schema",
|
|
16
|
+
properties=[
|
|
17
|
+
ValueProperty(
|
|
18
|
+
name="root_tag_name",
|
|
19
|
+
description="the root tag name in this document (must match one of the elements defined in the schema)",
|
|
20
|
+
type="string",
|
|
21
|
+
),
|
|
22
|
+
ChildProperty(
|
|
23
|
+
name="elements",
|
|
24
|
+
description="the configuration of this sandbox",
|
|
25
|
+
child_tag_names=["element"],
|
|
26
|
+
),
|
|
27
|
+
],
|
|
28
|
+
),
|
|
29
|
+
ElementType(
|
|
30
|
+
tag_name="element",
|
|
31
|
+
description="an element inside the document",
|
|
32
|
+
properties=[
|
|
33
|
+
ValueProperty(
|
|
34
|
+
name="tag_name",
|
|
35
|
+
description="the tag name used by this element. Element names are case-sensitive. Element names cannot contain spaces. Element names must start with a letter or underscore. Element names cannot start with the letters xml (or XML, or Xml, etc) Element names can contain letters, digits, hyphens, underscores, and periods.",
|
|
36
|
+
type="string",
|
|
37
|
+
),
|
|
38
|
+
ChildProperty(
|
|
39
|
+
name="schema",
|
|
40
|
+
description="the attributes of this node",
|
|
41
|
+
child_tag_names=["attribute", "child_elements"],
|
|
42
|
+
),
|
|
43
|
+
ValueProperty(name="description", type="string"),
|
|
44
|
+
],
|
|
45
|
+
),
|
|
46
|
+
ElementType(
|
|
47
|
+
tag_name="attribute",
|
|
48
|
+
properties=[
|
|
49
|
+
ValueProperty(
|
|
50
|
+
name="name",
|
|
51
|
+
description="the attribute name. Attribute names are case-sensitive. Attribute names cannot contain spaces. Attribute names must start with a letter or underscore. Attribute names cannot start with the letters xml (or XML, or Xml, etc) Attribute names can contain letters, digits, hyphens, underscores, and periods.",
|
|
52
|
+
type="string",
|
|
53
|
+
),
|
|
54
|
+
ValueProperty(
|
|
55
|
+
name="type",
|
|
56
|
+
description="the type of value stored by this attribute",
|
|
57
|
+
type="string",
|
|
58
|
+
enum=["string", "boolean", "number"],
|
|
59
|
+
),
|
|
60
|
+
ValueProperty(name="description", type="string"),
|
|
61
|
+
],
|
|
62
|
+
),
|
|
63
|
+
ElementType(
|
|
64
|
+
tag_name="child_elements",
|
|
65
|
+
properties=[
|
|
66
|
+
ValueProperty(
|
|
67
|
+
name="name",
|
|
68
|
+
description="the name of the property to store the children in. Propterty names cannot contain spaces. Propterty names must start with a letter or underscore. Propterty names cannot start with the letters xml (or XML, or Xml, etc) Propterty names can contain letters, digits, hyphens, and underscores.",
|
|
69
|
+
type="string",
|
|
70
|
+
),
|
|
71
|
+
ValueProperty(name="description", type="string"),
|
|
72
|
+
ChildProperty(
|
|
73
|
+
name="children",
|
|
74
|
+
description="the tag name of an element. The element must have a corresponding element definition under the schema elements",
|
|
75
|
+
child_tag_names=["element_reference"],
|
|
76
|
+
),
|
|
77
|
+
],
|
|
78
|
+
),
|
|
79
|
+
ElementType(
|
|
80
|
+
tag_name="element_reference",
|
|
81
|
+
description="an allowed child element for an element, should only used when a schema can contain multiple items of a specific type",
|
|
82
|
+
properties=[
|
|
83
|
+
ValueProperty(
|
|
84
|
+
name="tag_name",
|
|
85
|
+
description="the tag name of an element. The element must have a corresponding element definition under the schema elements",
|
|
86
|
+
type="string",
|
|
87
|
+
),
|
|
88
|
+
],
|
|
89
|
+
),
|
|
37
90
|
],
|
|
38
91
|
)
|
|
39
92
|
|
|
93
|
+
|
|
40
94
|
def schema_from_schema_document(document: Document):
|
|
41
95
|
root_tag_name = document.root["root_tag_name"]
|
|
42
96
|
|
|
43
97
|
elements = list[ElementType]()
|
|
44
98
|
|
|
45
99
|
for element in document.root.get_children():
|
|
46
|
-
|
|
47
100
|
properties = list[ElementProperty]()
|
|
48
|
-
|
|
101
|
+
|
|
49
102
|
for prop in element.get_children():
|
|
50
103
|
name = prop["name"]
|
|
51
104
|
description = prop["description"]
|
|
52
105
|
type = prop["type"]
|
|
53
|
-
|
|
106
|
+
|
|
54
107
|
if prop.tag_name == "attribute":
|
|
55
|
-
properties.append(
|
|
56
|
-
name =
|
|
57
|
-
|
|
58
|
-
description = description
|
|
59
|
-
))
|
|
108
|
+
properties.append(
|
|
109
|
+
ValueProperty(name=name, type=type, description=description)
|
|
110
|
+
)
|
|
60
111
|
elif prop.tag_name == "child_elements":
|
|
61
112
|
child_tag_names = []
|
|
62
|
-
|
|
113
|
+
|
|
63
114
|
for child in prop.get_children():
|
|
64
115
|
child_tag_names.append(child["tag_name"])
|
|
65
116
|
|
|
66
|
-
properties.append(
|
|
67
|
-
name=name,
|
|
68
|
-
|
|
69
|
-
))
|
|
117
|
+
properties.append(
|
|
118
|
+
ChildProperty(name=name, child_tag_names=child_tag_names)
|
|
119
|
+
)
|
|
70
120
|
|
|
71
|
-
et = ElementType(
|
|
121
|
+
et = ElementType(
|
|
122
|
+
tag_name=element["tag_name"],
|
|
123
|
+
properties=properties,
|
|
124
|
+
description=element["description"],
|
|
125
|
+
)
|
|
72
126
|
elements.append(et)
|
|
73
127
|
|
|
74
128
|
doc = MeshSchema(root_tag_name=root_tag_name, elements=elements)
|
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
from meshagent.api.schema import MeshSchema, ElementType,
|
|
1
|
+
from meshagent.api.schema import MeshSchema, ElementType, ChildProperty, ValueProperty
|
|
2
2
|
|
|
3
|
-
super_editor_document_schema = MeshSchema(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
3
|
+
super_editor_document_schema = MeshSchema(
|
|
4
|
+
root_tag_name="document",
|
|
5
|
+
elements=[
|
|
6
|
+
ElementType(
|
|
7
|
+
tag_name="document",
|
|
8
|
+
description="A SuperEditor document for use with Flutter apps",
|
|
9
|
+
properties=[
|
|
10
|
+
ChildProperty(
|
|
11
|
+
name="children",
|
|
12
|
+
child_tag_names=[
|
|
13
|
+
"block",
|
|
14
|
+
"horizontalRule",
|
|
15
|
+
"image",
|
|
16
|
+
],
|
|
17
|
+
),
|
|
18
|
+
],
|
|
19
|
+
),
|
|
20
|
+
ElementType(
|
|
21
|
+
tag_name="block",
|
|
22
|
+
description="Block element - this can be a paragraph, list-item or tasks",
|
|
23
|
+
properties=[
|
|
24
|
+
ValueProperty(name="blockType", type="string"),
|
|
25
|
+
ValueProperty(name="textAlign", type="string"),
|
|
26
|
+
ValueProperty(name="itemType", type="string"),
|
|
27
|
+
ValueProperty(name="indent", type="number"),
|
|
28
|
+
ChildProperty(name="children", child_tag_names=["text"]),
|
|
29
|
+
],
|
|
30
|
+
),
|
|
31
|
+
ElementType(
|
|
32
|
+
tag_name="image",
|
|
33
|
+
description="Image element",
|
|
34
|
+
properties=[
|
|
35
|
+
ValueProperty(name="imageUrl", type="string"),
|
|
36
|
+
ValueProperty(name="width", type="number"),
|
|
37
|
+
ValueProperty(name="height", type="number"),
|
|
38
|
+
],
|
|
39
|
+
),
|
|
40
|
+
ElementType(
|
|
41
|
+
tag_name="horizontalRule",
|
|
42
|
+
description="Horizontal rule element",
|
|
43
|
+
properties=[],
|
|
44
|
+
),
|
|
45
|
+
ElementType(
|
|
46
|
+
tag_name="text",
|
|
47
|
+
description="Text element",
|
|
48
|
+
properties=[
|
|
49
|
+
ValueProperty(name="text", type="string"),
|
|
50
|
+
],
|
|
51
|
+
),
|
|
52
|
+
],
|
|
53
|
+
)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
from meshagent.api.schema import ValueProperty, ChildProperty
|
|
3
2
|
from meshagent.tools import Toolkit
|
|
4
3
|
from meshagent.agents.writer import Writer, WriterContext
|
|
@@ -12,37 +11,44 @@ import logging
|
|
|
12
11
|
logger = logging.getLogger("planning_agent")
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
class SingleShotWriter(Writer):
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
name: str,
|
|
18
|
+
llm_adapter: LLMAdapter,
|
|
19
|
+
tool_adapter: Optional[ToolResponseAdapter] = None,
|
|
20
|
+
description: Optional[str] = None,
|
|
21
|
+
title: Optional[str] = None,
|
|
22
|
+
rules: Optional[list[str]] = None,
|
|
23
|
+
requires: Optional[list[Requirement]] = None,
|
|
24
|
+
toolkits: Optional[list[Toolkit]] = None,
|
|
25
|
+
supports_tools: Optional[bool] = None,
|
|
26
|
+
labels: Optional[list[str]] = None,
|
|
27
|
+
):
|
|
19
28
|
super().__init__(
|
|
20
29
|
name=name,
|
|
21
30
|
description=description,
|
|
22
31
|
title=title,
|
|
23
32
|
input_schema=merge(
|
|
24
33
|
schema=prompt_schema(description="use a prompt to generate content"),
|
|
25
|
-
additional_properties={
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
},
|
|
34
|
+
additional_properties={"path": {"type": "string"}},
|
|
35
|
+
),
|
|
36
|
+
output_schema={
|
|
37
|
+
"type": "object",
|
|
38
|
+
"additionalProperties": False,
|
|
39
|
+
"required": [],
|
|
40
|
+
"properties": {},
|
|
41
|
+
},
|
|
35
42
|
requires=requires,
|
|
36
43
|
supports_tools=supports_tools,
|
|
37
44
|
)
|
|
38
45
|
self._rules = rules
|
|
39
46
|
self._llm_adapter = llm_adapter
|
|
40
|
-
self._tool_adapter = tool_adapter
|
|
41
|
-
if toolkits
|
|
47
|
+
self._tool_adapter = tool_adapter
|
|
48
|
+
if toolkits is None:
|
|
42
49
|
toolkits = []
|
|
43
50
|
self._toolkits = toolkits
|
|
44
51
|
self._labels = labels
|
|
45
|
-
|
|
46
52
|
|
|
47
53
|
async def init_chat_context(self):
|
|
48
54
|
context = self._llm_adapter.create_chat_context()
|
|
@@ -50,31 +56,33 @@ class SingleShotWriter(Writer):
|
|
|
50
56
|
return context
|
|
51
57
|
|
|
52
58
|
async def write(self, writer_context: WriterContext, arguments: dict):
|
|
53
|
-
|
|
54
59
|
arguments = arguments.copy()
|
|
55
60
|
self.pop_path(arguments=arguments)
|
|
56
61
|
|
|
57
62
|
prompt = arguments["prompt"]
|
|
58
63
|
|
|
59
64
|
writer_context.call_context.chat.append_user_message(message=prompt)
|
|
60
|
-
|
|
61
|
-
toolkits = [
|
|
62
|
-
|
|
63
|
-
*writer_context.call_context.toolkits
|
|
64
|
-
]
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
toolkits = [*self._toolkits, *writer_context.call_context.toolkits]
|
|
67
|
+
|
|
66
68
|
try:
|
|
67
69
|
logger.info("SINGLE SHOT COMPLETION STARTING")
|
|
68
|
-
|
|
69
|
-
response = await self._llm_adapter.next(
|
|
70
|
+
|
|
71
|
+
response = await self._llm_adapter.next(
|
|
72
|
+
context=writer_context.call_context.chat,
|
|
73
|
+
room=writer_context.room,
|
|
74
|
+
toolkits=toolkits,
|
|
75
|
+
tool_adapter=self._tool_adapter,
|
|
76
|
+
output_schema=writer_context.document.schema.to_json(),
|
|
77
|
+
)
|
|
70
78
|
|
|
71
79
|
logger.info("SINGLE SHOT COMPLETION RESPONSE %s", response)
|
|
72
|
-
|
|
80
|
+
|
|
73
81
|
except Exception as e:
|
|
74
82
|
logger.error("Unable to execute reasoning completion task", exc_info=e)
|
|
75
83
|
# retry
|
|
76
|
-
raise(e)
|
|
77
|
-
|
|
84
|
+
raise (e)
|
|
85
|
+
|
|
78
86
|
document = writer_context.document
|
|
79
87
|
response = response[document.schema.root.tag_name]
|
|
80
88
|
|
|
@@ -88,5 +96,3 @@ class SingleShotWriter(Writer):
|
|
|
88
96
|
raise Exception("Unexpected property type")
|
|
89
97
|
|
|
90
98
|
return {}
|
|
91
|
-
|
|
92
|
-
|
|
@@ -1,60 +1,102 @@
|
|
|
1
|
-
from meshagent.api.schema import MeshSchema, ElementType,
|
|
1
|
+
from meshagent.api.schema import MeshSchema, ElementType, ChildProperty, ValueProperty
|
|
2
2
|
|
|
3
3
|
thread_schema = MeshSchema(
|
|
4
4
|
root_tag_name="thread",
|
|
5
5
|
elements=[
|
|
6
6
|
ElementType(
|
|
7
|
-
tag_name="thread",
|
|
7
|
+
tag_name="thread",
|
|
8
8
|
description="a thread of messages",
|
|
9
9
|
properties=[
|
|
10
|
-
ValueProperty(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
ValueProperty(
|
|
11
|
+
name="name", description="name of the tread", type="string"
|
|
12
|
+
),
|
|
13
|
+
ChildProperty(
|
|
14
|
+
name="properties",
|
|
15
|
+
description="the messages in the thread",
|
|
16
|
+
ordered=True,
|
|
17
|
+
child_tag_names=["members", "messages"],
|
|
18
|
+
),
|
|
19
|
+
],
|
|
15
20
|
),
|
|
16
21
|
ElementType(
|
|
17
|
-
tag_name="members",
|
|
22
|
+
tag_name="members",
|
|
18
23
|
description="the members of this thread",
|
|
19
24
|
properties=[
|
|
20
|
-
ChildProperty(
|
|
21
|
-
|
|
25
|
+
ChildProperty(
|
|
26
|
+
name="items",
|
|
27
|
+
child_tag_names=["member"],
|
|
28
|
+
description="the messages in this thread",
|
|
29
|
+
)
|
|
30
|
+
],
|
|
22
31
|
),
|
|
23
32
|
ElementType(
|
|
24
|
-
tag_name="messages",
|
|
33
|
+
tag_name="messages",
|
|
25
34
|
description="the messages of this thread",
|
|
26
35
|
properties=[
|
|
27
|
-
ChildProperty(
|
|
28
|
-
|
|
36
|
+
ChildProperty(
|
|
37
|
+
name="items",
|
|
38
|
+
child_tag_names=["message"],
|
|
39
|
+
description="the messages in this thread",
|
|
40
|
+
)
|
|
41
|
+
],
|
|
29
42
|
),
|
|
30
43
|
ElementType(
|
|
31
|
-
tag_name="member",
|
|
44
|
+
tag_name="member",
|
|
32
45
|
description="a member of this thread",
|
|
33
46
|
properties=[
|
|
34
|
-
ValueProperty(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
ValueProperty(
|
|
48
|
+
name="name", description="the name of the member", type="string"
|
|
49
|
+
),
|
|
50
|
+
ValueProperty(
|
|
51
|
+
name="type",
|
|
52
|
+
description="the type of member",
|
|
53
|
+
type="string",
|
|
54
|
+
enum=["user", "agent"],
|
|
55
|
+
),
|
|
56
|
+
],
|
|
39
57
|
),
|
|
40
58
|
ElementType(
|
|
41
|
-
tag_name="file",
|
|
59
|
+
tag_name="file",
|
|
42
60
|
description="a file attachment",
|
|
43
61
|
properties=[
|
|
44
|
-
ValueProperty(
|
|
45
|
-
|
|
62
|
+
ValueProperty(
|
|
63
|
+
name="path",
|
|
64
|
+
description="the path of the file in the room",
|
|
65
|
+
type="string",
|
|
66
|
+
),
|
|
67
|
+
],
|
|
46
68
|
),
|
|
47
69
|
ElementType(
|
|
48
|
-
tag_name="message",
|
|
70
|
+
tag_name="message",
|
|
49
71
|
description="a message sent in the conversation",
|
|
50
72
|
properties=[
|
|
51
|
-
ValueProperty(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ValueProperty(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
ValueProperty(
|
|
74
|
+
name="id", description="the id of the message", type="string"
|
|
75
|
+
),
|
|
76
|
+
ValueProperty(
|
|
77
|
+
name="text", description="the text of the message", type="string"
|
|
78
|
+
),
|
|
79
|
+
ValueProperty(
|
|
80
|
+
name="created_at",
|
|
81
|
+
description="the date that the message was sent in ISO format",
|
|
82
|
+
type="string",
|
|
83
|
+
),
|
|
84
|
+
ValueProperty(
|
|
85
|
+
name="author_name",
|
|
86
|
+
description="the name of the author of the post",
|
|
87
|
+
type="string",
|
|
88
|
+
),
|
|
89
|
+
ValueProperty(
|
|
90
|
+
name="author_ref",
|
|
91
|
+
description="a reference to author identity in another system",
|
|
92
|
+
type="string",
|
|
93
|
+
),
|
|
94
|
+
ChildProperty(
|
|
95
|
+
name="attachments",
|
|
96
|
+
child_tag_names=["file"],
|
|
97
|
+
description="a list of message attachments",
|
|
98
|
+
),
|
|
99
|
+
],
|
|
100
|
+
),
|
|
101
|
+
],
|
|
60
102
|
)
|
meshagent/agents/utils.py
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
from meshagent.api import RoomClient, Requirement, RoomException, Participant
|
|
2
|
-
from meshagent.tools import validate_openai_schema
|
|
2
|
+
from meshagent.tools import validate_openai_schema
|
|
3
3
|
import json
|
|
4
4
|
from typing import Optional
|
|
5
5
|
import asyncio
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
async def generate_json(
|
|
9
|
+
*,
|
|
10
|
+
on_behalf_of: Optional[Participant] = None,
|
|
11
|
+
room: RoomClient,
|
|
12
|
+
prompt: Optional[str] = None,
|
|
13
|
+
output_schema: dict,
|
|
14
|
+
requires: Optional[list[Requirement]] = None,
|
|
15
|
+
) -> dict:
|
|
9
16
|
# make sure agent is in the room before proceeding
|
|
10
17
|
agent = None
|
|
11
18
|
for i in range(10):
|
|
@@ -14,25 +21,26 @@ async def generate_json(*, on_behalf_of: Optional[Participant] = None, room: Roo
|
|
|
14
21
|
if a.name == "meshagent.schema_planner":
|
|
15
22
|
agent = a
|
|
16
23
|
break
|
|
17
|
-
|
|
18
|
-
if agent
|
|
24
|
+
|
|
25
|
+
if agent is not None:
|
|
19
26
|
break
|
|
20
27
|
|
|
21
28
|
await asyncio.sleep(1)
|
|
22
29
|
|
|
23
|
-
if agent
|
|
24
|
-
raise RoomException(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
if agent is None:
|
|
31
|
+
raise RoomException(
|
|
32
|
+
"unable to locate required agent (meshagent.schema_planner)"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
if prompt is None:
|
|
28
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."
|
|
29
37
|
|
|
30
38
|
validate_openai_schema(output_schema)
|
|
31
39
|
return await room.agents.ask(
|
|
32
40
|
on_behalf_of=on_behalf_of,
|
|
33
41
|
agent="meshagent.schema_planner",
|
|
34
|
-
requires
|
|
35
|
-
arguments
|
|
42
|
+
requires=requires,
|
|
43
|
+
arguments={
|
|
36
44
|
"prompt": prompt,
|
|
37
45
|
"output_schema": output_schema,
|
|
38
46
|
},
|
meshagent/agents/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.38"
|