langroid 0.48.2__py3-none-any.whl → 0.49.0__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.
@@ -227,6 +227,16 @@ class OpenAICallParams(BaseModel):
227
227
  return {k: v for k, v in self.dict().items() if v is not None}
228
228
 
229
229
 
230
+ class LiteLLMProxyConfig(BaseSettings):
231
+ """Configuration for LiteLLM proxy connection."""
232
+
233
+ api_key: str = "" # read from env var LITELLM_API_KEY if set
234
+ api_base: str = "" # read from env var LITELLM_API_BASE if set
235
+
236
+ class Config:
237
+ env_prefix = "LITELLM_"
238
+
239
+
230
240
  class OpenAIGPTConfig(LLMConfig):
231
241
  """
232
242
  Class for any LLM with an OpenAI-like API: besides the OpenAI models this includes:
@@ -250,6 +260,7 @@ class OpenAIGPTConfig(LLMConfig):
250
260
  organization: str = ""
251
261
  api_base: str | None = None # used for local or other non-OpenAI models
252
262
  litellm: bool = False # use litellm api?
263
+ litellm_proxy: LiteLLMProxyConfig = LiteLLMProxyConfig()
253
264
  ollama: bool = False # use ollama's OpenAI-compatible endpoint?
254
265
  min_output_tokens: int = 1
255
266
  use_chat_for_completion = True # do not change this, for OpenAI models!
@@ -520,6 +531,7 @@ class OpenAIGPT(LanguageModel):
520
531
  self.is_glhf = self.config.chat_model.startswith("glhf/")
521
532
  self.is_openrouter = self.config.chat_model.startswith("openrouter/")
522
533
  self.is_langdb = self.config.chat_model.startswith("langdb/")
534
+ self.is_litellm_proxy = self.config.chat_model.startswith("litellm-proxy/")
523
535
 
524
536
  if self.is_groq:
525
537
  # use groq-specific client
@@ -546,7 +558,14 @@ class OpenAIGPT(LanguageModel):
546
558
  )
547
559
  else:
548
560
  # in these cases, there's no specific client: OpenAI python client suffices
549
- if self.is_gemini:
561
+ if self.is_litellm_proxy:
562
+ self.config.chat_model = self.config.chat_model.replace(
563
+ "litellm-proxy/", ""
564
+ )
565
+ if self.api_key == OPENAI_API_KEY:
566
+ self.api_key = self.config.litellm_proxy.api_key or self.api_key
567
+ self.api_base = self.config.litellm_proxy.api_base or self.api_base
568
+ elif self.is_gemini:
550
569
  self.config.chat_model = self.config.chat_model.replace("gemini/", "")
551
570
  if self.api_key == OPENAI_API_KEY:
552
571
  self.api_key = os.getenv("GEMINI_API_KEY", DUMMY_API_KEY)
langroid/mytypes.py CHANGED
@@ -3,7 +3,7 @@ from textwrap import dedent
3
3
  from typing import Any, Callable, Dict, List, Union
4
4
  from uuid import uuid4
5
5
 
6
- from langroid.pydantic_v1 import BaseModel, Extra, Field, validator
6
+ from langroid.pydantic_v1 import BaseModel, Extra, Field
7
7
 
8
8
  Number = Union[int, float]
9
9
  Embedding = List[Number]
@@ -51,13 +51,6 @@ class DocMetaData(BaseModel):
51
51
  id: str = Field(default_factory=lambda: str(uuid4()))
52
52
  window_ids: List[str] = [] # for RAG: ids of chunks around this one
53
53
 
54
- @validator("source", "source_content", "id", "title", "published_date")
55
- def ensure_not_empty(cls, v: str) -> str:
56
- """Ensure required string fields are not empty."""
57
- if not v:
58
- raise ValueError("Field cannot be empty")
59
- return v
60
-
61
54
  def dict_bool_int(self, *args: Any, **kwargs: Any) -> Dict[str, Any]:
62
55
  """
63
56
  Special dict method to convert bool fields to int, to appease some
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.48.2
3
+ Version: 0.49.0
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  langroid/__init__.py,sha256=z_fCOLQJPOw3LLRPBlFB5-2HyCjpPgQa4m4iY5Fvb8Y,1800
2
2
  langroid/exceptions.py,sha256=OPjece_8cwg94DLPcOGA1ddzy5bGh65pxzcHMnssTz8,2995
3
- langroid/mytypes.py,sha256=yzsPpDQqfndMP8ZX9zuQY_oLuUTkW2VJ_iLPARmKoLE,3268
3
+ langroid/mytypes.py,sha256=1mt21xiczAu1WgfZIptBKN9WpqYgpVeo8cAXvs6drKA,2986
4
4
  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=U-UjdpxIFqkzRIB5-LYwHrhMSNI3sDbfnNRqIhrtsyI,79568
@@ -72,7 +72,7 @@ langroid/language_models/base.py,sha256=mDYmFCBCLdq8_Uvws4MiewwEgcOCP8Qb0e5yUXr3
72
72
  langroid/language_models/config.py,sha256=9Q8wk5a7RQr8LGMT_0WkpjY8S4ywK06SalVRjXlfCiI,378
73
73
  langroid/language_models/mock_lm.py,sha256=5BgHKDVRWFbUwDT_PFgTZXz9-k8wJSA2e3PZmyDgQ1k,4022
74
74
  langroid/language_models/model_info.py,sha256=tfBBxL0iUf2mVN6CjcvqflzFUVg2oZqOJZexZ8jHTYA,12216
75
- langroid/language_models/openai_gpt.py,sha256=JJXLw7iuQFbW0CkcKiYjX4agRllRhDaGT9Q8OCdEK-8,79559
75
+ langroid/language_models/openai_gpt.py,sha256=Vcs2g2N3dT6Oc8WfbIXckuzmYWUCrN8TPYw0yyyTWNM,80378
76
76
  langroid/language_models/utils.py,sha256=L4_CbihDMTGcsg0TOG1Yd5JFEto46--h7CX_14m89sQ,5016
77
77
  langroid/language_models/prompt_formatter/__init__.py,sha256=2-5cdE24XoFDhifOLl8yiscohil1ogbP1ECkYdBlBsk,372
78
78
  langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
@@ -127,7 +127,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
127
127
  langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
128
128
  langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
129
129
  langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
130
- langroid-0.48.2.dist-info/METADATA,sha256=kCjeNq2-TNlc0DM8DRitNPJsHUhubpKGNJ2q-Mp6rY4,63606
131
- langroid-0.48.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
- langroid-0.48.2.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
- langroid-0.48.2.dist-info/RECORD,,
130
+ langroid-0.49.0.dist-info/METADATA,sha256=hheI5QVNzEyGlA-p2gJVGsgOuN1jP8piUAxXnv05CTg,63606
131
+ langroid-0.49.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
+ langroid-0.49.0.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
+ langroid-0.49.0.dist-info/RECORD,,