langroid 0.31.1__py3-none-any.whl → 0.33.3__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-0.31.1.dist-info → langroid-0.33.3.dist-info}/METADATA +150 -124
- langroid-0.33.3.dist-info/RECORD +7 -0
- {langroid-0.31.1.dist-info → langroid-0.33.3.dist-info}/WHEEL +1 -1
- langroid-0.33.3.dist-info/entry_points.txt +4 -0
- pyproject.toml +317 -212
- langroid/__init__.py +0 -106
- langroid/agent/.chainlit/config.toml +0 -121
- langroid/agent/.chainlit/translations/bn.json +0 -231
- langroid/agent/.chainlit/translations/en-US.json +0 -229
- langroid/agent/.chainlit/translations/gu.json +0 -231
- langroid/agent/.chainlit/translations/he-IL.json +0 -231
- langroid/agent/.chainlit/translations/hi.json +0 -231
- langroid/agent/.chainlit/translations/kn.json +0 -231
- langroid/agent/.chainlit/translations/ml.json +0 -231
- langroid/agent/.chainlit/translations/mr.json +0 -231
- langroid/agent/.chainlit/translations/ta.json +0 -231
- langroid/agent/.chainlit/translations/te.json +0 -231
- langroid/agent/.chainlit/translations/zh-CN.json +0 -229
- langroid/agent/__init__.py +0 -41
- langroid/agent/base.py +0 -1981
- langroid/agent/batch.py +0 -398
- langroid/agent/callbacks/__init__.py +0 -0
- langroid/agent/callbacks/chainlit.py +0 -598
- langroid/agent/chat_agent.py +0 -1899
- langroid/agent/chat_document.py +0 -454
- langroid/agent/helpers.py +0 -0
- langroid/agent/junk +0 -13
- langroid/agent/openai_assistant.py +0 -882
- langroid/agent/special/__init__.py +0 -59
- langroid/agent/special/arangodb/__init__.py +0 -0
- langroid/agent/special/arangodb/arangodb_agent.py +0 -656
- langroid/agent/special/arangodb/system_messages.py +0 -186
- langroid/agent/special/arangodb/tools.py +0 -107
- langroid/agent/special/arangodb/utils.py +0 -36
- langroid/agent/special/doc_chat_agent.py +0 -1466
- langroid/agent/special/lance_doc_chat_agent.py +0 -262
- langroid/agent/special/lance_rag/__init__.py +0 -9
- langroid/agent/special/lance_rag/critic_agent.py +0 -198
- langroid/agent/special/lance_rag/lance_rag_task.py +0 -82
- langroid/agent/special/lance_rag/query_planner_agent.py +0 -260
- langroid/agent/special/lance_tools.py +0 -61
- langroid/agent/special/neo4j/__init__.py +0 -0
- langroid/agent/special/neo4j/csv_kg_chat.py +0 -174
- langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -433
- langroid/agent/special/neo4j/system_messages.py +0 -120
- langroid/agent/special/neo4j/tools.py +0 -32
- langroid/agent/special/relevance_extractor_agent.py +0 -127
- langroid/agent/special/retriever_agent.py +0 -56
- langroid/agent/special/sql/__init__.py +0 -17
- langroid/agent/special/sql/sql_chat_agent.py +0 -654
- langroid/agent/special/sql/utils/__init__.py +0 -21
- langroid/agent/special/sql/utils/description_extractors.py +0 -190
- langroid/agent/special/sql/utils/populate_metadata.py +0 -85
- langroid/agent/special/sql/utils/system_message.py +0 -35
- langroid/agent/special/sql/utils/tools.py +0 -64
- langroid/agent/special/table_chat_agent.py +0 -263
- langroid/agent/structured_message.py +0 -9
- langroid/agent/task.py +0 -2093
- langroid/agent/tool_message.py +0 -393
- langroid/agent/tools/__init__.py +0 -38
- langroid/agent/tools/duckduckgo_search_tool.py +0 -50
- langroid/agent/tools/file_tools.py +0 -234
- langroid/agent/tools/google_search_tool.py +0 -39
- langroid/agent/tools/metaphor_search_tool.py +0 -67
- langroid/agent/tools/orchestration.py +0 -303
- langroid/agent/tools/recipient_tool.py +0 -235
- langroid/agent/tools/retrieval_tool.py +0 -32
- langroid/agent/tools/rewind_tool.py +0 -137
- langroid/agent/tools/segment_extract_tool.py +0 -41
- langroid/agent/typed_task.py +0 -19
- langroid/agent/xml_tool_message.py +0 -382
- langroid/agent_config.py +0 -0
- langroid/cachedb/__init__.py +0 -17
- langroid/cachedb/base.py +0 -58
- langroid/cachedb/momento_cachedb.py +0 -108
- langroid/cachedb/redis_cachedb.py +0 -153
- langroid/embedding_models/__init__.py +0 -39
- langroid/embedding_models/base.py +0 -74
- langroid/embedding_models/clustering.py +0 -189
- langroid/embedding_models/models.py +0 -461
- langroid/embedding_models/protoc/__init__.py +0 -0
- langroid/embedding_models/protoc/embeddings.proto +0 -19
- langroid/embedding_models/protoc/embeddings_pb2.py +0 -33
- langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -50
- langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -79
- langroid/embedding_models/remote_embeds.py +0 -153
- langroid/exceptions.py +0 -65
- langroid/experimental/team-save.py +0 -391
- langroid/language_models/.chainlit/config.toml +0 -121
- langroid/language_models/.chainlit/translations/en-US.json +0 -231
- langroid/language_models/__init__.py +0 -53
- langroid/language_models/azure_openai.py +0 -153
- langroid/language_models/base.py +0 -678
- langroid/language_models/config.py +0 -18
- langroid/language_models/mock_lm.py +0 -124
- langroid/language_models/openai_gpt.py +0 -1923
- langroid/language_models/prompt_formatter/__init__.py +0 -16
- langroid/language_models/prompt_formatter/base.py +0 -40
- langroid/language_models/prompt_formatter/hf_formatter.py +0 -132
- langroid/language_models/prompt_formatter/llama2_formatter.py +0 -75
- langroid/language_models/utils.py +0 -147
- langroid/mytypes.py +0 -84
- langroid/parsing/__init__.py +0 -52
- langroid/parsing/agent_chats.py +0 -38
- langroid/parsing/code-parsing.md +0 -86
- langroid/parsing/code_parser.py +0 -121
- langroid/parsing/config.py +0 -0
- langroid/parsing/document_parser.py +0 -718
- langroid/parsing/image_text.py +0 -32
- langroid/parsing/para_sentence_split.py +0 -62
- langroid/parsing/parse_json.py +0 -155
- langroid/parsing/parser.py +0 -313
- langroid/parsing/repo_loader.py +0 -790
- langroid/parsing/routing.py +0 -36
- langroid/parsing/search.py +0 -275
- langroid/parsing/spider.py +0 -102
- langroid/parsing/table_loader.py +0 -94
- langroid/parsing/url_loader.py +0 -111
- langroid/parsing/url_loader_cookies.py +0 -73
- langroid/parsing/urls.py +0 -273
- langroid/parsing/utils.py +0 -373
- langroid/parsing/web_search.py +0 -155
- langroid/prompts/__init__.py +0 -9
- langroid/prompts/chat-gpt4-system-prompt.md +0 -68
- langroid/prompts/dialog.py +0 -17
- langroid/prompts/prompts_config.py +0 -5
- langroid/prompts/templates.py +0 -141
- langroid/pydantic_v1/__init__.py +0 -10
- langroid/pydantic_v1/main.py +0 -4
- langroid/utils/.chainlit/config.toml +0 -121
- langroid/utils/.chainlit/translations/en-US.json +0 -231
- langroid/utils/__init__.py +0 -19
- langroid/utils/algorithms/__init__.py +0 -3
- langroid/utils/algorithms/graph.py +0 -103
- langroid/utils/configuration.py +0 -98
- langroid/utils/constants.py +0 -30
- langroid/utils/docker.py +0 -37
- langroid/utils/git_utils.py +0 -252
- langroid/utils/globals.py +0 -49
- langroid/utils/llms/__init__.py +0 -0
- langroid/utils/llms/strings.py +0 -8
- langroid/utils/logging.py +0 -135
- langroid/utils/object_registry.py +0 -66
- langroid/utils/output/__init__.py +0 -20
- langroid/utils/output/citations.py +0 -41
- langroid/utils/output/printing.py +0 -99
- langroid/utils/output/status.py +0 -40
- langroid/utils/pandas_utils.py +0 -30
- langroid/utils/pydantic_utils.py +0 -602
- langroid/utils/system.py +0 -286
- langroid/utils/types.py +0 -93
- langroid/utils/web/__init__.py +0 -0
- langroid/utils/web/login.py +0 -83
- langroid/vector_store/__init__.py +0 -50
- langroid/vector_store/base.py +0 -357
- langroid/vector_store/chromadb.py +0 -214
- langroid/vector_store/lancedb.py +0 -401
- langroid/vector_store/meilisearch.py +0 -299
- langroid/vector_store/momento.py +0 -278
- langroid/vector_store/qdrant_cloud.py +0 -6
- langroid/vector_store/qdrantdb.py +0 -468
- langroid-0.31.1.dist-info/RECORD +0 -162
- {langroid-0.31.1.dist-info → langroid-0.33.3.dist-info/licenses}/LICENSE +0 -0
@@ -1,124 +0,0 @@
|
|
1
|
-
"""Mock Language Model for testing"""
|
2
|
-
|
3
|
-
from typing import Awaitable, Callable, Dict, List, Optional, Union
|
4
|
-
|
5
|
-
import langroid.language_models as lm
|
6
|
-
from langroid.language_models import LLMResponse
|
7
|
-
from langroid.language_models.base import (
|
8
|
-
LanguageModel,
|
9
|
-
LLMConfig,
|
10
|
-
OpenAIJsonSchemaSpec,
|
11
|
-
OpenAIToolSpec,
|
12
|
-
ToolChoiceTypes,
|
13
|
-
)
|
14
|
-
from langroid.utils.types import to_string
|
15
|
-
|
16
|
-
|
17
|
-
def none_fn(x: str) -> None | str:
|
18
|
-
return None
|
19
|
-
|
20
|
-
|
21
|
-
class MockLMConfig(LLMConfig):
|
22
|
-
"""
|
23
|
-
Mock Language Model Configuration.
|
24
|
-
|
25
|
-
Attributes:
|
26
|
-
response_dict (Dict[str, str]): A "response rule-book", in the form of a
|
27
|
-
dictionary; if last msg in dialog is x,then respond with response_dict[x]
|
28
|
-
"""
|
29
|
-
|
30
|
-
response_dict: Dict[str, str] = {}
|
31
|
-
response_fn: Callable[[str], None | str] = none_fn
|
32
|
-
response_fn_async: Optional[Callable[[str], Awaitable[Optional[str]]]] = None
|
33
|
-
default_response: str = "Mock response"
|
34
|
-
|
35
|
-
type: str = "mock"
|
36
|
-
|
37
|
-
|
38
|
-
class MockLM(LanguageModel):
|
39
|
-
|
40
|
-
def __init__(self, config: MockLMConfig = MockLMConfig()):
|
41
|
-
super().__init__(config)
|
42
|
-
self.config: MockLMConfig = config
|
43
|
-
|
44
|
-
def _response(self, msg: str) -> LLMResponse:
|
45
|
-
# response is based on this fallback order:
|
46
|
-
# - response_dict
|
47
|
-
# - response_fn
|
48
|
-
# - default_response
|
49
|
-
mapped_response = self.config.response_dict.get(
|
50
|
-
msg, self.config.response_fn(msg) or self.config.default_response
|
51
|
-
)
|
52
|
-
return lm.LLMResponse(
|
53
|
-
message=to_string(mapped_response),
|
54
|
-
cached=False,
|
55
|
-
)
|
56
|
-
|
57
|
-
async def _response_async(self, msg: str) -> LLMResponse:
|
58
|
-
# response is based on this fallback order:
|
59
|
-
# - response_dict
|
60
|
-
# - response_fn_async
|
61
|
-
# - response_fn
|
62
|
-
# - default_response
|
63
|
-
if self.config.response_fn_async is not None:
|
64
|
-
response = await self.config.response_fn_async(msg)
|
65
|
-
else:
|
66
|
-
response = self.config.response_fn(msg)
|
67
|
-
|
68
|
-
mapped_response = self.config.response_dict.get(
|
69
|
-
msg, response or self.config.default_response
|
70
|
-
)
|
71
|
-
return lm.LLMResponse(
|
72
|
-
message=to_string(mapped_response),
|
73
|
-
cached=False,
|
74
|
-
)
|
75
|
-
|
76
|
-
def chat(
|
77
|
-
self,
|
78
|
-
messages: Union[str, List[lm.LLMMessage]],
|
79
|
-
max_tokens: int = 200,
|
80
|
-
tools: Optional[List[OpenAIToolSpec]] = None,
|
81
|
-
tool_choice: ToolChoiceTypes | Dict[str, str | Dict[str, str]] = "auto",
|
82
|
-
functions: Optional[List[lm.LLMFunctionSpec]] = None,
|
83
|
-
function_call: str | Dict[str, str] = "auto",
|
84
|
-
response_format: Optional[OpenAIJsonSchemaSpec] = None,
|
85
|
-
) -> lm.LLMResponse:
|
86
|
-
"""
|
87
|
-
Mock chat function for testing
|
88
|
-
"""
|
89
|
-
last_msg = messages[-1].content if isinstance(messages, list) else messages
|
90
|
-
return self._response(last_msg)
|
91
|
-
|
92
|
-
async def achat(
|
93
|
-
self,
|
94
|
-
messages: Union[str, List[lm.LLMMessage]],
|
95
|
-
max_tokens: int = 200,
|
96
|
-
tools: Optional[List[OpenAIToolSpec]] = None,
|
97
|
-
tool_choice: ToolChoiceTypes | Dict[str, str | Dict[str, str]] = "auto",
|
98
|
-
functions: Optional[List[lm.LLMFunctionSpec]] = None,
|
99
|
-
function_call: str | Dict[str, str] = "auto",
|
100
|
-
response_format: Optional[OpenAIJsonSchemaSpec] = None,
|
101
|
-
) -> lm.LLMResponse:
|
102
|
-
"""
|
103
|
-
Mock chat function for testing
|
104
|
-
"""
|
105
|
-
last_msg = messages[-1].content if isinstance(messages, list) else messages
|
106
|
-
return await self._response_async(last_msg)
|
107
|
-
|
108
|
-
def generate(self, prompt: str, max_tokens: int = 200) -> lm.LLMResponse:
|
109
|
-
"""
|
110
|
-
Mock generate function for testing
|
111
|
-
"""
|
112
|
-
return self._response(prompt)
|
113
|
-
|
114
|
-
async def agenerate(self, prompt: str, max_tokens: int = 200) -> LLMResponse:
|
115
|
-
"""
|
116
|
-
Mock generate function for testing
|
117
|
-
"""
|
118
|
-
return await self._response_async(prompt)
|
119
|
-
|
120
|
-
def get_stream(self) -> bool:
|
121
|
-
return False
|
122
|
-
|
123
|
-
def set_stream(self, stream: bool) -> bool:
|
124
|
-
return False
|