alita-sdk 0.3.126__py3-none-any.whl → 0.3.127__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/langraph_agent.py +35 -3
- alita_sdk/tools/tool.py +8 -2
- {alita_sdk-0.3.126.dist-info → alita_sdk-0.3.127.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.126.dist-info → alita_sdk-0.3.127.dist-info}/RECORD +7 -7
- {alita_sdk-0.3.126.dist-info → alita_sdk-0.3.127.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.126.dist-info → alita_sdk-0.3.127.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.126.dist-info → alita_sdk-0.3.127.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,7 @@ from uuid import uuid4
|
|
4
4
|
from typing import Dict
|
5
5
|
|
6
6
|
import yaml
|
7
|
+
import ast
|
7
8
|
from langchain_core.callbacks import dispatch_custom_event
|
8
9
|
from langchain_core.messages import HumanMessage
|
9
10
|
from langchain_core.runnables import Runnable
|
@@ -211,6 +212,25 @@ class TransitionalEdge(Runnable):
|
|
211
212
|
)
|
212
213
|
return self.next_step if self.next_step != 'END' else END
|
213
214
|
|
215
|
+
class StateDefaultNode(Runnable):
|
216
|
+
name = "StateDefaultNode"
|
217
|
+
|
218
|
+
def __init__(self, default_vars: dict = {}):
|
219
|
+
self.default_vars = default_vars
|
220
|
+
|
221
|
+
def invoke(self, state: BaseStore, config: Optional[RunnableConfig] = None) -> dict:
|
222
|
+
logger.info("Setting default state variables")
|
223
|
+
result = {}
|
224
|
+
for key, value in self.default_vars.items():
|
225
|
+
if isinstance(value, dict) and 'value' in value:
|
226
|
+
temp_value = value['value']
|
227
|
+
try:
|
228
|
+
result[key] = ast.literal_eval(temp_value)
|
229
|
+
except:
|
230
|
+
logger.debug("Unable to evaluate value, using as is")
|
231
|
+
result[key] = temp_value
|
232
|
+
return result
|
233
|
+
|
214
234
|
|
215
235
|
class StateModifierNode(Runnable):
|
216
236
|
name = "StateModifierNode"
|
@@ -353,7 +373,8 @@ def create_graph(
|
|
353
373
|
logger.debug(f"Schema: {schema}")
|
354
374
|
logger.debug(f"Tools: {tools}")
|
355
375
|
logger.info(f"Tools: {[tool.name for tool in tools]}")
|
356
|
-
|
376
|
+
state = schema.get('state', {})
|
377
|
+
state_class = create_state(state)
|
357
378
|
lg_builder = StateGraph(state_class)
|
358
379
|
interrupt_before = [clean_string(every) for every in schema.get('interrupt_before', [])]
|
359
380
|
interrupt_after = [clean_string(every) for every in schema.get('interrupt_after', [])]
|
@@ -503,9 +524,20 @@ def create_graph(
|
|
503
524
|
conditional_outputs=node['condition'].get('conditional_outputs', []),
|
504
525
|
default_output=node['condition'].get('default_output', 'END')))
|
505
526
|
|
506
|
-
|
527
|
+
# set default value for state variable at START
|
528
|
+
entry_point = clean_string(schema['entry_point'])
|
529
|
+
for key, value in state.items():
|
530
|
+
if 'type' in value and 'value' in value:
|
531
|
+
# set default value for state variable if it is defined in the schema
|
532
|
+
state_default_node = StateDefaultNode(default_vars=state)
|
533
|
+
lg_builder.add_node(state_default_node.name, state_default_node)
|
534
|
+
lg_builder.set_entry_point(state_default_node.name)
|
535
|
+
lg_builder.add_conditional_edges(state_default_node.name, TransitionalEdge(entry_point))
|
536
|
+
break
|
537
|
+
else:
|
538
|
+
# if no state variables are defined, set the entry point directly
|
539
|
+
lg_builder.set_entry_point(entry_point)
|
507
540
|
|
508
|
-
# assign default values
|
509
541
|
interrupt_before = interrupt_before or []
|
510
542
|
interrupt_after = interrupt_after or []
|
511
543
|
|
alita_sdk/tools/tool.py
CHANGED
@@ -10,6 +10,7 @@ from langchain_core.tools import BaseTool
|
|
10
10
|
from langchain_core.utils.function_calling import convert_to_openai_tool
|
11
11
|
from pydantic import ValidationError, BaseModel, create_model
|
12
12
|
|
13
|
+
from .application import Application
|
13
14
|
from ..langchain.utils import _extract_json
|
14
15
|
|
15
16
|
logger = logging.getLogger(__name__)
|
@@ -74,8 +75,9 @@ Anwer must be JSON only extractable by JSON.LOADS."""
|
|
74
75
|
))
|
75
76
|
]
|
76
77
|
if self.structured_output:
|
77
|
-
# cut defaults from schema
|
78
|
-
fields = {name: (field.annotation, ...) for name, field
|
78
|
+
# cut defaults from schema and remove chat_history for application as a tool
|
79
|
+
fields = {name: (field.annotation, ...) for name, field
|
80
|
+
in self.tool.args_schema.model_fields.items() if name != 'chat_history'}
|
79
81
|
input_schema = create_model('NewModel', **fields)
|
80
82
|
|
81
83
|
llm = self.client.with_structured_output(input_schema)
|
@@ -87,6 +89,10 @@ Anwer must be JSON only extractable by JSON.LOADS."""
|
|
87
89
|
result = _extract_json(completion.content.strip())
|
88
90
|
logger.info(f"ToolNode tool params: {result}")
|
89
91
|
try:
|
92
|
+
# handler for application added as a tool
|
93
|
+
if isinstance(self.tool, Application):
|
94
|
+
# set empty chat history
|
95
|
+
result['chat_history'] = None
|
90
96
|
tool_result = self.tool.invoke(result, config=config, kwargs=kwargs)
|
91
97
|
dispatch_custom_event(
|
92
98
|
"on_tool_node", {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: alita_sdk
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.127
|
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=J_xhwbNl934BgDKSpAMC9a1u6v03DZQcTYaamCzt
|
|
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=PrD_9XEX7_LDOT_SuohW_nhqLMlzc14xmByHPrO0V6E,37951
|
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
|
@@ -85,7 +85,7 @@ alita_sdk/tools/mcp_server_tool.py,sha256=xcH9AiqfR2TYrwJ3Ixw-_A7XDodtJCnwmq1Ssi
|
|
85
85
|
alita_sdk/tools/pgvector_search.py,sha256=NN2BGAnq4SsDHIhUcFZ8d_dbEOM8QwB0UwpsWCYruXU,11692
|
86
86
|
alita_sdk/tools/prompt.py,sha256=nJafb_e5aOM1Rr3qGFCR-SKziU9uCsiP2okIMs9PppM,741
|
87
87
|
alita_sdk/tools/router.py,sha256=wCvZjVkdXK9dMMeEerrgKf5M790RudH68pDortnHSz0,1517
|
88
|
-
alita_sdk/tools/tool.py,sha256=
|
88
|
+
alita_sdk/tools/tool.py,sha256=f2ULDU4PU4PlLgygT_lsInLgNROJeWUNXLe0i0uOcqI,5419
|
89
89
|
alita_sdk/tools/vectorstore.py,sha256=F-DoHxPa4UVsKB-FEd-wWa59QGQifKMwcSNcZ5WZOKc,23496
|
90
90
|
alita_sdk/utils/AlitaCallback.py,sha256=cvpDhR4QLVCNQci6CO6TEUrUVDZU9_CRSwzcHGm3SGw,7356
|
91
91
|
alita_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -93,10 +93,10 @@ alita_sdk/utils/evaluate.py,sha256=iM1P8gzBLHTuSCe85_Ng_h30m52hFuGuhNXJ7kB1tgI,1
|
|
93
93
|
alita_sdk/utils/logging.py,sha256=hBE3qAzmcLMdamMp2YRXwOOK9P4lmNaNhM76kntVljs,3124
|
94
94
|
alita_sdk/utils/streamlit.py,sha256=zp8owZwHI3HZplhcExJf6R3-APtWx-z6s5jznT2hY_k,29124
|
95
95
|
alita_sdk/utils/utils.py,sha256=dM8whOJAuFJFe19qJ69-FLzrUp6d2G-G6L7d4ss2XqM,346
|
96
|
-
alita_sdk-0.3.
|
96
|
+
alita_sdk-0.3.127.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
97
97
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
98
98
|
tests/test_jira_analysis.py,sha256=I0cErH5R_dHVyutpXrM1QEo7jfBuKWTmDQvJBPjx18I,3281
|
99
|
-
alita_sdk-0.3.
|
100
|
-
alita_sdk-0.3.
|
101
|
-
alita_sdk-0.3.
|
102
|
-
alita_sdk-0.3.
|
99
|
+
alita_sdk-0.3.127.dist-info/METADATA,sha256=Ox_VkvvGHqTNfe_wFqkVXU0etHQmW92EziEoEM5D158,7075
|
100
|
+
alita_sdk-0.3.127.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
101
|
+
alita_sdk-0.3.127.dist-info/top_level.txt,sha256=SWRhxB7Et3cOy3RkE5hR7OIRnHoo3K8EXzoiNlkfOmc,25
|
102
|
+
alita_sdk-0.3.127.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|