alita-sdk 0.3.179__py3-none-any.whl → 0.3.180__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.
@@ -186,37 +186,44 @@ class Assistant:
186
186
  Create a LangGraph agent with auto-continue capability for when responses get truncated.
187
187
  This provides better handling of length-limited responses compared to traditional AgentExecutor.
188
188
  Uses simple in-memory checkpointing for auto-continue functionality.
189
+
190
+ Note: Requires LangGraph 0.5.x or higher that supports post_model_hook.
189
191
  """
192
+
190
193
  from langgraph.prebuilt import create_react_agent
191
194
  from langgraph.checkpoint.memory import MemorySaver
192
-
195
+
193
196
  # Use simple in-memory checkpointer for auto-continue functionality
194
- # This ensures clean, predictable behavior for continuation logic
195
197
  memory = MemorySaver()
196
198
 
197
199
  # Filter tools to only include BaseTool instances
198
200
  simple_tools = [t for t in self.tools if isinstance(t, BaseTool)]
199
201
 
200
- # Create the agent with checkpointing enabled
201
- agent = create_react_agent(
202
- prompt=self.prompt,
203
- model=self.client,
204
- tools=simple_tools,
205
- checkpointer=memory,
206
- state_modifier=self._create_auto_continue_state_modifier()
207
- )
208
-
202
+ # Set up parameters for the agent
203
+ kwargs = {
204
+ "prompt": self.prompt,
205
+ "model": self.client,
206
+ "tools": simple_tools,
207
+ "checkpointer": memory,
208
+ "post_model_hook": self._create_auto_continue_hook() # Auto-continue hook
209
+ }
210
+
211
+ # Create the agent with the new hook-based API
212
+ agent = create_react_agent(**kwargs)
209
213
  return agent
210
214
 
211
- def _create_auto_continue_state_modifier(self):
215
+ # The state_modifier approach has been removed in favor of post_model_hook which
216
+ # is the recommended approach for LangGraph 0.5.x and higher
217
+
218
+ def _create_auto_continue_hook(self):
212
219
  """
213
- Create a state modifier that implements auto-continue logic.
214
- This checks if the last AI response was truncated and automatically continues if needed.
215
- Limits auto-continue to prevent infinite loops.
220
+ Create a post-model hook for LangGraph 0.5.x that detects truncated responses
221
+ and adds continuation prompts.
222
+ This checks if the last AI message was truncated and automatically continues if needed.
216
223
  """
217
224
  MAX_CONTINUATIONS = 3 # Maximum number of auto-continuations allowed
218
225
 
219
- def auto_continue_modifier(state):
226
+ def post_model_hook(state):
220
227
  messages = state.get("messages", [])
221
228
 
222
229
  # Count how many auto-continue messages we've already sent
@@ -229,8 +236,8 @@ class Assistant:
229
236
  # Don't continue if we've reached the limit
230
237
  if continuation_count >= MAX_CONTINUATIONS:
231
238
  return state
232
-
233
- # Check if the last AI message was truncated
239
+
240
+ # Check if the last message is from AI and was truncated
234
241
  if messages and isinstance(messages[-1], AIMessage):
235
242
  last_ai_message = messages[-1]
236
243
 
@@ -244,17 +251,13 @@ class Assistant:
244
251
  not last_ai_message.content.rstrip().endswith(('.', '!', '?', ':', ';'))
245
252
  )
246
253
 
247
- # Add continuation logic
254
+ # Add continuation request if truncated
248
255
  if is_truncated:
249
- # Add a human message to continue
250
- continuation_msg = HumanMessage(
251
- content="Continue your previous response from where you left off"
252
- )
253
- return {
254
- **state,
255
- "messages": messages + [continuation_msg]
256
- }
256
+ logger.info("Detected truncated response, adding continuation request")
257
+ new_messages = messages.copy()
258
+ new_messages.append(HumanMessage(content="Continue your previous response from where you left off"))
259
+ return {"messages": new_messages}
257
260
 
258
261
  return state
259
-
260
- return auto_continue_modifier
262
+
263
+ return post_model_hook
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.179
3
+ Version: 0.3.180
4
4
  Summary: SDK for building langchain agents using resources 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>, Artem Dubrovskiy <ad13box@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -17,7 +17,7 @@ alita_sdk/runtime/clients/client.py,sha256=6ezOJ92CSw6b2PVs4uFMQKQdp40uT1awoFEqW
17
17
  alita_sdk/runtime/clients/datasource.py,sha256=HAZovoQN9jBg0_-lIlGBQzb4FJdczPhkHehAiVG3Wx0,1020
18
18
  alita_sdk/runtime/clients/prompt.py,sha256=li1RG9eBwgNK_Qf0qUaZ8QNTmsncFrAL2pv3kbxZRZg,1447
19
19
  alita_sdk/runtime/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- alita_sdk/runtime/langchain/assistant.py,sha256=VE6Gq7O1ErJV0eTHgM-7TOxdATd62aFimUKprz92o-I,11526
20
+ alita_sdk/runtime/langchain/assistant.py,sha256=eY36htHBvB7n0sW4cr79HZ-FsTh-rQIQga66th_Tpe0,11759
21
21
  alita_sdk/runtime/langchain/chat_message_template.py,sha256=kPz8W2BG6IMyITFDA5oeb5BxVRkHEVZhuiGl4MBZKdc,2176
22
22
  alita_sdk/runtime/langchain/constants.py,sha256=eHVJ_beJNTf1WJo4yq7KMK64fxsRvs3lKc34QCXSbpk,3319
23
23
  alita_sdk/runtime/langchain/indexer.py,sha256=0ENHy5EOhThnAiYFc7QAsaTNp9rr8hDV_hTK8ahbatk,37592
@@ -295,8 +295,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=UHVQUVqcBc3SZvDfO78HSuBzwAsRw
295
295
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=rq4jOb3lRW2GXvAguk4H1KinO5f-zpygzhBJf-E1Ucw,2773
296
296
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=iOMxyE7vOc_LwFB_nBMiSFXkNtvbptA4i-BrTlo7M0A,5854
297
297
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=IYUJoMFOMA70knLhLtAnuGoy3OK80RuqeQZ710oyIxE,3631
298
- alita_sdk-0.3.179.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
299
- alita_sdk-0.3.179.dist-info/METADATA,sha256=GkBo37E1OM9ej52nimuYYnsfys22QnRSuuR4rDutZgg,18753
300
- alita_sdk-0.3.179.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
301
- alita_sdk-0.3.179.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
302
- alita_sdk-0.3.179.dist-info/RECORD,,
298
+ alita_sdk-0.3.180.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
299
+ alita_sdk-0.3.180.dist-info/METADATA,sha256=1_Zfqgg2jYnpzujyCog3Z8_bNx07CjpO1ZjHGqlWzLE,18753
300
+ alita_sdk-0.3.180.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
301
+ alita_sdk-0.3.180.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
302
+ alita_sdk-0.3.180.dist-info/RECORD,,