langroid 0.16.0__tar.gz → 0.16.2__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.16.0 → langroid-0.16.2}/PKG-INFO +6 -1
- {langroid-0.16.0 → langroid-0.16.2}/README.md +5 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/chat_agent.py +1 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/task.py +24 -7
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/base.py +9 -1
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/openai_gpt.py +32 -10
- {langroid-0.16.0 → langroid-0.16.2}/pyproject.toml +1 -1
- {langroid-0.16.0 → langroid-0.16.2}/LICENSE +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/base.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/batch.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/callbacks/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/callbacks/chainlit.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/chat_document.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/helpers.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/junk +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/openai_assistant.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/doc_chat_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_rag/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/lance_tools.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/neo4j/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/neo4j/utils/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/neo4j/utils/system_message.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/relevance_extractor_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/retriever_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/utils/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/utils/system_message.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/sql/utils/tools.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/special/table_chat_agent.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/structured_message.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tool_message.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/extract_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/generator_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/google_search_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/metaphor_search_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/note_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/orchestration.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/recipient_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/retrieval_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/rewind_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/run_python_code.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/tools/segment_extract_tool.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent/typed_task.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/agent_config.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/cachedb/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/cachedb/base.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/cachedb/momento_cachedb.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/cachedb/redis_cachedb.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/base.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/clustering.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/models.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/protoc/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/protoc/embeddings.proto +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/embedding_models/remote_embeds.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/exceptions.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/.chainlit/config.toml +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/.chainlit/translations/en-US.json +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/azure_openai.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/config.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/mock_lm.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/prompt_formatter/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/prompt_formatter/base.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/language_models/utils.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/mytypes.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/agent_chats.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/code-parsing.md +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/code_parser.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/config.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/document_parser.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/image_text.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/para_sentence_split.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/parse_json.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/parser.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/repo_loader.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/routing.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/search.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/spider.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/table_loader.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/url_loader.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/url_loader_cookies.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/urls.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/utils.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/parsing/web_search.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/prompts/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/prompts/chat-gpt4-system-prompt.md +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/prompts/dialog.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/prompts/prompts_config.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/prompts/templates.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/py.typed +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/pydantic_v1/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/pydantic_v1/main.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/.chainlit/config.toml +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/.chainlit/translations/en-US.json +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/algorithms/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/algorithms/graph.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/configuration.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/constants.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/docker.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/globals.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/llms/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/llms/strings.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/logging.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/object_registry.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/output/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/output/citations.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/output/printing.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/output/status.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/pandas_utils.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/pydantic_utils.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/system.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/types.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/web/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/utils/web/login.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/__init__.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/base.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/chromadb.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/lancedb.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/meilisearch.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/momento.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/qdrant_cloud.py +0 -0
- {langroid-0.16.0 → langroid-0.16.2}/langroid/vector_store/qdrantdb.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.16.
|
3
|
+
Version: 0.16.2
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
License: MIT
|
6
6
|
Author: Prasad Chalasani
|
@@ -242,6 +242,11 @@ teacher_task.run()
|
|
242
242
|
<details>
|
243
243
|
<summary> <b>Click to expand</b></summary>
|
244
244
|
|
245
|
+
- **Sep 2024:**
|
246
|
+
- **[0.16.0](https://github.com/langroid/langroid/releases/tag/0.16.0)** Support for OpenAI `o1-mini` and `o1-preview` models.
|
247
|
+
- **[0.15.0](https://github.com/langroid/langroid/releases/tag/0.15.0)** Cerebras API support -- run llama-3.1 models hosted on Cerebras Cloud (very fast inference).
|
248
|
+
- **[0.14.0](https://github.com/langroid/langroid/releases/tag/0.14.0)** `DocChatAgent` uses Reciprocal Rank Fusion (RRF) to rank chunks retrieved by different methods.
|
249
|
+
- **[0.12.0](https://github.com/langroid/langroid/releases/tag/0.12.0)** `run_batch_task` new option -- `stop_on_first_result` - allows termination of batch as soon as any task returns a result.
|
245
250
|
- **Aug 2024:**
|
246
251
|
- **[0.11.0](https://github.com/langroid/langroid/releases/tag/0.11.0)** Polymorphic `Task.run(), Task.run_async`.
|
247
252
|
- **[0.10.0](https://github.com/langroid/langroid/releases/tag/0.10.0)** Allow tool handlers to return arbitrary result type, including other tools.
|
@@ -134,6 +134,11 @@ teacher_task.run()
|
|
134
134
|
<details>
|
135
135
|
<summary> <b>Click to expand</b></summary>
|
136
136
|
|
137
|
+
- **Sep 2024:**
|
138
|
+
- **[0.16.0](https://github.com/langroid/langroid/releases/tag/0.16.0)** Support for OpenAI `o1-mini` and `o1-preview` models.
|
139
|
+
- **[0.15.0](https://github.com/langroid/langroid/releases/tag/0.15.0)** Cerebras API support -- run llama-3.1 models hosted on Cerebras Cloud (very fast inference).
|
140
|
+
- **[0.14.0](https://github.com/langroid/langroid/releases/tag/0.14.0)** `DocChatAgent` uses Reciprocal Rank Fusion (RRF) to rank chunks retrieved by different methods.
|
141
|
+
- **[0.12.0](https://github.com/langroid/langroid/releases/tag/0.12.0)** `run_batch_task` new option -- `stop_on_first_result` - allows termination of batch as soon as any task returns a result.
|
137
142
|
- **Aug 2024:**
|
138
143
|
- **[0.11.0](https://github.com/langroid/langroid/releases/tag/0.11.0)** Polymorphic `Task.run(), Task.run_async`.
|
139
144
|
- **[0.10.0](https://github.com/langroid/langroid/releases/tag/0.10.0)** Allow tool handlers to return arbitrary result type, including other tools.
|
@@ -98,6 +98,12 @@ class TaskConfig(BaseModel):
|
|
98
98
|
(Search for "SEND_TO" in the examples/ dir to see how this is used.)
|
99
99
|
allow_subtask_multi_oai_tools (bool): whether to allow multiple OpenAI
|
100
100
|
tool-calls to be sent to a sub-task.
|
101
|
+
recognize_string_signals (bool): whether to recognize string-based signaling
|
102
|
+
like DONE, SEND_TO, PASS, etc. Default is True, but note that we don't need
|
103
|
+
to use string-based signaling, and it is recommended to use the
|
104
|
+
new Orchestration tools instead (see agent/tools/orchestration.py),
|
105
|
+
e.g. DoneTool, SendTool, etc.
|
106
|
+
|
101
107
|
"""
|
102
108
|
|
103
109
|
inf_loop_cycle_len: int = 10
|
@@ -107,6 +113,7 @@ class TaskConfig(BaseModel):
|
|
107
113
|
logs_dir: str = "logs"
|
108
114
|
addressing_prefix: str = ""
|
109
115
|
allow_subtask_multi_oai_tools: bool = True
|
116
|
+
recognize_string_signals: bool = True
|
110
117
|
|
111
118
|
|
112
119
|
class Task:
|
@@ -1363,7 +1370,10 @@ class Task:
|
|
1363
1370
|
else:
|
1364
1371
|
# e must be this agent's Entity (LLM, AGENT or USER)
|
1365
1372
|
return self.agent.response_template(e=e, tool_messages=[result])
|
1366
|
-
|
1373
|
+
if not self.config.recognize_string_signals:
|
1374
|
+
# ignore all string-based signaling/routing
|
1375
|
+
return result
|
1376
|
+
# parse various routing/addressing strings in result
|
1367
1377
|
is_pass, recipient, content = parse_routing(
|
1368
1378
|
result,
|
1369
1379
|
addressing_prefix=self.config.addressing_prefix,
|
@@ -1490,7 +1500,7 @@ class Task:
|
|
1490
1500
|
|
1491
1501
|
content = result_msg.content if result_msg else ""
|
1492
1502
|
content_any = result_msg.content_any if result_msg else None
|
1493
|
-
if DONE in content:
|
1503
|
+
if DONE in content and self.config.recognize_string_signals:
|
1494
1504
|
# assuming it is of the form "DONE: <content>"
|
1495
1505
|
content = content.replace(DONE, "").strip()
|
1496
1506
|
oai_tool_calls = result_msg.oai_tool_calls if result_msg else None
|
@@ -1556,12 +1566,14 @@ class Task:
|
|
1556
1566
|
Returns:
|
1557
1567
|
bool: True if msg is (equivalent to) empty or None, False otherwise
|
1558
1568
|
"""
|
1569
|
+
# if ignoring string-based signaling, set pass_str to ""
|
1570
|
+
pass_str = PASS if self.config.recognize_string_signals else ""
|
1559
1571
|
return (
|
1560
1572
|
msg is None
|
1561
|
-
or (isinstance(msg, str) and msg.strip() in [
|
1573
|
+
or (isinstance(msg, str) and msg.strip() in [pass_str, ""])
|
1562
1574
|
or (
|
1563
1575
|
isinstance(msg, ChatDocument)
|
1564
|
-
and msg.content.strip() in [
|
1576
|
+
and msg.content.strip() in [pass_str, ""]
|
1565
1577
|
and msg.function_call is None
|
1566
1578
|
and msg.oai_tool_calls is None
|
1567
1579
|
and msg.oai_tool_id2result is None
|
@@ -1574,12 +1586,13 @@ class Task:
|
|
1574
1586
|
) -> bool:
|
1575
1587
|
"""Is the task done based on the response from the given responder?"""
|
1576
1588
|
|
1589
|
+
allow_done_string = self.config.recognize_string_signals
|
1577
1590
|
response_says_done = result is not None and (
|
1578
|
-
(isinstance(result, str) and DONE in result)
|
1591
|
+
(isinstance(result, str) and DONE in result and allow_done_string)
|
1579
1592
|
or (
|
1580
1593
|
isinstance(result, ChatDocument)
|
1581
1594
|
and (
|
1582
|
-
DONE in result.content
|
1595
|
+
(DONE in result.content and allow_done_string)
|
1583
1596
|
or any(
|
1584
1597
|
isinstance(t, (DoneTool, AgentDoneTool, FinalResultTool))
|
1585
1598
|
for t in result.tool_messages
|
@@ -1697,10 +1710,14 @@ class Task:
|
|
1697
1710
|
if self._is_kill():
|
1698
1711
|
return (True, StatusCode.KILL)
|
1699
1712
|
result = result or self.pending_message
|
1713
|
+
allow_done_string = self.config.recognize_string_signals
|
1700
1714
|
# An entity decided task is done, either via DoneTool,
|
1701
1715
|
# or by explicitly saying DONE
|
1702
1716
|
done_result = result is not None and (
|
1703
|
-
|
1717
|
+
(
|
1718
|
+
DONE in (result.content if isinstance(result, str) else result.content)
|
1719
|
+
and allow_done_string
|
1720
|
+
)
|
1704
1721
|
or any(
|
1705
1722
|
isinstance(t, (DoneTool, AgentDoneTool, FinalResultTool))
|
1706
1723
|
for t in result.tool_messages
|
@@ -201,16 +201,24 @@ class LLMMessage(BaseModel):
|
|
201
201
|
# link to corresponding chat document, for provenance/rewind purposes
|
202
202
|
chat_document_id: str = ""
|
203
203
|
|
204
|
-
def api_dict(self) -> Dict[str, Any]:
|
204
|
+
def api_dict(self, has_system_role: bool = True) -> Dict[str, Any]:
|
205
205
|
"""
|
206
206
|
Convert to dictionary for API request, keeping ONLY
|
207
207
|
the fields that are expected in an API call!
|
208
208
|
E.g., DROP the tool_id, since it is only for use in the Assistant API,
|
209
209
|
not the completion API.
|
210
|
+
|
211
|
+
Args:
|
212
|
+
has_system_role: whether the message has a system role (if not,
|
213
|
+
set to "user" role)
|
210
214
|
Returns:
|
211
215
|
dict: dictionary representation of LLM message
|
212
216
|
"""
|
213
217
|
d = self.dict()
|
218
|
+
# if there is a key k = "role" with value "system", change to "user"
|
219
|
+
# in case has_system_role is False
|
220
|
+
if not has_system_role and "role" in d and d["role"] == "system":
|
221
|
+
d["role"] = "user"
|
214
222
|
# drop None values since API doesn't accept them
|
215
223
|
dict_no_none = {k: v for k, v in d.items() if v is not None}
|
216
224
|
if "name" in dict_no_none and dict_no_none["name"] == "":
|
@@ -592,6 +592,12 @@ class OpenAIGPT(LanguageModel):
|
|
592
592
|
openai_chat_models = [e.value for e in OpenAIChatModel]
|
593
593
|
return self.config.chat_model in openai_chat_models
|
594
594
|
|
595
|
+
def supports_functions_or_tools(self) -> bool:
|
596
|
+
return self.is_openai_chat_model() and self.config.chat_model not in [
|
597
|
+
OpenAIChatModel.O1_MINI,
|
598
|
+
OpenAIChatModel.O1_PREVIEW,
|
599
|
+
]
|
600
|
+
|
595
601
|
def is_openai_completion_model(self) -> bool:
|
596
602
|
openai_completion_models = [e.value for e in OpenAICompletionModel]
|
597
603
|
return self.config.completion_model in openai_completion_models
|
@@ -606,6 +612,17 @@ class OpenAIGPT(LanguageModel):
|
|
606
612
|
case _:
|
607
613
|
return []
|
608
614
|
|
615
|
+
def rename_params(self) -> Dict[str, str]:
|
616
|
+
"""
|
617
|
+
Map of param name -> new name for specific models.
|
618
|
+
Currently main troublemaker is o1* series.
|
619
|
+
"""
|
620
|
+
match self.config.chat_model:
|
621
|
+
case OpenAIChatModel.O1_MINI | OpenAIChatModel.O1_PREVIEW:
|
622
|
+
return {"max_tokens": "max_completion_tokens"}
|
623
|
+
case _:
|
624
|
+
return {}
|
625
|
+
|
609
626
|
def chat_context_length(self) -> int:
|
610
627
|
"""
|
611
628
|
Context-length for chat-completion models/endpoints
|
@@ -1186,7 +1203,7 @@ class OpenAIGPT(LanguageModel):
|
|
1186
1203
|
kwargs["prompt"] = prompt
|
1187
1204
|
args = dict(
|
1188
1205
|
**kwargs,
|
1189
|
-
|
1206
|
+
max_tokens=max_tokens, # for output/completion
|
1190
1207
|
stream=self.get_stream(),
|
1191
1208
|
)
|
1192
1209
|
args = self._openai_api_call_params(args)
|
@@ -1261,7 +1278,7 @@ class OpenAIGPT(LanguageModel):
|
|
1261
1278
|
kwargs["prompt"] = prompt
|
1262
1279
|
cached, hashed_key, response = await completions_with_backoff(
|
1263
1280
|
**kwargs,
|
1264
|
-
|
1281
|
+
max_tokens=max_tokens,
|
1265
1282
|
stream=False,
|
1266
1283
|
)
|
1267
1284
|
if not isinstance(response, dict):
|
@@ -1452,12 +1469,6 @@ class OpenAIGPT(LanguageModel):
|
|
1452
1469
|
else:
|
1453
1470
|
llm_messages = messages
|
1454
1471
|
|
1455
|
-
# for models that don't support system msg, change SYSTEM role to USER
|
1456
|
-
if self.config.chat_model in NON_SYSTEM_MESSAGE_MODELS:
|
1457
|
-
for i, m in enumerate(llm_messages):
|
1458
|
-
if m.role == Role.SYSTEM:
|
1459
|
-
llm_messages[i].role = Role.USER
|
1460
|
-
|
1461
1472
|
# Azure uses different parameters. It uses ``engine`` instead of ``model``
|
1462
1473
|
# and the value should be the deployment_name not ``self.config.chat_model``
|
1463
1474
|
chat_model = self.config.chat_model
|
@@ -1467,8 +1478,14 @@ class OpenAIGPT(LanguageModel):
|
|
1467
1478
|
|
1468
1479
|
args: Dict[str, Any] = dict(
|
1469
1480
|
model=chat_model,
|
1470
|
-
messages=[
|
1471
|
-
|
1481
|
+
messages=[
|
1482
|
+
m.api_dict(
|
1483
|
+
has_system_role=self.config.chat_model
|
1484
|
+
not in NON_SYSTEM_MESSAGE_MODELS
|
1485
|
+
)
|
1486
|
+
for m in (llm_messages)
|
1487
|
+
],
|
1488
|
+
max_tokens=max_tokens,
|
1472
1489
|
stream=self.get_stream(),
|
1473
1490
|
)
|
1474
1491
|
args.update(self._openai_api_call_params(args))
|
@@ -1498,6 +1515,11 @@ class OpenAIGPT(LanguageModel):
|
|
1498
1515
|
# some models e.g. o1-mini (as of sep 2024) don't support some params,
|
1499
1516
|
# like temperature and stream, so we need to remove them.
|
1500
1517
|
args.pop(p, None)
|
1518
|
+
|
1519
|
+
param_rename_map = self.rename_params()
|
1520
|
+
for old_param, new_param in param_rename_map.items():
|
1521
|
+
if old_param in args:
|
1522
|
+
args[new_param] = args.pop(old_param)
|
1501
1523
|
return args
|
1502
1524
|
|
1503
1525
|
def _process_chat_completion_response(
|
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.16.0 → langroid-0.16.2}/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
|
File without changes
|
File without changes
|
{langroid-0.16.0 → langroid-0.16.2}/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.16.0 → langroid-0.16.2}/langroid/language_models/prompt_formatter/hf_formatter.py
RENAMED
File without changes
|
{langroid-0.16.0 → langroid-0.16.2}/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
|
File without changes
|
File without changes
|
File without changes
|