alita-sdk 0.3.122__py3-none-any.whl → 0.3.123__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.
- alita_sdk/langchain/interfaces/llm_processor.py +7 -0
- alita_sdk/langchain/langraph_agent.py +8 -2
- alita_sdk/tools/function.py +2 -3
- alita_sdk/tools/llm.py +10 -1
- {alita_sdk-0.3.122.dist-info → alita_sdk-0.3.123.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.122.dist-info → alita_sdk-0.3.123.dist-info}/RECORD +9 -9
- {alita_sdk-0.3.122.dist-info → alita_sdk-0.3.123.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.122.dist-info → alita_sdk-0.3.123.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.122.dist-info → alita_sdk-0.3.123.dist-info}/top_level.txt +0 -0
@@ -13,6 +13,7 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
import importlib
|
16
|
+
from json import dumps
|
16
17
|
from traceback import format_exc
|
17
18
|
from langchain.chains.llm import LLMChain
|
18
19
|
|
@@ -33,6 +34,7 @@ from ..retrievers.AlitaRetriever import AlitaRetriever
|
|
33
34
|
from ..tools.log import print_log
|
34
35
|
|
35
36
|
|
37
|
+
|
36
38
|
def get_model(model_type: str, model_params: dict):
|
37
39
|
""" Get LLM or ChatLLM """
|
38
40
|
if model_type is None:
|
@@ -181,6 +183,11 @@ def add_documents(vectorstore, documents):
|
|
181
183
|
metadata = []
|
182
184
|
for document in documents:
|
183
185
|
texts.append(document.page_content)
|
186
|
+
for key in document.metadata:
|
187
|
+
if isinstance(document.metadata[key], list):
|
188
|
+
document.metadata[key] = "; ".join(document.metadata[key])
|
189
|
+
if isinstance(document.metadata[key], dict):
|
190
|
+
document.metadata[key] = dumps(document.metadata[key])
|
184
191
|
metadata.append(document.metadata)
|
185
192
|
vectorstore.add_texts(texts, metadatas=metadata)
|
186
193
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import logging
|
2
|
-
from typing import Union, Any, Optional, Annotated
|
2
|
+
from typing import Union, Any, Optional, Annotated, get_type_hints
|
3
3
|
from uuid import uuid4
|
4
4
|
|
5
5
|
import yaml
|
@@ -329,11 +329,17 @@ def create_graph(
|
|
329
329
|
structured_output=node.get('structured_output', False)))
|
330
330
|
break
|
331
331
|
elif node_type == 'llm':
|
332
|
+
output_vars = node.get('output', [])
|
333
|
+
output_vars_dict = {
|
334
|
+
var: get_type_hints(state_class).get(var, str).__name__
|
335
|
+
for var in output_vars
|
336
|
+
}
|
332
337
|
lg_builder.add_node(node_id, LLMNode(
|
333
338
|
client=client, prompt=node.get('prompt', {}),
|
334
339
|
name=node['id'], return_type='dict',
|
335
340
|
response_key=node.get('response_key', 'messages'),
|
336
|
-
|
341
|
+
structured_output_dict=output_vars_dict,
|
342
|
+
output_variables=output_vars,
|
337
343
|
input_variables=node.get('input', ['messages']),
|
338
344
|
structured_output=node.get('structured_output', False)))
|
339
345
|
elif node_type == 'router':
|
alita_sdk/tools/function.py
CHANGED
@@ -47,11 +47,10 @@ class FunctionTool(BaseTool):
|
|
47
47
|
)
|
48
48
|
logger.info(f"ToolNode response: {tool_result}")
|
49
49
|
if not self.output_variables:
|
50
|
-
return {"messages": [{"role": "assistant", "content": tool_result}]}
|
50
|
+
return {"messages": [{"role": "assistant", "content": dumps(tool_result)}]}
|
51
51
|
else:
|
52
52
|
return {
|
53
|
-
self.output_variables[0]: tool_result
|
54
|
-
"messages": [{"role": "assistant", "content": tool_result}]
|
53
|
+
self.output_variables[0]: tool_result
|
55
54
|
}
|
56
55
|
except ValidationError:
|
57
56
|
return {"messages": [
|
alita_sdk/tools/llm.py
CHANGED
@@ -25,6 +25,7 @@ class LLMNode(BaseTool):
|
|
25
25
|
client: Any = None
|
26
26
|
return_type: str = "str"
|
27
27
|
response_key: str = "messages"
|
28
|
+
structured_output_dict: Optional[dict[str, str]] = None
|
28
29
|
output_variables: Optional[List[str]] = None
|
29
30
|
input_variables: Optional[List[str]] = None
|
30
31
|
structured_output: Optional[bool] = False
|
@@ -35,11 +36,19 @@ class LLMNode(BaseTool):
|
|
35
36
|
llm_input = create_llm_input(self.prompt, params, kwargs)
|
36
37
|
try:
|
37
38
|
if self.structured_output and len(self.output_variables) > 0:
|
38
|
-
struct_params = {
|
39
|
+
struct_params = {
|
40
|
+
key: {
|
41
|
+
"type": 'list[str]' if 'list' in value else value,
|
42
|
+
"description": ""
|
43
|
+
}
|
44
|
+
for key, value in (self.structured_output_dict or {}).items()
|
45
|
+
}
|
39
46
|
stuct_model = create_pydantic_model(f"LLMOutput", struct_params)
|
40
47
|
llm = self.client.with_structured_output(stuct_model)
|
41
48
|
completion = llm.invoke(llm_input)
|
42
49
|
result = completion.model_dump()
|
50
|
+
if result.get('messages') and isinstance(result['messages'], list):
|
51
|
+
result['messages'] = [{'role': 'assistant', 'content': '\n'.join(result['messages'])}]
|
43
52
|
return result
|
44
53
|
else:
|
45
54
|
completion = self.client.invoke(llm_input)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: alita_sdk
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.123
|
4
4
|
Summary: SDK for building langchain agents using resouces from Alita
|
5
5
|
Author-email: Artem Rozumenko <artyom.rozumenko@gmail.com>, Mikalai Biazruchka <mikalai_biazruchka@epam.com>, Roman Mitusov <roman_mitusov@epam.com>, Ivan Krakhmaliuk <lifedjik@gmail.com>
|
6
6
|
Project-URL: Homepage, https://projectalita.ai
|
@@ -19,7 +19,7 @@ alita_sdk/langchain/assistant.py,sha256=V0MpZG9IQRlKMr1SfAabVbUsIp-gNPO9A1SWxuFi
|
|
19
19
|
alita_sdk/langchain/chat_message_template.py,sha256=kPz8W2BG6IMyITFDA5oeb5BxVRkHEVZhuiGl4MBZKdc,2176
|
20
20
|
alita_sdk/langchain/constants.py,sha256=eHVJ_beJNTf1WJo4yq7KMK64fxsRvs3lKc34QCXSbpk,3319
|
21
21
|
alita_sdk/langchain/indexer.py,sha256=0ENHy5EOhThnAiYFc7QAsaTNp9rr8hDV_hTK8ahbatk,37592
|
22
|
-
alita_sdk/langchain/langraph_agent.py,sha256=
|
22
|
+
alita_sdk/langchain/langraph_agent.py,sha256=f9rGk6QGQbfbGudwpM5ax9yS-xDlElFqGAOsZbGvrtI,20919
|
23
23
|
alita_sdk/langchain/mixedAgentParser.py,sha256=M256lvtsL3YtYflBCEp-rWKrKtcY1dJIyRGVv7KW9ME,2611
|
24
24
|
alita_sdk/langchain/mixedAgentRenderes.py,sha256=asBtKqm88QhZRILditjYICwFVKF5KfO38hu2O-WrSWE,5964
|
25
25
|
alita_sdk/langchain/utils.py,sha256=Npferkn10dvdksnKzLJLBI5bNGQyVWTBwqp3vQtUqmY,6631
|
@@ -41,7 +41,7 @@ alita_sdk/langchain/document_loaders/constants.py,sha256=QpgMiKo-riIBuU67DGhXi7Z
|
|
41
41
|
alita_sdk/langchain/document_loaders/utils.py,sha256=ifh0UJiweIb2iEb2_THJy2pbAnTupOffGtTdRA7vjeE,874
|
42
42
|
alita_sdk/langchain/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
43
|
alita_sdk/langchain/interfaces/kwextractor.py,sha256=kSJA9L8g8UArmHu7Bd9dIO0Rrq86JPUb8RYNlnN68FQ,3072
|
44
|
-
alita_sdk/langchain/interfaces/llm_processor.py,sha256=
|
44
|
+
alita_sdk/langchain/interfaces/llm_processor.py,sha256=AbuWlZ54Cu5zy6AExRN0ou3r15i4pY3WSIVPJx8ltkA,8764
|
45
45
|
alita_sdk/langchain/interfaces/loaders.py,sha256=li-O2dubiDNYn-qfVcDsuD4LqP_IZ61cV2vHUZAqeXc,3337
|
46
46
|
alita_sdk/langchain/interfaces/splitters.py,sha256=tW65-Ejj9VYyxXFZNgPts_CKILQ18bWp_1bZ-24FKGc,3630
|
47
47
|
alita_sdk/langchain/retrievers/AlitaRetriever.py,sha256=osChtJxUlfpsFESpJSE5mnJAkxTXnzgFZnC6l5mUlbo,6148
|
@@ -75,9 +75,9 @@ alita_sdk/tools/application.py,sha256=UJlYd3Sub10LpAoKkKEpvd4miWyrS-yYE5NKyqx-H4
|
|
75
75
|
alita_sdk/tools/artifact.py,sha256=uTa6K5d-NCDRnuLJVd6vA5TNIPH39onyPIyW5Thz4C0,6160
|
76
76
|
alita_sdk/tools/datasource.py,sha256=pvbaSfI-ThQQnjHG-QhYNSTYRnZB0rYtZFpjCfpzxYI,2443
|
77
77
|
alita_sdk/tools/echo.py,sha256=spw9eCweXzixJqHnZofHE1yWiSUa04L4VKycf3KCEaM,486
|
78
|
-
alita_sdk/tools/function.py,sha256=
|
78
|
+
alita_sdk/tools/function.py,sha256=wzPS5Y8ScmsXspmn73MQnkCcAghsllAg7BLh61ZNuVw,2543
|
79
79
|
alita_sdk/tools/indexer_tool.py,sha256=P9S_omk5TZkizb6UXyxMO87Pzj4UCaye0CuXBgCnhTU,4258
|
80
|
-
alita_sdk/tools/llm.py,sha256=
|
80
|
+
alita_sdk/tools/llm.py,sha256=JA0OnSU13CLdkS5NFv6iRk8P7k-B47L-oPjk8xrzk48,3223
|
81
81
|
alita_sdk/tools/loop.py,sha256=uds0WhZvwMxDVFI6MZHrcmMle637cQfBNg682iLxoJA,8335
|
82
82
|
alita_sdk/tools/loop_output.py,sha256=NoGIGYc42wY3NNcWRijYzRnUVXcCn5cRVd8QmuIpoHU,8068
|
83
83
|
alita_sdk/tools/pgvector_search.py,sha256=NN2BGAnq4SsDHIhUcFZ8d_dbEOM8QwB0UwpsWCYruXU,11692
|
@@ -91,10 +91,10 @@ alita_sdk/utils/evaluate.py,sha256=iM1P8gzBLHTuSCe85_Ng_h30m52hFuGuhNXJ7kB1tgI,1
|
|
91
91
|
alita_sdk/utils/logging.py,sha256=hBE3qAzmcLMdamMp2YRXwOOK9P4lmNaNhM76kntVljs,3124
|
92
92
|
alita_sdk/utils/streamlit.py,sha256=zp8owZwHI3HZplhcExJf6R3-APtWx-z6s5jznT2hY_k,29124
|
93
93
|
alita_sdk/utils/utils.py,sha256=dM8whOJAuFJFe19qJ69-FLzrUp6d2G-G6L7d4ss2XqM,346
|
94
|
-
alita_sdk-0.3.
|
94
|
+
alita_sdk-0.3.123.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
95
95
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
96
96
|
tests/test_jira_analysis.py,sha256=I0cErH5R_dHVyutpXrM1QEo7jfBuKWTmDQvJBPjx18I,3281
|
97
|
-
alita_sdk-0.3.
|
98
|
-
alita_sdk-0.3.
|
99
|
-
alita_sdk-0.3.
|
100
|
-
alita_sdk-0.3.
|
97
|
+
alita_sdk-0.3.123.dist-info/METADATA,sha256=UBv__Ag0bAjUYgjkYIE3pjx2tzIWlSfHZSc-XxiaFkg,7075
|
98
|
+
alita_sdk-0.3.123.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
99
|
+
alita_sdk-0.3.123.dist-info/top_level.txt,sha256=SWRhxB7Et3cOy3RkE5hR7OIRnHoo3K8EXzoiNlkfOmc,25
|
100
|
+
alita_sdk-0.3.123.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|