langroid 0.50.7__py3-none-any.whl → 0.50.9__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.
@@ -92,8 +92,8 @@ class ChatAgentConfig(AgentConfig):
92
92
  system_message: str = "You are a helpful assistant."
93
93
  user_message: Optional[str] = None
94
94
  handle_llm_no_tool: Any = None
95
- use_tools: bool = False
96
- use_functions_api: bool = True
95
+ use_tools: bool = True
96
+ use_functions_api: bool = False
97
97
  use_tools_api: bool = True
98
98
  strict_recovery: bool = True
99
99
  enable_orchestration_tool_handling: bool = True
@@ -105,33 +105,22 @@ class ChatAgentConfig(AgentConfig):
105
105
  use_tools_on_output_format: bool = True
106
106
  full_citations: bool = True # show source + content for each citation?
107
107
 
108
- def _set_fn_or_tools(self, fn_available: bool) -> None:
108
+ def _set_fn_or_tools(self) -> None:
109
109
  """
110
110
  Enable Langroid Tool or OpenAI-like fn-calling,
111
- depending on config settings and availability of fn-calling.
111
+ depending on config settings.
112
112
  """
113
- if self.use_functions_api and not fn_available:
114
- logger.debug(
115
- """
116
- You have enabled `use_functions_api` but the LLM does not support it.
117
- So we will enable `use_tools` instead, so we can use
118
- Langroid's ToolMessage mechanism.
119
- """
120
- )
121
- self.use_functions_api = False
122
- self.use_tools = True
123
-
124
113
  if not self.use_functions_api or not self.use_tools:
125
114
  return
126
115
  if self.use_functions_api and self.use_tools:
127
116
  logger.debug(
128
117
  """
129
118
  You have enabled both `use_tools` and `use_functions_api`.
130
- Turning off `use_tools`, since the LLM supports function-calling.
119
+ Setting `use_functions_api` to False.
131
120
  """
132
121
  )
133
- self.use_tools = False
134
- self.use_functions_api = True
122
+ self.use_tools = True
123
+ self.use_functions_api = False
135
124
 
136
125
 
137
126
  class ChatAgent(Agent):
@@ -163,7 +152,7 @@ class ChatAgent(Agent):
163
152
  """
164
153
  super().__init__(config)
165
154
  self.config: ChatAgentConfig = config
166
- self.config._set_fn_or_tools(self._fn_call_available())
155
+ self.config._set_fn_or_tools()
167
156
  self.message_history: List[LLMMessage] = []
168
157
  self.init_state()
169
158
  # An agent's "task" is defined by a system msg and an optional user msg;
@@ -59,6 +59,18 @@ def retry_with_exponential_backoff(
59
59
 
60
60
  # Retry on specified errors
61
61
  except errors as e:
62
+
63
+ # For certain types of errors that slip through here
64
+ # (e.g. when using proxies like LiteLLM, do not retry)
65
+ if any(
66
+ err in str(e)
67
+ for err in [
68
+ "BadRequestError",
69
+ "ConnectionError",
70
+ ]
71
+ ):
72
+ logger.error(f"OpenAI API request failed with error: {e}.")
73
+ raise e
62
74
  # Increment retries
63
75
  num_retries += 1
64
76
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.50.7
3
+ Version: 0.50.9
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -5,7 +5,7 @@ langroid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
6
6
  langroid/agent/base.py,sha256=bs5OLCf534mhsdR7Rgf27GqVNuSV2bOVbD46Y86mGFA,79829
7
7
  langroid/agent/batch.py,sha256=vi1r5i1-vN80WfqHDSwjEym_KfGsqPGUtwktmiK1nuk,20635
8
- langroid/agent/chat_agent.py,sha256=m1alf-KNJSU6PeFF6ocwTHSG0cmTE-iy1o7UYAvRGQE,85081
8
+ langroid/agent/chat_agent.py,sha256=BBXGx4nYUG4xgeRGoT4HmVJ9lVi6E3kPt0YYBW52e3E,84557
9
9
  langroid/agent/chat_document.py,sha256=gWceR8mcggyGbJePJQgVvqzVivYlfPlFp8pUZ7yUZvg,17821
10
10
  langroid/agent/openai_assistant.py,sha256=JkAcs02bIrgPNVvUWVR06VCthc5-ulla2QMBzux_q6o,34340
11
11
  langroid/agent/task.py,sha256=HB6N-Jn80HFqCf0ZYOC1v3Bn3oO7NLjShHQJJFwW0q4,90557
@@ -74,7 +74,7 @@ langroid/language_models/config.py,sha256=9Q8wk5a7RQr8LGMT_0WkpjY8S4ywK06SalVRjX
74
74
  langroid/language_models/mock_lm.py,sha256=5BgHKDVRWFbUwDT_PFgTZXz9-k8wJSA2e3PZmyDgQ1k,4022
75
75
  langroid/language_models/model_info.py,sha256=tfBBxL0iUf2mVN6CjcvqflzFUVg2oZqOJZexZ8jHTYA,12216
76
76
  langroid/language_models/openai_gpt.py,sha256=t5oFJFxfm0ZwbD5kS73TY8Hal6aCFUWX7O7dBZc-7fw,84480
77
- langroid/language_models/utils.py,sha256=L4_CbihDMTGcsg0TOG1Yd5JFEto46--h7CX_14m89sQ,5016
77
+ langroid/language_models/utils.py,sha256=hC5p61P_Qlrowkm5wMap1A1b5ZUCwK_XhPIzAQk1T1s,5483
78
78
  langroid/language_models/prompt_formatter/__init__.py,sha256=2-5cdE24XoFDhifOLl8yiscohil1ogbP1ECkYdBlBsk,372
79
79
  langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
80
80
  langroid/language_models/prompt_formatter/hf_formatter.py,sha256=PVJppmjRvD-2DF-XNC6mE05vTZ9wbu37SmXwZBQhad0,5055
@@ -129,7 +129,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
129
129
  langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
130
130
  langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
131
131
  langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
132
- langroid-0.50.7.dist-info/METADATA,sha256=Am8GortMmvBBtL6aMTS88xmzYCa3ywMFEgraPvNYsTQ,63641
133
- langroid-0.50.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
134
- langroid-0.50.7.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
135
- langroid-0.50.7.dist-info/RECORD,,
132
+ langroid-0.50.9.dist-info/METADATA,sha256=51zKXzdMlaWzOJAcz-8zmz78Kmqj_lXmEQ03LnMSOgc,63641
133
+ langroid-0.50.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
134
+ langroid-0.50.9.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
135
+ langroid-0.50.9.dist-info/RECORD,,