agently 4.0.5.5__tar.gz → 4.0.5.6__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.
- {agently-4.0.5.5 → agently-4.0.5.6}/PKG-INFO +1 -1
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ModelRequester/OpenAICompatible.py +40 -18
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ResponseParser/AgentlyResponseParser.py +14 -7
- agently-4.0.5.6/agently/integrations/chromadb.py +86 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/pyproject.toml +1 -1
- {agently-4.0.5.5 → agently-4.0.5.6}/LICENSE +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/README.md +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/_default_init.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/_default_settings.yaml +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/base.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/AutoFuncExtension.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/ChatSessionExtension.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/ConfigurePromptExtension.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/KeyWaiterExtension.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/ToolExtension.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/hookers/ConsoleHooker.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/hookers/PureLoggerHooker.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/hookers/SystemMessageHooker.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/PromptGenerator/AgentlyPromptGenerator.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ToolManager/AgentlyToolManager.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/tools/Browse.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/tools/Search.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/tools/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/Agent.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/EventCenter.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/ExtensionHandlers.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/ModelRequest.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/PluginManager.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/Prompt.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/Tool.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/BluePrint.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/Chunk.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/Execution.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/Process.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/TriggerFlow.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/process/BaseProcess.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/process/ForEachProcess.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/process/MatchCaseProcess.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/TriggerFlow/process/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/core/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/event.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/prompt.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/request.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/response.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/serializable.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/data/tool.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/EventHooker.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/ModelRequester.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/PromptGenerator.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/ResponseParser.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/ToolManager.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/plugins/base.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/trigger_flow/__init__.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/types/trigger_flow/trigger_flow.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/DataFormatter.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/DataLocator.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/DataPathBuilder.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/FunctionShifter.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/GeneratorConsumer.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/LazyImport.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/Logger.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/Messenger.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/RuntimeData.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/SerializableRuntimeData.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/Settings.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/Storage.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/StreamingJSONCompleter.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/StreamingJSONParser.py +0 -0
- {agently-4.0.5.5 → agently-4.0.5.6}/agently/utils/__init__.py +0 -0
{agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ModelRequester/OpenAICompatible.py
RENAMED
|
@@ -184,13 +184,25 @@ class OpenAICompatible(ModelRequester):
|
|
|
184
184
|
request_data = {"prompt": self.prompt.to_text()}
|
|
185
185
|
case "embeddings":
|
|
186
186
|
sanitized_input = DataFormatter.sanitize(self.prompt["input"])
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
if isinstance(sanitized_input, list):
|
|
188
|
+
request_data = {
|
|
189
|
+
"input": [
|
|
190
|
+
(
|
|
191
|
+
str(item)
|
|
192
|
+
if isinstance(item, (str, int, float, bool)) or item is None
|
|
193
|
+
else yaml.safe_dump(item)
|
|
194
|
+
)
|
|
195
|
+
for item in sanitized_input
|
|
196
|
+
],
|
|
197
|
+
}
|
|
198
|
+
else:
|
|
199
|
+
request_data = {
|
|
200
|
+
"input": (
|
|
201
|
+
str(sanitized_input)
|
|
202
|
+
if isinstance(sanitized_input, (str, int, float, bool)) or sanitized_input is None
|
|
203
|
+
else yaml.safe_dump(sanitized_input)
|
|
204
|
+
)
|
|
205
|
+
}
|
|
194
206
|
case _:
|
|
195
207
|
self._messenger.error(
|
|
196
208
|
TypeError(
|
|
@@ -266,7 +278,10 @@ class OpenAICompatible(ModelRequester):
|
|
|
266
278
|
## !: ensure stream
|
|
267
279
|
is_stream = self.plugin_settings.get("stream")
|
|
268
280
|
if is_stream is None:
|
|
269
|
-
|
|
281
|
+
if self.model_type == "embeddings":
|
|
282
|
+
is_stream = False
|
|
283
|
+
else:
|
|
284
|
+
is_stream = True
|
|
270
285
|
request_options.update({"stream": is_stream})
|
|
271
286
|
## set
|
|
272
287
|
agently_request_dict["request_options"] = request_options
|
|
@@ -536,6 +551,9 @@ class OpenAICompatible(ModelRequester):
|
|
|
536
551
|
yield "extra", {extra_key: extra_value}
|
|
537
552
|
else:
|
|
538
553
|
done_content = None
|
|
554
|
+
if self.model_type == "embeddings" and done_mapping is None:
|
|
555
|
+
done_mapping = "data"
|
|
556
|
+
content_mapping_style = "dot"
|
|
539
557
|
if done_mapping:
|
|
540
558
|
done_content = DataLocator.locate_path_in_dict(
|
|
541
559
|
message_record,
|
|
@@ -546,16 +564,20 @@ class OpenAICompatible(ModelRequester):
|
|
|
546
564
|
yield "done", done_content
|
|
547
565
|
else:
|
|
548
566
|
yield "done", content_buffer
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
567
|
+
match self.model_type:
|
|
568
|
+
case "embeddings":
|
|
569
|
+
yield "original_done", message_record
|
|
570
|
+
case "_":
|
|
571
|
+
done_message = message_record
|
|
572
|
+
if "message" not in done_message["choices"][0]:
|
|
573
|
+
done_message["choices"][0].update({"message": {}})
|
|
574
|
+
done_message["choices"][0]["message"].update(
|
|
575
|
+
{
|
|
576
|
+
"role": meta["role"] if "role" in meta else "assistant",
|
|
577
|
+
"content": done_content if done_content else content_buffer,
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
yield "original_done", done_message
|
|
559
581
|
if finish_reason_mapping:
|
|
560
582
|
meta.update(
|
|
561
583
|
{
|
{agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ResponseParser/AgentlyResponseParser.py
RENAMED
|
@@ -153,12 +153,12 @@ class AgentlyResponseParser(ResponseParser):
|
|
|
153
153
|
self.full_result_data["original_done"] = data
|
|
154
154
|
case "done":
|
|
155
155
|
self.full_result_data["text_result"] = str(data)
|
|
156
|
-
if buffer != self.full_result_data["text_result"]:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
# if buffer != self.full_result_data["text_result"]:
|
|
157
|
+
# warnings.warn(
|
|
158
|
+
# "Buffered streaming result is not exactly the same as final result.\n"
|
|
159
|
+
# f"Buffered Result: { buffer }\n"
|
|
160
|
+
# f"Final Result: { self.full_result_data['text_result'] }\n"
|
|
161
|
+
# )
|
|
162
162
|
if self._prompt_object.output_format == "json":
|
|
163
163
|
cleaned_json = DataLocator.locate_output_json(str(data), self._prompt_object.output)
|
|
164
164
|
if cleaned_json:
|
|
@@ -204,7 +204,14 @@ class AgentlyResponseParser(ResponseParser):
|
|
|
204
204
|
self.settings,
|
|
205
205
|
)
|
|
206
206
|
else:
|
|
207
|
-
|
|
207
|
+
if (
|
|
208
|
+
isinstance(data, list)
|
|
209
|
+
and isinstance(data[0], dict)
|
|
210
|
+
and "object" in data[0]
|
|
211
|
+
and data[0]["object"] == "embedding"
|
|
212
|
+
):
|
|
213
|
+
data = [item["embedding"] for item in data]
|
|
214
|
+
self.full_result_data["parsed_result"] = data
|
|
208
215
|
if self.settings.get("$log.cancel_logs") is not True:
|
|
209
216
|
await async_system_message(
|
|
210
217
|
"MODEL_REQUEST",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from agently.utils import LazyImport
|
|
2
|
+
|
|
3
|
+
LazyImport.import_package("chromadb")
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
from chromadb.api.types import EmbeddingFunction, Documents, Embedding, Embeddings
|
|
8
|
+
|
|
9
|
+
from typing import Callable, TypedDict, Any, cast
|
|
10
|
+
from agently.core import BaseAgent
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ChromaDataDictOptional(TypedDict, total=False):
|
|
14
|
+
metadata: dict[Any, Any]
|
|
15
|
+
id: Any
|
|
16
|
+
embedding: Embedding
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ChromaDataDict(ChromaDataDictOptional):
|
|
20
|
+
document: str
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ChromaData:
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
original_data: ChromaDataDict | list[ChromaDataDict],
|
|
27
|
+
*,
|
|
28
|
+
embedding_function: Callable[[str | list[str]], Embeddings] | None = None,
|
|
29
|
+
agent: BaseAgent | None = None,
|
|
30
|
+
):
|
|
31
|
+
self._original_data = original_data if isinstance(original_data, list) else [original_data]
|
|
32
|
+
if embedding_function:
|
|
33
|
+
self._embedding_function = embedding_function
|
|
34
|
+
elif agent:
|
|
35
|
+
|
|
36
|
+
def embedding_function_by_agent(texts: str | list[str]) -> Embeddings:
|
|
37
|
+
return agent.input(texts).start()
|
|
38
|
+
|
|
39
|
+
self._embedding_function = embedding_function_by_agent
|
|
40
|
+
else:
|
|
41
|
+
self._embedding_function = None
|
|
42
|
+
self._chroma_data = {
|
|
43
|
+
"documents": [],
|
|
44
|
+
"metadatas": [],
|
|
45
|
+
"ids": [],
|
|
46
|
+
"embeddings": [],
|
|
47
|
+
}
|
|
48
|
+
if self._embedding_function is not None:
|
|
49
|
+
documents = [data["document"] for data in self._original_data]
|
|
50
|
+
embeddings = self._embedding_function(documents)
|
|
51
|
+
self._chroma_data["embeddings"] = embeddings
|
|
52
|
+
for index, data in enumerate(self._original_data):
|
|
53
|
+
data["embedding"] = embeddings[index]
|
|
54
|
+
else:
|
|
55
|
+
del self._chroma_data["embeddings"]
|
|
56
|
+
for index, data in enumerate(self._original_data):
|
|
57
|
+
self._chroma_data["documents"].append(data["document"])
|
|
58
|
+
self._chroma_data["metadatas"].append(data["metadata"] if "metadata" in data else None)
|
|
59
|
+
self._chroma_data["ids"].append(data["id"] if "id" in data else str(index))
|
|
60
|
+
|
|
61
|
+
def get_kwargs(self):
|
|
62
|
+
return self._chroma_data
|
|
63
|
+
|
|
64
|
+
def get_original_data(self):
|
|
65
|
+
return self._original_data
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ChromaEmbeddingFunction(EmbeddingFunction):
|
|
69
|
+
def __init__(
|
|
70
|
+
self, *, embedding_function: Callable[[list[str]], Embeddings] | None = None, agent: BaseAgent | None = None
|
|
71
|
+
):
|
|
72
|
+
if embedding_function:
|
|
73
|
+
self.embedding_function = embedding_function
|
|
74
|
+
elif agent:
|
|
75
|
+
|
|
76
|
+
def embedding_function_by_agent(texts: list[str]) -> Embeddings:
|
|
77
|
+
return agent.input(texts).start()
|
|
78
|
+
|
|
79
|
+
self.embedding_function = embedding_function_by_agent
|
|
80
|
+
else:
|
|
81
|
+
raise ValueError(
|
|
82
|
+
f"ChromaEmbeddingFunction() requires at least one definition for 'embedding_function' or 'agent'."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def __call__(self, documents: Documents) -> Embeddings:
|
|
86
|
+
return self.embedding_function([document for document in documents])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/ChatSessionExtension.py
RENAMED
|
File without changes
|
{agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/agent_extensions/ConfigurePromptExtension.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agently-4.0.5.5 → agently-4.0.5.6}/agently/builtins/plugins/ToolManager/AgentlyToolManager.py
RENAMED
|
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
|
|
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
|
|
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
|
|
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
|