langroid 0.26.2__tar.gz → 0.27.1__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.26.2 → langroid-0.27.1}/PKG-INFO +1 -1
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/base.py +11 -11
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/chat_agent.py +18 -13
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/task.py +2 -2
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/azure_openai.py +22 -10
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/openai_gpt.py +11 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/chromadb.py +2 -4
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/lancedb.py +4 -6
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/momento.py +4 -6
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/qdrantdb.py +8 -10
- {langroid-0.26.2 → langroid-0.27.1}/pyproject.toml +1 -1
- {langroid-0.26.2 → langroid-0.27.1}/LICENSE +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/README.md +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/batch.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/chat_document.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/helpers.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/junk +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/arangodb/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/arangodb/system_messages.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/arangodb/tools.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/arangodb/utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/neo4j/system_messages.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/neo4j/tools.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/structured_message.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tool_message.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/file_tools.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/typed_task.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent/xml_tool_message.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/agent_config.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/cachedb/base.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/base.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/models.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/exceptions.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/.chainlit/config.toml +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/base.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/config.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/mytypes.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/config.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/image_text.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/parser.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/routing.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/search.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/spider.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/urls.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/parsing/web_search.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/prompts/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/prompts/dialog.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/prompts/templates.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/py.typed +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/.chainlit/config.toml +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/.chainlit/translations/en-US.json +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/configuration.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/constants.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/docker.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/git_utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/globals.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/logging.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/object_registry.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/output/citations.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/output/printing.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/output/status.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/system.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/types.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/utils/web/login.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/base.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.26.2 → langroid-0.27.1}/langroid/vector_store/qdrant_cloud.py +0 -0
@@ -450,20 +450,20 @@ class Agent(ABC):
|
|
450
450
|
"""
|
451
451
|
if results is None:
|
452
452
|
return None
|
453
|
+
if isinstance(results, str):
|
454
|
+
results_str = results
|
455
|
+
elif isinstance(results, ChatDocument):
|
456
|
+
results_str = results.content
|
457
|
+
elif isinstance(results, dict):
|
458
|
+
results_str = json.dumps(results, indent=2)
|
453
459
|
if not settings.quiet:
|
454
|
-
if isinstance(results, str):
|
455
|
-
results_str = results
|
456
|
-
elif isinstance(results, ChatDocument):
|
457
|
-
results_str = results.content
|
458
|
-
elif isinstance(results, dict):
|
459
|
-
results_str = json.dumps(results, indent=2)
|
460
460
|
console.print(f"[red]{self.indent}", end="")
|
461
461
|
print(f"[red]Agent: {escape(results_str)}")
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
462
|
+
maybe_json = len(extract_top_level_json(results_str)) > 0
|
463
|
+
self.callbacks.show_agent_response(
|
464
|
+
content=results_str,
|
465
|
+
language="json" if maybe_json else "text",
|
466
|
+
)
|
467
467
|
if isinstance(results, ChatDocument):
|
468
468
|
# Preserve trail of tool_ids for OpenAI Assistant fn-calls
|
469
469
|
results.metadata.tool_ids = (
|
@@ -1734,25 +1734,30 @@ class ChatAgent(Agent):
|
|
1734
1734
|
# streaming was enabled, AND we did not find a cached response.
|
1735
1735
|
# If we are here, it means the response has not yet been displayed.
|
1736
1736
|
cached = f"[red]{self.indent}(cached)[/red]" if is_cached else ""
|
1737
|
+
chat_doc = (
|
1738
|
+
response
|
1739
|
+
if isinstance(response, ChatDocument)
|
1740
|
+
else ChatDocument.from_LLMResponse(response, displayed=True)
|
1741
|
+
)
|
1742
|
+
# TODO: prepend TOOL: or OAI-TOOL: if it's a tool-call
|
1737
1743
|
if not settings.quiet:
|
1738
|
-
chat_doc = (
|
1739
|
-
response
|
1740
|
-
if isinstance(response, ChatDocument)
|
1741
|
-
else ChatDocument.from_LLMResponse(response, displayed=True)
|
1742
|
-
)
|
1743
|
-
# TODO: prepend TOOL: or OAI-TOOL: if it's a tool-call
|
1744
1744
|
print(cached + "[green]" + escape(str(response)))
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1745
|
+
self.callbacks.show_llm_response(
|
1746
|
+
content=str(response),
|
1747
|
+
is_tool=self.has_tool_message_attempt(chat_doc),
|
1748
|
+
cached=is_cached,
|
1749
|
+
)
|
1750
1750
|
if isinstance(response, LLMResponse):
|
1751
1751
|
# we are in the context immediately after an LLM responded,
|
1752
1752
|
# we won't have citations yet, so we're done
|
1753
1753
|
return
|
1754
|
-
if response.metadata.has_citation
|
1755
|
-
|
1754
|
+
if response.metadata.has_citation:
|
1755
|
+
if not settings.quiet:
|
1756
|
+
print(
|
1757
|
+
"[grey37]SOURCES:\n"
|
1758
|
+
+ escape(response.metadata.source)
|
1759
|
+
+ "[/grey37]"
|
1760
|
+
)
|
1756
1761
|
self.callbacks.show_llm_response(
|
1757
1762
|
content=str(response.metadata.source),
|
1758
1763
|
is_tool=False,
|
@@ -571,7 +571,7 @@ class Task:
|
|
571
571
|
|
572
572
|
if self.caller is not None and self.caller.logger is not None:
|
573
573
|
self.logger = self.caller.logger
|
574
|
-
|
574
|
+
elif self.logger is None:
|
575
575
|
self.logger = RichFileLogger(
|
576
576
|
str(Path(self.config.logs_dir) / f"{self.name}.log"),
|
577
577
|
color=self.color_log,
|
@@ -579,7 +579,7 @@ class Task:
|
|
579
579
|
|
580
580
|
if self.caller is not None and self.caller.tsv_logger is not None:
|
581
581
|
self.tsv_logger = self.caller.tsv_logger
|
582
|
-
|
582
|
+
elif self.tsv_logger is None:
|
583
583
|
self.tsv_logger = setup_file_logger(
|
584
584
|
"tsv_logger",
|
585
585
|
str(Path(self.config.logs_dir) / f"{self.name}.tsv"),
|
@@ -127,16 +127,28 @@ class AzureGPT(OpenAIGPT):
|
|
127
127
|
Sets the chat model configuration based on the model name specified in the
|
128
128
|
``.env``. This function checks the `model_name` in the configuration and sets
|
129
129
|
the appropriate chat model in the `config.chat_model`. It supports handling for
|
130
|
-
'35-turbo'
|
131
|
-
|
132
|
-
models, it defaults to
|
130
|
+
'gpt-35-turbo', 'gpt4-turbo', 'gpt-4o' and 'gpt-4o-mini' models. For
|
131
|
+
'gpt-4', it further delegates the handling to `handle_gpt4_model` method.
|
132
|
+
If the model name does not match any predefined models, it defaults to
|
133
|
+
`OpenAIChatModel.GPT4`.
|
133
134
|
"""
|
134
|
-
|
135
|
-
|
135
|
+
MODEL_35_TURBO_NAMES = ("gpt-35-turbo", "35-turbo")
|
136
|
+
MODEL_GPT4_TURBO_NAME = "gpt-4-turbo"
|
137
|
+
MODEL_GPT4o_NAME = "gpt-4o"
|
138
|
+
MODEL_GPT4o_MINI_NAME = "gpt-4o-mini"
|
139
|
+
MODEL_GPT4_PREFIX = "gpt-4"
|
136
140
|
|
137
|
-
if self.config.model_name
|
141
|
+
if self.config.model_name in MODEL_35_TURBO_NAMES:
|
138
142
|
self.config.chat_model = OpenAIChatModel.GPT3_5_TURBO
|
139
|
-
elif self.config.model_name ==
|
143
|
+
elif self.config.model_name == MODEL_GPT4o_NAME:
|
144
|
+
self.config.chat_model = OpenAIChatModel.GPT4o
|
145
|
+
elif self.config.model_name == MODEL_GPT4o_MINI_NAME:
|
146
|
+
self.config.chat_model = OpenAIChatModel.GPT4o_MINI
|
147
|
+
elif self.config.model_name == MODEL_GPT4_TURBO_NAME:
|
148
|
+
self.config.chat_model = OpenAIChatModel.GPT4_TURBO
|
149
|
+
elif isinstance(
|
150
|
+
self.config.model_name, str
|
151
|
+
) and self.config.model_name.startswith(MODEL_GPT4_PREFIX):
|
140
152
|
self.handle_gpt4_model()
|
141
153
|
else:
|
142
154
|
self.config.chat_model = OpenAIChatModel.GPT4
|
@@ -153,8 +165,8 @@ class AzureGPT(OpenAIGPT):
|
|
153
165
|
the version is '1106-Preview', otherwise, it defaults to
|
154
166
|
setting `OpenAIChatModel.GPT4`.
|
155
167
|
"""
|
156
|
-
|
157
|
-
VERSIONS_GPT4o =
|
168
|
+
VERSIONS_GPT4_TURBO = ("1106-Preview", "2024-04-09")
|
169
|
+
VERSIONS_GPT4o = ("2024-05-13", "2024-08-06", "2024-11-20")
|
158
170
|
|
159
171
|
if self.config.model_version == "":
|
160
172
|
raise ValueError(
|
@@ -164,7 +176,7 @@ class AzureGPT(OpenAIGPT):
|
|
164
176
|
|
165
177
|
if self.config.model_version in VERSIONS_GPT4o:
|
166
178
|
self.config.chat_model = OpenAIChatModel.GPT4o
|
167
|
-
elif self.config.model_version
|
179
|
+
elif self.config.model_version in VERSIONS_GPT4_TURBO:
|
168
180
|
self.config.chat_model = OpenAIChatModel.GPT4_TURBO
|
169
181
|
else:
|
170
182
|
self.config.chat_model = OpenAIChatModel.GPT4
|
@@ -67,6 +67,7 @@ if "OLLAMA_HOST" in os.environ:
|
|
67
67
|
else:
|
68
68
|
OLLAMA_BASE_URL = "http://localhost:11434/v1"
|
69
69
|
|
70
|
+
OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1"
|
70
71
|
GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/"
|
71
72
|
GLHF_BASE_URL = "https://glhf.chat/api/openai/v1"
|
72
73
|
OLLAMA_API_KEY = "ollama"
|
@@ -566,8 +567,10 @@ class OpenAIGPT(LanguageModel):
|
|
566
567
|
self.is_cerebras = self.config.chat_model.startswith("cerebras/")
|
567
568
|
self.is_gemini = self.config.chat_model.startswith("gemini/")
|
568
569
|
self.is_glhf = self.config.chat_model.startswith("glhf/")
|
570
|
+
self.is_openrouter = self.config.chat_model.startswith("openrouter/")
|
569
571
|
|
570
572
|
if self.is_groq:
|
573
|
+
# use groq-specific client
|
571
574
|
self.config.chat_model = self.config.chat_model.replace("groq/", "")
|
572
575
|
self.api_key = os.getenv("GROQ_API_KEY", DUMMY_API_KEY)
|
573
576
|
self.client = Groq(
|
@@ -577,6 +580,7 @@ class OpenAIGPT(LanguageModel):
|
|
577
580
|
api_key=self.api_key,
|
578
581
|
)
|
579
582
|
elif self.is_cerebras:
|
583
|
+
# use cerebras-specific client
|
580
584
|
self.config.chat_model = self.config.chat_model.replace("cerebras/", "")
|
581
585
|
self.api_key = os.getenv("CEREBRAS_API_KEY", DUMMY_API_KEY)
|
582
586
|
self.client = Cerebras(
|
@@ -587,6 +591,7 @@ class OpenAIGPT(LanguageModel):
|
|
587
591
|
api_key=self.api_key,
|
588
592
|
)
|
589
593
|
else:
|
594
|
+
# in these cases, there's no specific client: OpenAI python client suffices
|
590
595
|
if self.is_gemini:
|
591
596
|
self.config.chat_model = self.config.chat_model.replace("gemini/", "")
|
592
597
|
self.api_key = os.getenv("GEMINI_API_KEY", DUMMY_API_KEY)
|
@@ -595,6 +600,12 @@ class OpenAIGPT(LanguageModel):
|
|
595
600
|
self.config.chat_model = self.config.chat_model.replace("glhf/", "")
|
596
601
|
self.api_key = os.getenv("GLHF_API_KEY", DUMMY_API_KEY)
|
597
602
|
self.api_base = GLHF_BASE_URL
|
603
|
+
elif self.is_openrouter:
|
604
|
+
self.config.chat_model = self.config.chat_model.replace(
|
605
|
+
"openrouter/", ""
|
606
|
+
)
|
607
|
+
self.api_key = os.getenv("OPENROUTER_API_KEY", DUMMY_API_KEY)
|
608
|
+
self.api_base = OPENROUTER_BASE_URL
|
598
609
|
|
599
610
|
self.client = OpenAI(
|
600
611
|
api_key=self.api_key,
|
@@ -3,7 +3,6 @@ import logging
|
|
3
3
|
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
4
4
|
|
5
5
|
from langroid.embedding_models.base import (
|
6
|
-
EmbeddingModel,
|
7
6
|
EmbeddingModelsConfig,
|
8
7
|
)
|
9
8
|
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
|
@@ -32,8 +31,7 @@ class ChromaDB(VectorStore):
|
|
32
31
|
except ImportError:
|
33
32
|
raise LangroidImportError("chromadb", "chromadb")
|
34
33
|
self.config = config
|
35
|
-
|
36
|
-
self.embedding_fn = emb_model.embedding_fn()
|
34
|
+
self.embedding_fn = self.embedding_model.embedding_fn()
|
37
35
|
self.client = chromadb.Client(
|
38
36
|
chromadb.config.Settings(
|
39
37
|
# chroma_db_impl="duckdb+parquet",
|
@@ -64,7 +62,7 @@ class ChromaDB(VectorStore):
|
|
64
62
|
self.client.delete_collection(name=c.name)
|
65
63
|
logger.warning(
|
66
64
|
f"""
|
67
|
-
Deleted {n_empty_deletes} empty collections and
|
65
|
+
Deleted {n_empty_deletes} empty collections and
|
68
66
|
{n_non_empty_deletes} non-empty collections.
|
69
67
|
"""
|
70
68
|
)
|
@@ -22,7 +22,6 @@ if TYPE_CHECKING:
|
|
22
22
|
from lancedb.query import LanceVectorQueryBuilder
|
23
23
|
|
24
24
|
from langroid.embedding_models.base import (
|
25
|
-
EmbeddingModel,
|
26
25
|
EmbeddingModelsConfig,
|
27
26
|
)
|
28
27
|
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
|
@@ -61,9 +60,8 @@ class LanceDB(VectorStore):
|
|
61
60
|
raise LangroidImportError("lancedb", "lancedb")
|
62
61
|
|
63
62
|
self.config: LanceDBConfig = config
|
64
|
-
|
65
|
-
self.
|
66
|
-
self.embedding_dim = emb_model.embedding_dims
|
63
|
+
self.embedding_fn: EmbeddingFunction = self.embedding_model.embedding_fn()
|
64
|
+
self.embedding_dim = self.embedding_model.embedding_dims
|
67
65
|
self.host = config.host
|
68
66
|
self.port = config.port
|
69
67
|
self.is_from_dataframe = False # were docs ingested from a dataframe?
|
@@ -123,7 +121,7 @@ class LanceDB(VectorStore):
|
|
123
121
|
self.client.drop_table(name)
|
124
122
|
logger.warning(
|
125
123
|
f"""
|
126
|
-
Deleted {n_empty_deletes} empty collections and
|
124
|
+
Deleted {n_empty_deletes} empty collections and
|
127
125
|
{n_non_empty_deletes} non-empty collections.
|
128
126
|
"""
|
129
127
|
)
|
@@ -344,7 +342,7 @@ class LanceDB(VectorStore):
|
|
344
342
|
raise ValueError(
|
345
343
|
f"""
|
346
344
|
Error validating LanceDB result: {e}
|
347
|
-
HINT: This could happen when you're re-using an
|
345
|
+
HINT: This could happen when you're re-using an
|
348
346
|
existing LanceDB store with a different schema.
|
349
347
|
Try deleting your local lancedb storage at `{self.config.storage_path}`
|
350
348
|
re-ingesting your documents and/or replacing the collections.
|
@@ -34,7 +34,6 @@ except ImportError:
|
|
34
34
|
|
35
35
|
|
36
36
|
from langroid.embedding_models.base import (
|
37
|
-
EmbeddingModel,
|
38
37
|
EmbeddingModelsConfig,
|
39
38
|
)
|
40
39
|
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
|
@@ -62,9 +61,8 @@ class MomentoVI(VectorStore):
|
|
62
61
|
raise LangroidImportError("momento", "momento")
|
63
62
|
self.distance = SimilarityMetric.COSINE_SIMILARITY
|
64
63
|
self.config: MomentoVIConfig = config
|
65
|
-
|
66
|
-
self.
|
67
|
-
self.embedding_dim = emb_model.embedding_dims
|
64
|
+
self.embedding_fn: EmbeddingFunction = self.embedding_model.embedding_fn()
|
65
|
+
self.embedding_dim = self.embedding_model.embedding_dims
|
68
66
|
self.host = config.host
|
69
67
|
self.port = config.port
|
70
68
|
load_dotenv()
|
@@ -72,8 +70,8 @@ class MomentoVI(VectorStore):
|
|
72
70
|
if config.cloud:
|
73
71
|
if api_key is None:
|
74
72
|
raise ValueError(
|
75
|
-
"""MOMENTO_API_KEY env variable must be set to
|
76
|
-
MomentoVI hosted service. Please set this in your .env file.
|
73
|
+
"""MOMENTO_API_KEY env variable must be set to
|
74
|
+
MomentoVI hosted service. Please set this in your .env file.
|
77
75
|
"""
|
78
76
|
)
|
79
77
|
self.client = PreviewVectorIndexClient(
|
@@ -23,7 +23,6 @@ from qdrant_client.http.models import (
|
|
23
23
|
)
|
24
24
|
|
25
25
|
from langroid.embedding_models.base import (
|
26
|
-
EmbeddingModel,
|
27
26
|
EmbeddingModelsConfig,
|
28
27
|
)
|
29
28
|
from langroid.embedding_models.models import OpenAIEmbeddingsConfig
|
@@ -77,16 +76,15 @@ class QdrantDB(VectorStore):
|
|
77
76
|
def __init__(self, config: QdrantDBConfig = QdrantDBConfig()):
|
78
77
|
super().__init__(config)
|
79
78
|
self.config: QdrantDBConfig = config
|
80
|
-
|
81
|
-
self.
|
82
|
-
self.embedding_dim = emb_model.embedding_dims
|
79
|
+
self.embedding_fn: EmbeddingFunction = self.embedding_model.embedding_fn()
|
80
|
+
self.embedding_dim = self.embedding_model.embedding_dims
|
83
81
|
if self.config.use_sparse_embeddings:
|
84
82
|
try:
|
85
83
|
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
86
84
|
except ImportError:
|
87
85
|
raise ImportError(
|
88
86
|
"""
|
89
|
-
To use sparse embeddings,
|
87
|
+
To use sparse embeddings,
|
90
88
|
you must install langroid with the [transformers] extra, e.g.:
|
91
89
|
pip install "langroid[transformers]"
|
92
90
|
"""
|
@@ -117,10 +115,10 @@ class QdrantDB(VectorStore):
|
|
117
115
|
config.cloud = True
|
118
116
|
elif config.cloud and None in [key, url]:
|
119
117
|
logger.warning(
|
120
|
-
f"""QDRANT_API_KEY, QDRANT_API_URL env variable must be set to use
|
121
|
-
QdrantDB in cloud mode. Please set these values
|
122
|
-
in your .env file.
|
123
|
-
Switching to local storage at {config.storage_path}
|
118
|
+
f"""QDRANT_API_KEY, QDRANT_API_URL env variable must be set to use
|
119
|
+
QdrantDB in cloud mode. Please set these values
|
120
|
+
in your .env file.
|
121
|
+
Switching to local storage at {config.storage_path}
|
124
122
|
"""
|
125
123
|
)
|
126
124
|
config.cloud = False
|
@@ -189,7 +187,7 @@ class QdrantDB(VectorStore):
|
|
189
187
|
self.client.delete_collection(collection_name=name)
|
190
188
|
logger.warning(
|
191
189
|
f"""
|
192
|
-
Deleted {n_empty_deletes} empty collections and
|
190
|
+
Deleted {n_empty_deletes} empty collections and
|
193
191
|
{n_non_empty_deletes} non-empty collections.
|
194
192
|
"""
|
195
193
|
)
|
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
|
{langroid-0.26.2 → langroid-0.27.1}/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
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/.chainlit/translations/en-US.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{langroid-0.26.2 → langroid-0.27.1}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.26.2 → langroid-0.27.1}/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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|