langroid 0.1.206__tar.gz → 0.1.207__tar.gz
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-0.1.206 → langroid-0.1.207}/PKG-INFO +1 -1
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/openai_gpt.py +8 -2
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/utils.py +10 -1
- {langroid-0.1.206 → langroid-0.1.207}/pyproject.toml +1 -1
- {langroid-0.1.206 → langroid-0.1.207}/LICENSE +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/README.md +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/batch.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/chat_document.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/helpers.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/junk +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/task.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tool_message.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/sciphi_search_rag_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/agent_config.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/cachedb/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/embedding_models/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/embedding_models/models.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/config.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/openai_assistants.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/mytypes.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/config.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/json.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/parser.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/search.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/spider.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/urls.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/utils.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/parsing/web_search.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/dialog.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/templates.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/prompts/transforms.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/configuration.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/constants.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/docker.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/globals.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/logging.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/output/printing.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/system.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/web/login.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/utils/web/selenium_login.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/base.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/momento.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.1.206 → langroid-0.1.207}/langroid/vector_store/qdrantdb.py +0 -0
@@ -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 =
|
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.
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/lance_rag/query_planner_agent.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.206 → langroid-0.1.207}/langroid/agent/special/sql/utils/description_extractors.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.1.206 → langroid-0.1.207}/langroid/language_models/prompt_formatter/llama2_formatter.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|