agently 4.0.6.4__py3-none-any.whl → 4.0.6.6__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.
- agently/builtins/plugins/PromptGenerator/AgentlyPromptGenerator.py +4 -16
- agently/integrations/chromadb.py +93 -12
- agently/types/data/tool.py +2 -2
- agently/utils/DataFormatter.py +25 -15
- {agently-4.0.6.4.dist-info → agently-4.0.6.6.dist-info}/METADATA +1 -1
- {agently-4.0.6.4.dist-info → agently-4.0.6.6.dist-info}/RECORD +8 -8
- {agently-4.0.6.4.dist-info → agently-4.0.6.6.dist-info}/WHEEL +0 -0
- {agently-4.0.6.4.dist-info → agently-4.0.6.6.dist-info}/licenses/LICENSE +0 -0
|
@@ -307,9 +307,7 @@ class AgentlyPromptGenerator(PromptGenerator):
|
|
|
307
307
|
if isinstance(role_mapping, dict):
|
|
308
308
|
merged_role_mapping.update(role_mapping)
|
|
309
309
|
|
|
310
|
-
prompt_text_list.append(
|
|
311
|
-
f"{ (merged_role_mapping['user'] if 'user' in merged_role_mapping else 'user').upper() }:"
|
|
312
|
-
)
|
|
310
|
+
prompt_text_list.append(f"{ (merged_role_mapping['user'] if 'user' in merged_role_mapping else 'user') }:")
|
|
313
311
|
|
|
314
312
|
# system & developer
|
|
315
313
|
if prompt_object.system:
|
|
@@ -368,7 +366,7 @@ class AgentlyPromptGenerator(PromptGenerator):
|
|
|
368
366
|
|
|
369
367
|
prompt_text_list.extend(self._generate_main_prompt(prompt_object))
|
|
370
368
|
prompt_text_list.append(
|
|
371
|
-
f"{ (merged_role_mapping['assistant'] if 'assistant' in merged_role_mapping else 'assistant')
|
|
369
|
+
f"{ (merged_role_mapping['assistant'] if 'assistant' in merged_role_mapping else 'assistant') }:"
|
|
372
370
|
)
|
|
373
371
|
|
|
374
372
|
return "\n".join(prompt_text_list)
|
|
@@ -398,12 +396,7 @@ class AgentlyPromptGenerator(PromptGenerator):
|
|
|
398
396
|
if prompt_object.system:
|
|
399
397
|
prompt_messages.append(
|
|
400
398
|
self._generate_yaml_prompt_message(
|
|
401
|
-
|
|
402
|
-
prompt_title_mapping.get(
|
|
403
|
-
'system',
|
|
404
|
-
'SYSTEM',
|
|
405
|
-
)
|
|
406
|
-
),
|
|
399
|
+
"system",
|
|
407
400
|
prompt_object.system,
|
|
408
401
|
role_mapping=merged_role_mapping,
|
|
409
402
|
)
|
|
@@ -412,12 +405,7 @@ class AgentlyPromptGenerator(PromptGenerator):
|
|
|
412
405
|
if prompt_object.developer:
|
|
413
406
|
prompt_messages.append(
|
|
414
407
|
self._generate_yaml_prompt_message(
|
|
415
|
-
|
|
416
|
-
prompt_title_mapping.get(
|
|
417
|
-
'developer',
|
|
418
|
-
'DEVELOPER DIRECTIONS',
|
|
419
|
-
)
|
|
420
|
-
),
|
|
408
|
+
"developer",
|
|
421
409
|
prompt_object.developer,
|
|
422
410
|
role_mapping=merged_role_mapping,
|
|
423
411
|
)
|
agently/integrations/chromadb.py
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
from agently.utils import LazyImport
|
|
1
|
+
from agently.utils import LazyImport, FunctionShifter
|
|
2
2
|
|
|
3
3
|
LazyImport.import_package("chromadb")
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
from typing import Callable, TypedDict, Any, TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
from chromadb.api.types import EmbeddingFunction,
|
|
7
|
+
from chromadb.api.types import EmbeddingFunction, DefaultEmbeddingFunction
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
from
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from chromadb.api.types import (
|
|
11
|
+
Documents,
|
|
12
|
+
Embedding,
|
|
13
|
+
Embeddings,
|
|
14
|
+
QueryResult,
|
|
15
|
+
Schema,
|
|
16
|
+
CollectionMetadata,
|
|
17
|
+
DataLoader,
|
|
18
|
+
Loadable,
|
|
19
|
+
)
|
|
20
|
+
from chromadb.api.collection_configuration import CreateCollectionConfiguration
|
|
21
|
+
from chromadb.api import ClientAPI
|
|
22
|
+
from agently.core import BaseAgent
|
|
11
23
|
|
|
12
24
|
|
|
13
25
|
class ChromaDataDictOptional(TypedDict, total=False):
|
|
14
26
|
metadata: dict[Any, Any]
|
|
15
27
|
id: Any
|
|
16
|
-
embedding: Embedding
|
|
28
|
+
embedding: "Embedding"
|
|
17
29
|
|
|
18
30
|
|
|
19
31
|
class ChromaDataDict(ChromaDataDictOptional):
|
|
@@ -25,15 +37,15 @@ class ChromaData:
|
|
|
25
37
|
self,
|
|
26
38
|
original_data: ChromaDataDict | list[ChromaDataDict],
|
|
27
39
|
*,
|
|
28
|
-
embedding_function: Callable[[str | list[str]], Embeddings] | None = None,
|
|
29
|
-
agent: BaseAgent | None = None,
|
|
40
|
+
embedding_function: "Callable[[str | list[str]], Embeddings] | None" = None,
|
|
41
|
+
agent: "BaseAgent | None" = None,
|
|
30
42
|
):
|
|
31
43
|
self._original_data = original_data if isinstance(original_data, list) else [original_data]
|
|
32
44
|
if embedding_function:
|
|
33
45
|
self._embedding_function = embedding_function
|
|
34
46
|
elif agent:
|
|
35
47
|
|
|
36
|
-
def embedding_function_by_agent(texts: str | list[str]) -> Embeddings:
|
|
48
|
+
def embedding_function_by_agent(texts: str | list[str]) -> "Embeddings":
|
|
37
49
|
return agent.input(texts).start()
|
|
38
50
|
|
|
39
51
|
self._embedding_function = embedding_function_by_agent
|
|
@@ -65,15 +77,50 @@ class ChromaData:
|
|
|
65
77
|
return self._original_data
|
|
66
78
|
|
|
67
79
|
|
|
80
|
+
class ChromaResults:
|
|
81
|
+
def __init__(
|
|
82
|
+
self,
|
|
83
|
+
*,
|
|
84
|
+
queries: str | list[str],
|
|
85
|
+
results: "QueryResult",
|
|
86
|
+
):
|
|
87
|
+
if isinstance(queries, str):
|
|
88
|
+
queries = [queries]
|
|
89
|
+
if len(queries) != len(results["documents"] or []):
|
|
90
|
+
raise ValueError(
|
|
91
|
+
f"The length of queries does not equal the length of results.\nQueries: { queries }\nResults: { results }"
|
|
92
|
+
)
|
|
93
|
+
self._chroma_results = results
|
|
94
|
+
self._results = {}
|
|
95
|
+
for query_index, query in enumerate(queries):
|
|
96
|
+
for result_index, id in enumerate(results["ids"][query_index]):
|
|
97
|
+
result = {
|
|
98
|
+
"id": id,
|
|
99
|
+
"document": results["documents"][query_index][result_index] if results["documents"] else None,
|
|
100
|
+
"metadata": results["metadatas"][query_index][result_index] if results["metadatas"] else None,
|
|
101
|
+
"distance": results["distances"][query_index][result_index] if results["distances"] else None,
|
|
102
|
+
}
|
|
103
|
+
self._results[query] = result
|
|
104
|
+
|
|
105
|
+
def get_original_results(self):
|
|
106
|
+
return self._chroma_results
|
|
107
|
+
|
|
108
|
+
def get(self):
|
|
109
|
+
return self._results
|
|
110
|
+
|
|
111
|
+
|
|
68
112
|
class ChromaEmbeddingFunction(EmbeddingFunction):
|
|
69
113
|
def __init__(
|
|
70
|
-
self,
|
|
114
|
+
self,
|
|
115
|
+
*,
|
|
116
|
+
embedding_function: "Callable[[list[str]], Embeddings] | None" = None,
|
|
117
|
+
agent: "BaseAgent | None" = None,
|
|
71
118
|
):
|
|
72
119
|
if embedding_function:
|
|
73
120
|
self.embedding_function = embedding_function
|
|
74
121
|
elif agent:
|
|
75
122
|
|
|
76
|
-
def embedding_function_by_agent(texts: list[str]) -> Embeddings:
|
|
123
|
+
def embedding_function_by_agent(texts: list[str]) -> "Embeddings":
|
|
77
124
|
return agent.input(texts).start()
|
|
78
125
|
|
|
79
126
|
self.embedding_function = embedding_function_by_agent
|
|
@@ -82,5 +129,39 @@ class ChromaEmbeddingFunction(EmbeddingFunction):
|
|
|
82
129
|
f"ChromaEmbeddingFunction() requires at least one definition for 'embedding_function' or 'agent'."
|
|
83
130
|
)
|
|
84
131
|
|
|
85
|
-
def __call__(self, documents: Documents) -> Embeddings:
|
|
132
|
+
def __call__(self, documents: "Documents") -> "Embeddings":
|
|
86
133
|
return self.embedding_function([document for document in documents])
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class ChromaCollection:
|
|
137
|
+
def __init__(
|
|
138
|
+
self,
|
|
139
|
+
conn: "ClientAPI",
|
|
140
|
+
collection_name: str,
|
|
141
|
+
*,
|
|
142
|
+
schema: "Schema | None" = None,
|
|
143
|
+
configuration: "CreateCollectionConfiguration | None" = None,
|
|
144
|
+
metadata: None = None,
|
|
145
|
+
embedding_function: EmbeddingFunction | None = None,
|
|
146
|
+
agent: "BaseAgent | None" = None,
|
|
147
|
+
data_loader: "DataLoader[Loadable] | None" = None,
|
|
148
|
+
get_or_create: bool = False,
|
|
149
|
+
):
|
|
150
|
+
if embedding_function:
|
|
151
|
+
self._embedding_function = embedding_function
|
|
152
|
+
elif agent:
|
|
153
|
+
self._embedding_function = ChromaEmbeddingFunction(agent=agent)
|
|
154
|
+
else:
|
|
155
|
+
self._embedding_function = DefaultEmbeddingFunction()
|
|
156
|
+
|
|
157
|
+
self._collection = conn.create_collection(
|
|
158
|
+
collection_name,
|
|
159
|
+
schema=schema,
|
|
160
|
+
configuration=configuration,
|
|
161
|
+
metadata=metadata,
|
|
162
|
+
embedding_function=embedding_function,
|
|
163
|
+
data_loader=data_loader,
|
|
164
|
+
get_or_create=get_or_create,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
def add(self): ...
|
agently/types/data/tool.py
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
from typing import Literal, Callable, TypeAlias
|
|
16
|
+
from typing import Any, Literal, Callable, TypeAlias
|
|
17
17
|
from typing_extensions import TypedDict, NotRequired
|
|
18
18
|
from pydantic import AnyUrl
|
|
19
19
|
from httpx import Auth, AsyncClient
|
|
20
20
|
|
|
21
|
-
ArgumentDesc: TypeAlias = type | str | tuple[str | type, str]
|
|
21
|
+
ArgumentDesc: TypeAlias = type | str | tuple[str | type | Any, str]
|
|
22
22
|
KwargsType: TypeAlias = dict[str, ArgumentDesc]
|
|
23
23
|
ReturnType: TypeAlias = KwargsType | ArgumentDesc | dict[str, "ReturnType"] | list["ReturnType"]
|
|
24
24
|
|
agently/utils/DataFormatter.py
CHANGED
|
@@ -218,21 +218,31 @@ class DataFormatter:
|
|
|
218
218
|
raise KeyError(f"Cannot find key 'type' in input schema: { input_schema }")
|
|
219
219
|
if input_schema["type"] != "object":
|
|
220
220
|
raise TypeError(f"Input schema type is not 'object' but: { input_schema['type'] }")
|
|
221
|
-
|
|
222
|
-
raise KeyError(f"Cannot find key 'properties' in input schema: { input_schema }")
|
|
223
|
-
properties = input_schema["properties"]
|
|
221
|
+
|
|
224
222
|
kwargs_format: "KwargsType" = {}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
|
|
224
|
+
if "properties" in input_schema and input_schema["properties"]:
|
|
225
|
+
properties = input_schema["properties"]
|
|
226
|
+
for kwarg_name, kwarg_schema in properties.items():
|
|
227
|
+
kwarg_type = kwarg_schema.pop("type", Any)
|
|
228
|
+
kwarg_schema.pop("title", None)
|
|
229
|
+
kwarg_desc = ";".join([f"{k}: {v}" for k, v in kwarg_schema.items()]) if kwarg_schema else ""
|
|
230
|
+
kwargs_format[kwarg_name] = (kwarg_type, kwarg_desc)
|
|
231
|
+
|
|
232
|
+
if "additionalProperties" in input_schema:
|
|
233
|
+
additional_properties = input_schema["additionalProperties"]
|
|
234
|
+
if additional_properties is True or additional_properties is None:
|
|
235
|
+
kwargs_format["<*>"] = (Any, "")
|
|
229
236
|
else:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
additional_type = additional_properties.pop("type", Any)
|
|
238
|
+
additional_properties.pop("title", None)
|
|
239
|
+
additional_desc = (
|
|
240
|
+
";".join([f"{k}: {v}" for k, v in additional_properties.items()])
|
|
241
|
+
if additional_properties
|
|
242
|
+
else ""
|
|
243
|
+
)
|
|
244
|
+
kwargs_format["<*>"] = (additional_type, additional_desc)
|
|
245
|
+
|
|
246
|
+
return kwargs_format or None
|
|
247
|
+
|
|
238
248
|
return None
|
|
@@ -12,7 +12,7 @@ agently/builtins/hookers/ConsoleHooker.py,sha256=aJdDj_nG8CiwyelA505zvtpzBSwD52n
|
|
|
12
12
|
agently/builtins/hookers/PureLoggerHooker.py,sha256=fzN0OfhQzgns4KeCNH-qcdm-BdQT0W2kqEmt3Zp2pYI,1906
|
|
13
13
|
agently/builtins/hookers/SystemMessageHooker.py,sha256=nU5rOzcuXKdaTXWix3jhZ-4QoD4cMQJZo02wNTpZpjI,5396
|
|
14
14
|
agently/builtins/plugins/ModelRequester/OpenAICompatible.py,sha256=ApH6EKAWY66eKpm-BtK6qID73CelLFA_7EfJ4zvRH1k,25233
|
|
15
|
-
agently/builtins/plugins/PromptGenerator/AgentlyPromptGenerator.py,sha256=
|
|
15
|
+
agently/builtins/plugins/PromptGenerator/AgentlyPromptGenerator.py,sha256=KMlXKH44MExTaGnu5cmLtvYT3aXOQiXOZN-F4JeVnJE,28514
|
|
16
16
|
agently/builtins/plugins/ResponseParser/AgentlyResponseParser.py,sha256=FEhfsiHB4Bx7HfghnObklLj08j8IVwGh0WEVD6U-G3U,17445
|
|
17
17
|
agently/builtins/plugins/ToolManager/AgentlyToolManager.py,sha256=oaqte5LAryZQMD6vuEbKhe6kOLUyZTRZswC1MDFiYxw,9138
|
|
18
18
|
agently/builtins/plugins/__init__.py,sha256=wj4_U9TTekc2CmjppbXKUREDFRXFX1y0ySOW-CxQuok,801
|
|
@@ -37,7 +37,7 @@ agently/core/TriggerFlow/process/ForEachProcess.py,sha256=oBI7KIpnj2tbczt_cTJCNv
|
|
|
37
37
|
agently/core/TriggerFlow/process/MatchCaseProcess.py,sha256=-NpbAlXq054juNkFCsDdWsIBMoHHKV1-cEsgndcd9KY,7888
|
|
38
38
|
agently/core/TriggerFlow/process/__init__.py,sha256=BP5bAr9LRVVD83KFqXeprgTmXA1iCSOSsD509BtoX_E,753
|
|
39
39
|
agently/core/__init__.py,sha256=CPglSpW5oEEmWpCpdvv9wK4myXmVipjuZm5HtMq6Vxo,1214
|
|
40
|
-
agently/integrations/chromadb.py,sha256=
|
|
40
|
+
agently/integrations/chromadb.py,sha256=Hsp2cNZ_D3WK_OkYwlYBRvYpwBEgFGf7PuQW-ckUWwA,5693
|
|
41
41
|
agently/types/__init__.py,sha256=xb8GMY-ULncO_PY9rfRUsyi12wAQQJx8gAAnoM30uZA,592
|
|
42
42
|
agently/types/data/__init__.py,sha256=qladqSEqcAUW_XzdTDl4cvaraq_DpANy3aZbIPxoygk,1627
|
|
43
43
|
agently/types/data/event.py,sha256=LFQW7MN_QGOis3XV-8K6jNXWsLvT7tYxo4BZbUBCpfI,1790
|
|
@@ -45,7 +45,7 @@ agently/types/data/prompt.py,sha256=DiszVM_3OHe66waf-99mBH7bzRr0cpbCHSpDI-2EjPs,
|
|
|
45
45
|
agently/types/data/request.py,sha256=Do-9g5QxZRMYjaoHCZYwHbj28r-t4noAAtOebw764P4,1924
|
|
46
46
|
agently/types/data/response.py,sha256=vjKIILaVyd5TVz5nvmytVRJPZg-RP0sRydhg_AzU6y0,3700
|
|
47
47
|
agently/types/data/serializable.py,sha256=v2KlyKNOKp4L6J_Ueupb-gCyrnngvBskFUwNPSJQgnA,844
|
|
48
|
-
agently/types/data/tool.py,sha256=
|
|
48
|
+
agently/types/data/tool.py,sha256=wE8Dda2JtY5cojpHUuQrw7PNeVZ6Zma968bn-pUmS7I,1529
|
|
49
49
|
agently/types/plugins/EventHooker.py,sha256=kb80-baVc3fVlrddW5syv9uSD8a2Mcw8Fd3I2HQhY_Y,1030
|
|
50
50
|
agently/types/plugins/ModelRequester.py,sha256=urG1zFX0b4U6ZKSO50IbW5IHK3ydmRgUom7O7Niqk8s,3875
|
|
51
51
|
agently/types/plugins/PromptGenerator.py,sha256=45jmVzAkyl1Yj2M8RVfQM_zFAJZP4zrPuQkHbWIQSRQ,4531
|
|
@@ -55,7 +55,7 @@ agently/types/plugins/__init__.py,sha256=gz_EpgBQGndIQHY5vJB2YRzAN5yIb3FZZG7pC8l
|
|
|
55
55
|
agently/types/plugins/base.py,sha256=AoNLwsH5IZBQt7_NZfxMWMhAk6PJSOFHR0IYOXp1imI,1167
|
|
56
56
|
agently/types/trigger_flow/__init__.py,sha256=Gj31SmWBC4qtrOqQedyGsnCfeSkUf3XvZNFrJ2QbMNw,777
|
|
57
57
|
agently/types/trigger_flow/trigger_flow.py,sha256=uDUZiila_4Rr41zUlzR4QqaRaraC43XTFfj-jnnG2G0,3787
|
|
58
|
-
agently/utils/DataFormatter.py,sha256=
|
|
58
|
+
agently/utils/DataFormatter.py,sha256=0P92t81vnp-rJSJvlbTF3yM-PRiteB19BNEQ8cmvmns,9444
|
|
59
59
|
agently/utils/DataLocator.py,sha256=ss8OLet9HN0U1PZb-OCHS6KL54kv7vFZph6G0-GBidk,6015
|
|
60
60
|
agently/utils/DataPathBuilder.py,sha256=sEzE1i2EWn7NMkCCXDT50gR6_qMzcZ0y0YGkYbXdB3s,10007
|
|
61
61
|
agently/utils/FunctionShifter.py,sha256=quwugTmf-vzHzRR_2wdv14AxLpr0lwxdUtVoX7Jeq48,5839
|
|
@@ -70,7 +70,7 @@ agently/utils/Storage.py,sha256=E7QyNJ9T0yOUafPgdP90La698hgLMSGjhJ7qCEHzxxw,9438
|
|
|
70
70
|
agently/utils/StreamingJSONCompleter.py,sha256=aZ9zuGUTQlP-QKbXHUZCf6EtVuG49MKn8xdhw0VhDEA,4292
|
|
71
71
|
agently/utils/StreamingJSONParser.py,sha256=sPPJOtj5OYvsrukRErcoxRl4yuV1zDuf7pQ_pvw_Zow,21116
|
|
72
72
|
agently/utils/__init__.py,sha256=7MDln5OVkqFEdhhuG8VTdr2q02UWwCj-udndwzWV_iQ,1280
|
|
73
|
-
agently-4.0.6.
|
|
74
|
-
agently-4.0.6.
|
|
75
|
-
agently-4.0.6.
|
|
76
|
-
agently-4.0.6.
|
|
73
|
+
agently-4.0.6.6.dist-info/METADATA,sha256=wNMoonuHHBsLZHqe94S5YV6Cae2B_EvCzQS8FMbRiYU,7112
|
|
74
|
+
agently-4.0.6.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
75
|
+
agently-4.0.6.6.dist-info/licenses/LICENSE,sha256=Y5ZgAdYgMFigPT8dhN18dTLRtBshOSfWhTDRO1t0Cq4,11360
|
|
76
|
+
agently-4.0.6.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|