langroid 0.1.205__py3-none-any.whl → 0.1.207__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.
@@ -60,6 +60,7 @@ else:
60
60
  OLLAMA_BASE_URL = "http://localhost:11434/v1"
61
61
 
62
62
  OLLAMA_API_KEY = "ollama"
63
+ DUMMY_API_KEY = "xxx"
63
64
 
64
65
 
65
66
  class OpenAIChatModel(str, Enum):
@@ -210,7 +211,7 @@ class OpenAIGPTConfig(LLMConfig):
210
211
  """
211
212
 
212
213
  type: str = "openai"
213
- api_key: str = "" # CAUTION: set this ONLY via env var OPENAI_API_KEY
214
+ api_key: str = DUMMY_API_KEY # CAUTION: set this ONLY via env var OPENAI_API_KEY
214
215
  organization: str = ""
215
216
  api_base: str | None = None # used for local or other non-OpenAI models
216
217
  litellm: bool = False # use litellm api?
@@ -441,7 +442,12 @@ class OpenAIGPT(LanguageModel):
441
442
  # Pydantic's BaseSettings will automatically pick it up from the
442
443
  # .env file
443
444
  # The config.api_key is ignored when not using an OpenAI model
444
- self.api_key = config.api_key if self.is_openai_chat_model() else "xxx"
445
+ if self.is_openai_completion_model() or self.is_openai_chat_model():
446
+ self.api_key = config.api_key
447
+ if self.api_key == DUMMY_API_KEY:
448
+ self.api_key = os.getenv("OPENAI_API_KEY", DUMMY_API_KEY)
449
+ else:
450
+ self.api_key = DUMMY_API_KEY
445
451
  self.client = OpenAI(
446
452
  api_key=self.api_key,
447
453
  base_url=self.api_base,
@@ -25,6 +25,7 @@ def retry_with_exponential_backoff(
25
25
  requests.exceptions.RequestException,
26
26
  openai.APITimeoutError,
27
27
  openai.RateLimitError,
28
+ openai.AuthenticationError,
28
29
  openai.APIError,
29
30
  aiohttp.ServerTimeoutError,
30
31
  asyncio.TimeoutError,
@@ -47,6 +48,10 @@ def retry_with_exponential_backoff(
47
48
  # e.g. when context is too long
48
49
  logger.error(f"OpenAI API request failed with error: {e}.")
49
50
  raise e
51
+ except openai.AuthenticationError as e:
52
+ # do not retry when there's an auth error
53
+ logger.error(f"OpenAI API request failed with error: {e}.")
54
+ raise e
50
55
 
51
56
  # Retry on specified errors
52
57
  except errors as e:
@@ -85,6 +90,7 @@ def async_retry_with_exponential_backoff(
85
90
  errors: tuple = ( # type: ignore
86
91
  openai.APITimeoutError,
87
92
  openai.RateLimitError,
93
+ openai.AuthenticationError,
88
94
  openai.APIError,
89
95
  aiohttp.ServerTimeoutError,
90
96
  asyncio.TimeoutError,
@@ -108,7 +114,10 @@ def async_retry_with_exponential_backoff(
108
114
  # e.g. when context is too long
109
115
  logger.error(f"OpenAI API request failed with error: {e}.")
110
116
  raise e
111
-
117
+ except openai.AuthenticationError as e:
118
+ # do not retry when there's an auth error
119
+ logger.error(f"OpenAI API request failed with error: {e}.")
120
+ raise e
112
121
  # Retry on specified errors
113
122
  except errors as e:
114
123
  # Increment retries
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.1.205
3
+ Version: 0.1.207
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -42,7 +42,7 @@ Requires-Dist: halo (>=0.0.31,<0.0.32)
42
42
  Requires-Dist: huggingface-hub (>=0.21.2,<0.22.0) ; extra == "transformers"
43
43
  Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
44
44
  Requires-Dist: lancedb (>=0.6.2,<0.7.0)
45
- Requires-Dist: litellm (>=1.29.5,<2.0.0) ; extra == "litellm"
45
+ Requires-Dist: litellm (>=1.30.1,<2.0.0) ; extra == "litellm"
46
46
  Requires-Dist: lxml (>=4.9.3,<5.0.0)
47
47
  Requires-Dist: meilisearch (>=0.28.3,<0.29.0)
48
48
  Requires-Dist: meilisearch-python-sdk (>=2.2.3,<3.0.0)
@@ -67,6 +67,7 @@ Requires-Dist: pdfplumber (>=0.10.2,<0.11.0)
67
67
  Requires-Dist: pre-commit (>=3.3.2,<4.0.0)
68
68
  Requires-Dist: prettytable (>=3.8.0,<4.0.0)
69
69
  Requires-Dist: psycopg2 (>=2.9.7,<3.0.0) ; extra == "postgres"
70
+ Requires-Dist: pyarrow (==15.0.0)
70
71
  Requires-Dist: pydantic (==1.10.13)
71
72
  Requires-Dist: pygithub (>=1.58.1,<2.0.0)
72
73
  Requires-Dist: pygments (>=2.15.1,<3.0.0)
@@ -58,12 +58,12 @@ langroid/language_models/azure_openai.py,sha256=ncRCbKooqLVOY-PWQUIo9C3yTuKEFbAw
58
58
  langroid/language_models/base.py,sha256=oZskZ9oT-_4kEk1M2515jQ4VOpf31M8NFvPr5knDTEU,21008
59
59
  langroid/language_models/config.py,sha256=5UF3DzO1a-Dfsc3vghE0XGq7g9t_xDsRCsuRiU4dgBg,366
60
60
  langroid/language_models/openai_assistants.py,sha256=9K-DEAL2aSWHeXj2hwCo2RAlK9_1oCPtqX2u1wISCj8,36
61
- langroid/language_models/openai_gpt.py,sha256=YC5mzFLDXpOFmnEefoazpZ2XrZMPIw75QxqamETF8ck,49433
61
+ langroid/language_models/openai_gpt.py,sha256=6CE6I_hmnHfRIMJMh4qhVeKijgKEm_LNcWNn3vLMLlM,49680
62
62
  langroid/language_models/prompt_formatter/__init__.py,sha256=9JXFF22QNMmbQV1q4nrIeQVTtA3Tx8tEZABLtLBdFyc,352
63
63
  langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
64
64
  langroid/language_models/prompt_formatter/hf_formatter.py,sha256=QhVj5DcJYqveLC6nE3DKjsiJ8jY-J__8--NNp-2h8vI,5216
65
65
  langroid/language_models/prompt_formatter/llama2_formatter.py,sha256=YdcO88qyBeuMENVIVvVqSYuEpvYSTndUe_jd6hVTko4,2899
66
- langroid/language_models/utils.py,sha256=J1Y1HoYPkwS7L-kuLRAGzjcseqAj_S8u_MaaqlOA9uk,4265
66
+ langroid/language_models/utils.py,sha256=ivbmAUpDewWb-j9HNhnpmFeQbELQaGYRNul4wiP9p3c,4756
67
67
  langroid/mytypes.py,sha256=opL488mtHKob1uJeK_h1-kNjU5GZwkgCfXhBQCsONWU,2614
68
68
  langroid/parsing/__init__.py,sha256=bo1sjirQCFK-1voHTr__w6PAosiCmBc1MAJ8hkst_S8,597
69
69
  langroid/parsing/agent_chats.py,sha256=sbZRV9ujdM5QXvvuHVjIi2ysYSYlap-uqfMMUKulrW0,1068
@@ -115,7 +115,7 @@ langroid/vector_store/meilisearch.py,sha256=d2huA9P-NoYRuAQ9ZeXJmMKr7ry8u90RUSR2
115
115
  langroid/vector_store/momento.py,sha256=j6Eo6oIDN2fe7lsBOlCXJn3uvvERHHTFL5QJfeREeOM,10044
116
116
  langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
117
117
  langroid/vector_store/qdrantdb.py,sha256=_egbsP9SWBwmI827EDYSSOqfIQSmwNsmJfFTxrLpWYE,13457
118
- langroid-0.1.205.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
119
- langroid-0.1.205.dist-info/METADATA,sha256=yn62BcieoKi0Z3E-GQu3JhdtavjaXAZ6K3itnPgOcV4,46205
120
- langroid-0.1.205.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
121
- langroid-0.1.205.dist-info/RECORD,,
118
+ langroid-0.1.207.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
119
+ langroid-0.1.207.dist-info/METADATA,sha256=gmjzlymopU2UOrbF294gOjxaDDmz9gXH4vvG1-ac6Ao,46239
120
+ langroid-0.1.207.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
121
+ langroid-0.1.207.dist-info/RECORD,,