langroid 0.45.5__py3-none-any.whl → 0.45.7__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.
- langroid/embedding_models/models.py +5 -0
- langroid/language_models/base.py +6 -4
- langroid/language_models/model_info.py +7 -7
- langroid/language_models/openai_gpt.py +13 -6
- langroid/parsing/web_search.py +21 -2
- {langroid-0.45.5.dist-info → langroid-0.45.7.dist-info}/METADATA +1 -1
- {langroid-0.45.5.dist-info → langroid-0.45.7.dist-info}/RECORD +9 -9
- {langroid-0.45.5.dist-info → langroid-0.45.7.dist-info}/WHEEL +0 -0
- {langroid-0.45.5.dist-info → langroid-0.45.7.dist-info}/licenses/LICENSE +0 -0
@@ -25,6 +25,11 @@ class OpenAIEmbeddingsConfig(EmbeddingModelsConfig):
|
|
25
25
|
dims: int = 1536
|
26
26
|
context_length: int = 8192
|
27
27
|
|
28
|
+
class Config:
|
29
|
+
# enable auto-loading of env vars with OPENAI_ prefix, e.g.
|
30
|
+
# api_base is set from OPENAI_API_BASE env var, in .env or system env
|
31
|
+
env_prefix = "OPENAI_"
|
32
|
+
|
28
33
|
|
29
34
|
class AzureOpenAIEmbeddingsConfig(EmbeddingModelsConfig):
|
30
35
|
model_type: str = "azure-openai"
|
langroid/language_models/base.py
CHANGED
@@ -42,6 +42,8 @@ FunctionCallTypes = Literal["none", "auto"]
|
|
42
42
|
ToolChoiceTypes = Literal["none", "auto", "required"]
|
43
43
|
ToolTypes = Literal["function"]
|
44
44
|
|
45
|
+
DEFAULT_CONTEXT_LENGTH = 16_000
|
46
|
+
|
45
47
|
|
46
48
|
class StreamEventType(Enum):
|
47
49
|
TEXT = 1
|
@@ -66,9 +68,9 @@ class LLMConfig(BaseSettings):
|
|
66
68
|
chat_model: str = ""
|
67
69
|
completion_model: str = ""
|
68
70
|
temperature: float = 0.0
|
69
|
-
chat_context_length: int =
|
71
|
+
chat_context_length: int | None = None
|
70
72
|
async_stream_quiet: bool = True # suppress streaming output in async mode?
|
71
|
-
completion_context_length: int =
|
73
|
+
completion_context_length: int | None = None
|
72
74
|
# if input length + max_output_tokens > context length of model,
|
73
75
|
# we will try shortening requested output
|
74
76
|
min_output_tokens: int = 64
|
@@ -625,10 +627,10 @@ class LanguageModel(ABC):
|
|
625
627
|
return get_model_info(orig_model, model)
|
626
628
|
|
627
629
|
def chat_context_length(self) -> int:
|
628
|
-
return self.config.chat_context_length
|
630
|
+
return self.config.chat_context_length or DEFAULT_CONTEXT_LENGTH
|
629
631
|
|
630
632
|
def completion_context_length(self) -> int:
|
631
|
-
return self.config.completion_context_length
|
633
|
+
return self.config.completion_context_length or DEFAULT_CONTEXT_LENGTH
|
632
634
|
|
633
635
|
def chat_cost(self) -> Tuple[float, float]:
|
634
636
|
return self.config.chat_cost_per_1k_tokens
|
@@ -60,13 +60,13 @@ class DeepSeekModel(ModelName):
|
|
60
60
|
class GeminiModel(ModelName):
|
61
61
|
"""Enum for Gemini models"""
|
62
62
|
|
63
|
-
GEMINI_1_5_FLASH = "gemini
|
64
|
-
GEMINI_1_5_FLASH_8B = "gemini
|
65
|
-
GEMINI_1_5_PRO = "gemini
|
66
|
-
GEMINI_2_PRO = "gemini
|
67
|
-
GEMINI_2_FLASH = "gemini
|
68
|
-
GEMINI_2_FLASH_LITE = "gemini
|
69
|
-
GEMINI_2_FLASH_THINKING = "gemini
|
63
|
+
GEMINI_1_5_FLASH = "gemini-1.5-flash"
|
64
|
+
GEMINI_1_5_FLASH_8B = "gemini-1.5-flash-8b"
|
65
|
+
GEMINI_1_5_PRO = "gemini-1.5-pro"
|
66
|
+
GEMINI_2_PRO = "gemini-2.0-pro-exp-02-05"
|
67
|
+
GEMINI_2_FLASH = "gemini-2.0-flash"
|
68
|
+
GEMINI_2_FLASH_LITE = "gemini-2.0-flash-lite-preview"
|
69
|
+
GEMINI_2_FLASH_THINKING = "gemini-2.0-flash-thinking-exp"
|
70
70
|
|
71
71
|
|
72
72
|
class OpenAI_API_ParamInfo(BaseModel):
|
@@ -660,17 +660,24 @@ class OpenAIGPT(LanguageModel):
|
|
660
660
|
|
661
661
|
def chat_context_length(self) -> int:
|
662
662
|
"""
|
663
|
-
Context-length for chat-completion models/endpoints
|
664
|
-
Get it from the
|
663
|
+
Context-length for chat-completion models/endpoints.
|
664
|
+
Get it from the config if explicitly given,
|
665
|
+
otherwise use model_info based on model name, and fall back to
|
666
|
+
generic model_info if there's no match.
|
665
667
|
"""
|
666
|
-
return self.info().context_length
|
668
|
+
return self.config.chat_context_length or self.info().context_length
|
667
669
|
|
668
670
|
def completion_context_length(self) -> int:
|
669
671
|
"""
|
670
|
-
Context-length for completion models/endpoints
|
671
|
-
Get it from the
|
672
|
+
Context-length for completion models/endpoints.
|
673
|
+
Get it from the config if explicitly given,
|
674
|
+
otherwise use model_info based on model name, and fall back to
|
675
|
+
generic model_info if there's no match.
|
672
676
|
"""
|
673
|
-
return
|
677
|
+
return (
|
678
|
+
self.config.completion_context_length
|
679
|
+
or self.completion_info().context_length
|
680
|
+
)
|
674
681
|
|
675
682
|
def chat_cost(self) -> Tuple[float, float]:
|
676
683
|
"""
|
langroid/parsing/web_search.py
CHANGED
@@ -51,8 +51,27 @@ class WebSearchResult:
|
|
51
51
|
|
52
52
|
def get_full_content(self) -> str:
|
53
53
|
try:
|
54
|
-
|
55
|
-
|
54
|
+
# First check headers only to get content length and type
|
55
|
+
head_response: Response = requests.head(self.link, timeout=5)
|
56
|
+
if head_response.status_code != 200:
|
57
|
+
return f"Error: HTTP {head_response.status_code} for {self.link}"
|
58
|
+
|
59
|
+
# Skip large files
|
60
|
+
content_length = int(head_response.headers.get("content-length", 0))
|
61
|
+
if content_length > 5_000_000: # 5MB limit
|
62
|
+
return (
|
63
|
+
f"Error: Content too large ({content_length} bytes) for {self.link}"
|
64
|
+
)
|
65
|
+
|
66
|
+
response: Response = requests.get(self.link, timeout=10)
|
67
|
+
|
68
|
+
import warnings
|
69
|
+
|
70
|
+
from bs4 import XMLParsedAsHTMLWarning
|
71
|
+
|
72
|
+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
|
73
|
+
|
74
|
+
soup: BeautifulSoup = BeautifulSoup(response.text, "html.parser")
|
56
75
|
text = " ".join(soup.stripped_strings)
|
57
76
|
return text[: self.max_content_length]
|
58
77
|
except Exception as e:
|
@@ -59,7 +59,7 @@ langroid/cachedb/momento_cachedb.py,sha256=YEOJ62hEcV6iIeMr5aGgRYgWQqFYaej9gEDEc
|
|
59
59
|
langroid/cachedb/redis_cachedb.py,sha256=7kgnbf4b5CKsCrlL97mHWKvdvlLt8zgn7lc528jEpiE,5141
|
60
60
|
langroid/embedding_models/__init__.py,sha256=KyYxR3jDFUCfYjSuCL86qjAmrq6mXXjOT4lFNOKVj6Y,955
|
61
61
|
langroid/embedding_models/base.py,sha256=Ml7oA6PzQm0wZmIYn3fhF7dvZCi-amviWUwOeBegH3A,2562
|
62
|
-
langroid/embedding_models/models.py,sha256=
|
62
|
+
langroid/embedding_models/models.py,sha256=kYGGG-FkmGxNr0msXM3ANZ2eU-C85iTcoWNo00E9F_4,19151
|
63
63
|
langroid/embedding_models/remote_embeds.py,sha256=6_kjXByVbqhY9cGwl9R83ZcYC2km-nGieNNAo1McHaY,5151
|
64
64
|
langroid/embedding_models/protoc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
65
65
|
langroid/embedding_models/protoc/embeddings.proto,sha256=_O-SgFpTaylQeOTgSpxhEJ7CUw7PeCQQJLaPqpPYKJg,321
|
@@ -68,11 +68,11 @@ langroid/embedding_models/protoc/embeddings_pb2.pyi,sha256=UkNy7BrNsmQm0vLb3NtGX
|
|
68
68
|
langroid/embedding_models/protoc/embeddings_pb2_grpc.py,sha256=9dYQqkW3JPyBpSEjeGXTNpSqAkC-6FPtBHyteVob2Y8,2452
|
69
69
|
langroid/language_models/__init__.py,sha256=3aD2qC1lz8v12HX4B-dilv27gNxYdGdeu1QvDlkqqHs,1095
|
70
70
|
langroid/language_models/azure_openai.py,sha256=SW0Fp_y6HpERr9l6TtF6CYsKgKwjUf_hSL_2mhTV4wI,5034
|
71
|
-
langroid/language_models/base.py,sha256=
|
71
|
+
langroid/language_models/base.py,sha256=mDYmFCBCLdq8_Uvws4MiewwEgcOCP8Qb0e5yUXr3zpQ,26249
|
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
|
-
langroid/language_models/model_info.py,sha256=
|
75
|
-
langroid/language_models/openai_gpt.py,sha256=
|
74
|
+
langroid/language_models/model_info.py,sha256=tfBBxL0iUf2mVN6CjcvqflzFUVg2oZqOJZexZ8jHTYA,12216
|
75
|
+
langroid/language_models/openai_gpt.py,sha256=FMi4rQsdJETof5eSQrxIaBdu-5cOHFg8fFy7Hx7twOQ,77691
|
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
|
@@ -94,7 +94,7 @@ langroid/parsing/table_loader.py,sha256=qNM4obT_0Y4tjrxNBCNUYjKQ9oETCZ7FbolKBTcz
|
|
94
94
|
langroid/parsing/url_loader.py,sha256=obi_kj6ehBkdh5mXNtYCXpm3KCuExoy2D1ODVlFbXbQ,4895
|
95
95
|
langroid/parsing/urls.py,sha256=Tjzr64YsCusiYkY0LEGB5-rSuX8T2P_4DVoOFKAeKuI,8081
|
96
96
|
langroid/parsing/utils.py,sha256=WwqzOhbQRlorbVvddDIZKv9b1KqZCBDm955lgIHDXRw,12828
|
97
|
-
langroid/parsing/web_search.py,sha256=
|
97
|
+
langroid/parsing/web_search.py,sha256=rGkeUGsv_nopRIRuB-OqbieGASuHUaEFWsXmVdBXi8g,7800
|
98
98
|
langroid/prompts/__init__.py,sha256=RW11vK6jiLPuaUh4GpeFvstti73gkm8_rDMtrbo2YsU,142
|
99
99
|
langroid/prompts/dialog.py,sha256=SpfiSyofSgy2pwD1YboHR_yHO3LEEMbv6j2sm874jKo,331
|
100
100
|
langroid/prompts/prompts_config.py,sha256=p_lp9nbMuQwhhMwAZsOxveRw9C0ZFZvql7pdIfgVZYo,143
|
@@ -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.45.
|
131
|
-
langroid-0.45.
|
132
|
-
langroid-0.45.
|
133
|
-
langroid-0.45.
|
130
|
+
langroid-0.45.7.dist-info/METADATA,sha256=iuFtKxQjQwkRMb8-5lLmVKETJMCCxRcRO0REeJyW9dw,63335
|
131
|
+
langroid-0.45.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
132
|
+
langroid-0.45.7.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
133
|
+
langroid-0.45.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|