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,231 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"components": {
|
3
|
-
"atoms": {
|
4
|
-
"buttons": {
|
5
|
-
"userButton": {
|
6
|
-
"menu": {
|
7
|
-
"settings": "Settings",
|
8
|
-
"settingsKey": "S",
|
9
|
-
"APIKeys": "API Keys",
|
10
|
-
"logout": "Logout"
|
11
|
-
}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
},
|
15
|
-
"molecules": {
|
16
|
-
"newChatButton": {
|
17
|
-
"newChat": "New Chat"
|
18
|
-
},
|
19
|
-
"tasklist": {
|
20
|
-
"TaskList": {
|
21
|
-
"title": "\ud83d\uddd2\ufe0f Task List",
|
22
|
-
"loading": "Loading...",
|
23
|
-
"error": "An error occured"
|
24
|
-
}
|
25
|
-
},
|
26
|
-
"attachments": {
|
27
|
-
"cancelUpload": "Cancel upload",
|
28
|
-
"removeAttachment": "Remove attachment"
|
29
|
-
},
|
30
|
-
"newChatDialog": {
|
31
|
-
"createNewChat": "Create new chat?",
|
32
|
-
"clearChat": "This will clear the current messages and start a new chat.",
|
33
|
-
"cancel": "Cancel",
|
34
|
-
"confirm": "Confirm"
|
35
|
-
},
|
36
|
-
"settingsModal": {
|
37
|
-
"settings": "Settings",
|
38
|
-
"expandMessages": "Expand Messages",
|
39
|
-
"hideChainOfThought": "Hide Chain of Thought",
|
40
|
-
"darkMode": "Dark Mode"
|
41
|
-
},
|
42
|
-
"detailsButton": {
|
43
|
-
"using": "Using",
|
44
|
-
"running": "Running",
|
45
|
-
"took_one": "Took {{count}} step",
|
46
|
-
"took_other": "Took {{count}} steps"
|
47
|
-
},
|
48
|
-
"auth": {
|
49
|
-
"authLogin": {
|
50
|
-
"title": "Login to access the app.",
|
51
|
-
"form": {
|
52
|
-
"email": "Email address",
|
53
|
-
"password": "Password",
|
54
|
-
"noAccount": "Don't have an account?",
|
55
|
-
"alreadyHaveAccount": "Already have an account?",
|
56
|
-
"signup": "Sign Up",
|
57
|
-
"signin": "Sign In",
|
58
|
-
"or": "OR",
|
59
|
-
"continue": "Continue",
|
60
|
-
"forgotPassword": "Forgot password?",
|
61
|
-
"passwordMustContain": "Your password must contain:",
|
62
|
-
"emailRequired": "email is a required field",
|
63
|
-
"passwordRequired": "password is a required field"
|
64
|
-
},
|
65
|
-
"error": {
|
66
|
-
"default": "Unable to sign in.",
|
67
|
-
"signin": "Try signing in with a different account.",
|
68
|
-
"oauthsignin": "Try signing in with a different account.",
|
69
|
-
"redirect_uri_mismatch": "The redirect URI is not matching the oauth app configuration.",
|
70
|
-
"oauthcallbackerror": "Try signing in with a different account.",
|
71
|
-
"oauthcreateaccount": "Try signing in with a different account.",
|
72
|
-
"emailcreateaccount": "Try signing in with a different account.",
|
73
|
-
"callback": "Try signing in with a different account.",
|
74
|
-
"oauthaccountnotlinked": "To confirm your identity, sign in with the same account you used originally.",
|
75
|
-
"emailsignin": "The e-mail could not be sent.",
|
76
|
-
"emailverify": "Please verify your email, a new email has been sent.",
|
77
|
-
"credentialssignin": "Sign in failed. Check the details you provided are correct.",
|
78
|
-
"sessionrequired": "Please sign in to access this page."
|
79
|
-
}
|
80
|
-
},
|
81
|
-
"authVerifyEmail": {
|
82
|
-
"almostThere": "You're almost there! We've sent an email to ",
|
83
|
-
"verifyEmailLink": "Please click on the link in that email to complete your signup.",
|
84
|
-
"didNotReceive": "Can't find the email?",
|
85
|
-
"resendEmail": "Resend email",
|
86
|
-
"goBack": "Go Back",
|
87
|
-
"emailSent": "Email sent successfully.",
|
88
|
-
"verifyEmail": "Verify your email address"
|
89
|
-
},
|
90
|
-
"providerButton": {
|
91
|
-
"continue": "Continue with {{provider}}",
|
92
|
-
"signup": "Sign up with {{provider}}"
|
93
|
-
},
|
94
|
-
"authResetPassword": {
|
95
|
-
"newPasswordRequired": "New password is a required field",
|
96
|
-
"passwordsMustMatch": "Passwords must match",
|
97
|
-
"confirmPasswordRequired": "Confirm password is a required field",
|
98
|
-
"newPassword": "New password",
|
99
|
-
"confirmPassword": "Confirm password",
|
100
|
-
"resetPassword": "Reset Password"
|
101
|
-
},
|
102
|
-
"authForgotPassword": {
|
103
|
-
"email": "Email address",
|
104
|
-
"emailRequired": "email is a required field",
|
105
|
-
"emailSent": "Please check the email address {{email}} for instructions to reset your password.",
|
106
|
-
"enterEmail": "Enter your email address and we will send you instructions to reset your password.",
|
107
|
-
"resendEmail": "Resend email",
|
108
|
-
"continue": "Continue",
|
109
|
-
"goBack": "Go Back"
|
110
|
-
}
|
111
|
-
}
|
112
|
-
},
|
113
|
-
"organisms": {
|
114
|
-
"chat": {
|
115
|
-
"history": {
|
116
|
-
"index": {
|
117
|
-
"showHistory": "Show history",
|
118
|
-
"lastInputs": "Last Inputs",
|
119
|
-
"noInputs": "Such empty...",
|
120
|
-
"loading": "Loading..."
|
121
|
-
}
|
122
|
-
},
|
123
|
-
"inputBox": {
|
124
|
-
"input": {
|
125
|
-
"placeholder": "Type your message here..."
|
126
|
-
},
|
127
|
-
"speechButton": {
|
128
|
-
"start": "Start recording",
|
129
|
-
"stop": "Stop recording"
|
130
|
-
},
|
131
|
-
"SubmitButton": {
|
132
|
-
"sendMessage": "Send message",
|
133
|
-
"stopTask": "Stop Task"
|
134
|
-
},
|
135
|
-
"UploadButton": {
|
136
|
-
"attachFiles": "Attach files"
|
137
|
-
},
|
138
|
-
"waterMark": {
|
139
|
-
"text": "Built with"
|
140
|
-
}
|
141
|
-
},
|
142
|
-
"Messages": {
|
143
|
-
"index": {
|
144
|
-
"running": "Running",
|
145
|
-
"executedSuccessfully": "executed successfully",
|
146
|
-
"failed": "failed",
|
147
|
-
"feedbackUpdated": "Feedback updated",
|
148
|
-
"updating": "Updating"
|
149
|
-
}
|
150
|
-
},
|
151
|
-
"dropScreen": {
|
152
|
-
"dropYourFilesHere": "Drop your files here"
|
153
|
-
},
|
154
|
-
"index": {
|
155
|
-
"failedToUpload": "Failed to upload",
|
156
|
-
"cancelledUploadOf": "Cancelled upload of",
|
157
|
-
"couldNotReachServer": "Could not reach the server",
|
158
|
-
"continuingChat": "Continuing previous chat"
|
159
|
-
},
|
160
|
-
"settings": {
|
161
|
-
"settingsPanel": "Settings panel",
|
162
|
-
"reset": "Reset",
|
163
|
-
"cancel": "Cancel",
|
164
|
-
"confirm": "Confirm"
|
165
|
-
}
|
166
|
-
},
|
167
|
-
"threadHistory": {
|
168
|
-
"sidebar": {
|
169
|
-
"filters": {
|
170
|
-
"FeedbackSelect": {
|
171
|
-
"feedbackAll": "Feedback: All",
|
172
|
-
"feedbackPositive": "Feedback: Positive",
|
173
|
-
"feedbackNegative": "Feedback: Negative"
|
174
|
-
},
|
175
|
-
"SearchBar": {
|
176
|
-
"search": "Search"
|
177
|
-
}
|
178
|
-
},
|
179
|
-
"DeleteThreadButton": {
|
180
|
-
"confirmMessage": "This will delete the thread as well as it's messages and elements.",
|
181
|
-
"cancel": "Cancel",
|
182
|
-
"confirm": "Confirm",
|
183
|
-
"deletingChat": "Deleting chat",
|
184
|
-
"chatDeleted": "Chat deleted"
|
185
|
-
},
|
186
|
-
"index": {
|
187
|
-
"pastChats": "Past Chats"
|
188
|
-
},
|
189
|
-
"ThreadList": {
|
190
|
-
"empty": "Empty...",
|
191
|
-
"today": "Today",
|
192
|
-
"yesterday": "Yesterday",
|
193
|
-
"previous7days": "Previous 7 days",
|
194
|
-
"previous30days": "Previous 30 days"
|
195
|
-
},
|
196
|
-
"TriggerButton": {
|
197
|
-
"closeSidebar": "Close sidebar",
|
198
|
-
"openSidebar": "Open sidebar"
|
199
|
-
}
|
200
|
-
},
|
201
|
-
"Thread": {
|
202
|
-
"backToChat": "Go back to chat",
|
203
|
-
"chatCreatedOn": "This chat was created on"
|
204
|
-
}
|
205
|
-
},
|
206
|
-
"header": {
|
207
|
-
"chat": "Chat",
|
208
|
-
"readme": "Readme"
|
209
|
-
}
|
210
|
-
}
|
211
|
-
},
|
212
|
-
"hooks": {
|
213
|
-
"useLLMProviders": {
|
214
|
-
"failedToFetchProviders": "Failed to fetch providers:"
|
215
|
-
}
|
216
|
-
},
|
217
|
-
"pages": {
|
218
|
-
"Design": {},
|
219
|
-
"Env": {
|
220
|
-
"savedSuccessfully": "Saved successfully",
|
221
|
-
"requiredApiKeys": "Required API Keys",
|
222
|
-
"requiredApiKeysInfo": "To use this app, the following API keys are required. The keys are stored on your device's local storage."
|
223
|
-
},
|
224
|
-
"Page": {
|
225
|
-
"notPartOfProject": "You are not part of this project."
|
226
|
-
},
|
227
|
-
"ResumeButton": {
|
228
|
-
"resumeChat": "Resume Chat"
|
229
|
-
}
|
230
|
-
}
|
231
|
-
}
|
langroid/utils/__init__.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
from . import configuration
|
2
|
-
from . import globals
|
3
|
-
from . import constants
|
4
|
-
from . import logging
|
5
|
-
from . import pydantic_utils
|
6
|
-
from . import system
|
7
|
-
from . import output
|
8
|
-
from . import object_registry
|
9
|
-
|
10
|
-
__all__ = [
|
11
|
-
"configuration",
|
12
|
-
"globals",
|
13
|
-
"constants",
|
14
|
-
"logging",
|
15
|
-
"pydantic_utils",
|
16
|
-
"system",
|
17
|
-
"output",
|
18
|
-
"object_registry",
|
19
|
-
]
|
@@ -1,103 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Graph algos.
|
3
|
-
"""
|
4
|
-
|
5
|
-
from typing import Dict, List, no_type_check
|
6
|
-
|
7
|
-
import numpy as np
|
8
|
-
|
9
|
-
|
10
|
-
@no_type_check
|
11
|
-
def topological_sort(order: np.array) -> List[int]:
|
12
|
-
"""
|
13
|
-
Given a directed adjacency matrix, return a topological sort of the nodes.
|
14
|
-
order[i,j] = -1 means there is an edge from i to j.
|
15
|
-
order[i,j] = 0 means there is no edge from i to j.
|
16
|
-
order[i,j] = 1 means there is an edge from j to i.
|
17
|
-
|
18
|
-
Args:
|
19
|
-
order (np.array): The adjacency matrix.
|
20
|
-
|
21
|
-
Returns:
|
22
|
-
List[int]: The topological sort of the nodes.
|
23
|
-
|
24
|
-
"""
|
25
|
-
n = order.shape[0]
|
26
|
-
|
27
|
-
# Calculate the in-degrees
|
28
|
-
in_degree = [0] * n
|
29
|
-
for i in range(n):
|
30
|
-
for j in range(n):
|
31
|
-
if order[i, j] == -1:
|
32
|
-
in_degree[j] += 1
|
33
|
-
|
34
|
-
# Initialize the queue with nodes of in-degree 0
|
35
|
-
queue = [i for i in range(n) if in_degree[i] == 0]
|
36
|
-
result = []
|
37
|
-
|
38
|
-
while queue:
|
39
|
-
node = queue.pop(0)
|
40
|
-
result.append(node)
|
41
|
-
|
42
|
-
for i in range(n):
|
43
|
-
if order[node, i] == -1:
|
44
|
-
in_degree[i] -= 1
|
45
|
-
if in_degree[i] == 0:
|
46
|
-
queue.append(i)
|
47
|
-
|
48
|
-
assert len(result) == n, "Cycle detected"
|
49
|
-
return result
|
50
|
-
|
51
|
-
|
52
|
-
@no_type_check
|
53
|
-
def components(order: np.ndarray) -> List[List[int]]:
|
54
|
-
"""
|
55
|
-
Find the connected components in an undirected graph represented by a matrix.
|
56
|
-
|
57
|
-
Args:
|
58
|
-
order (np.ndarray): A matrix with values 0 or 1 indicating
|
59
|
-
undirected graph edges. `order[i][j] = 1` means an edge between `i`
|
60
|
-
and `j`, and `0` means no edge.
|
61
|
-
|
62
|
-
Returns:
|
63
|
-
List[List[int]]: A list of List where each List contains the indices of
|
64
|
-
nodes in the same connected component.
|
65
|
-
|
66
|
-
Example:
|
67
|
-
order = np.array([
|
68
|
-
[1, 1, 0, 0],
|
69
|
-
[1, 1, 1, 0],
|
70
|
-
[0, 1, 1, 0],
|
71
|
-
[0, 0, 0, 1]
|
72
|
-
])
|
73
|
-
components(order)
|
74
|
-
# [[0, 1, 2], [3]]
|
75
|
-
"""
|
76
|
-
|
77
|
-
i2g: Dict[int, int] = {} # index to group mapping
|
78
|
-
next_group = 0
|
79
|
-
n = order.shape[0]
|
80
|
-
for i in range(n):
|
81
|
-
connected_groups = {i2g[j] for j in np.nonzero(order[i, :])[0] if j in i2g}
|
82
|
-
|
83
|
-
# If the node is not part of any group
|
84
|
-
# and is not connected to any groups, assign a new group
|
85
|
-
if not connected_groups:
|
86
|
-
i2g[i] = next_group
|
87
|
-
next_group += 1
|
88
|
-
else:
|
89
|
-
# If the node is connected to multiple groups, we merge them
|
90
|
-
main_group = min(connected_groups)
|
91
|
-
for j in np.nonzero(order[i, :])[0]:
|
92
|
-
if i2g.get(j) in connected_groups:
|
93
|
-
i2g[j] = main_group
|
94
|
-
i2g[i] = main_group
|
95
|
-
|
96
|
-
# Convert i2g to a list of Lists
|
97
|
-
groups: Dict[int, List[int]] = {}
|
98
|
-
for index, group in i2g.items():
|
99
|
-
if group not in groups:
|
100
|
-
groups[group] = []
|
101
|
-
groups[group].append(index)
|
102
|
-
|
103
|
-
return list(groups.values())
|
langroid/utils/configuration.py
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
import copy
|
2
|
-
import os
|
3
|
-
from contextlib import contextmanager
|
4
|
-
from typing import Iterator, List, Literal
|
5
|
-
|
6
|
-
from dotenv import find_dotenv, load_dotenv
|
7
|
-
|
8
|
-
from langroid.pydantic_v1 import BaseSettings
|
9
|
-
|
10
|
-
|
11
|
-
class Settings(BaseSettings):
|
12
|
-
# NOTE all of these can be overridden in your .env file with upper-case names,
|
13
|
-
# for example CACHE_TYPE=momento
|
14
|
-
debug: bool = False # show debug messages?
|
15
|
-
max_turns: int = -1 # maximum number of turns in a task (to avoid inf loop)
|
16
|
-
progress: bool = False # show progress spinners/bars?
|
17
|
-
stream: bool = True # stream output?
|
18
|
-
cache: bool = True # use cache?
|
19
|
-
cache_type: Literal["redis", "fakeredis", "momento", "none"] = "redis" # cache type
|
20
|
-
chat_model: str = "" # language model name, e.g. litellm/ollama/llama2
|
21
|
-
quiet: bool = False # quiet mode (i.e. suppress all output)?
|
22
|
-
notebook: bool = False # running in a notebook?
|
23
|
-
|
24
|
-
class Config:
|
25
|
-
extra = "forbid"
|
26
|
-
|
27
|
-
|
28
|
-
load_dotenv(find_dotenv(usecwd=True)) # get settings from .env file
|
29
|
-
settings = Settings()
|
30
|
-
|
31
|
-
|
32
|
-
def update_global_settings(cfg: BaseSettings, keys: List[str]) -> None:
|
33
|
-
"""
|
34
|
-
Update global settings so modules can access them via (as an example):
|
35
|
-
```
|
36
|
-
from langroid.utils.configuration import settings
|
37
|
-
if settings.debug...
|
38
|
-
```
|
39
|
-
Caution we do not want to have too many such global settings!
|
40
|
-
Args:
|
41
|
-
cfg: pydantic config, typically from a main script
|
42
|
-
keys: which keys from cfg to use, to update the global settings object
|
43
|
-
"""
|
44
|
-
config_dict = cfg.dict()
|
45
|
-
|
46
|
-
# Filter the config_dict based on the keys
|
47
|
-
filtered_config = {key: config_dict[key] for key in keys if key in config_dict}
|
48
|
-
|
49
|
-
# create a new Settings() object to let pydantic validate it
|
50
|
-
new_settings = Settings(**filtered_config)
|
51
|
-
|
52
|
-
# Update the unique global settings object
|
53
|
-
settings.__dict__.update(new_settings.__dict__)
|
54
|
-
|
55
|
-
|
56
|
-
def set_global(key_vals: Settings) -> None:
|
57
|
-
"""Update the unique global settings object"""
|
58
|
-
settings.__dict__.update(key_vals.__dict__)
|
59
|
-
|
60
|
-
|
61
|
-
@contextmanager
|
62
|
-
def temporary_settings(temp_settings: Settings) -> Iterator[None]:
|
63
|
-
"""Temporarily update the global settings and restore them afterward."""
|
64
|
-
original_settings = copy.deepcopy(settings)
|
65
|
-
|
66
|
-
set_global(temp_settings)
|
67
|
-
|
68
|
-
try:
|
69
|
-
yield
|
70
|
-
finally:
|
71
|
-
settings.__dict__.update(original_settings.__dict__)
|
72
|
-
|
73
|
-
|
74
|
-
@contextmanager
|
75
|
-
def quiet_mode(quiet: bool = True) -> Iterator[None]:
|
76
|
-
"""Temporarily set quiet=True in global settings and restore afterward."""
|
77
|
-
original_settings = copy.deepcopy(settings)
|
78
|
-
if quiet:
|
79
|
-
temp_settings = original_settings.copy(update={"quiet": True})
|
80
|
-
set_global(temp_settings)
|
81
|
-
|
82
|
-
try:
|
83
|
-
yield
|
84
|
-
finally:
|
85
|
-
if quiet:
|
86
|
-
settings.__dict__.update(original_settings.__dict__)
|
87
|
-
|
88
|
-
|
89
|
-
def set_env(settings: BaseSettings) -> None:
|
90
|
-
"""
|
91
|
-
Set environment variables from a BaseSettings instance
|
92
|
-
Args:
|
93
|
-
settings (BaseSettings): desired settings
|
94
|
-
Returns:
|
95
|
-
"""
|
96
|
-
for field_name, field in settings.__class__.__fields__.items():
|
97
|
-
env_var_name = field.field_info.extra.get("env", field_name).upper()
|
98
|
-
os.environ[env_var_name] = str(settings.dict()[field_name])
|
langroid/utils/constants.py
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
from langroid.pydantic_v1 import BaseModel
|
2
|
-
|
3
|
-
|
4
|
-
# Define the ANSI escape sequences for various colors and reset
|
5
|
-
class Colors(BaseModel):
|
6
|
-
RED: str = "\033[31m"
|
7
|
-
BLUE: str = "\033[34m"
|
8
|
-
GREEN: str = "\033[32m"
|
9
|
-
ORANGE: str = "\033[33m" # no standard ANSI color for orange; using yellow
|
10
|
-
CYAN: str = "\033[36m"
|
11
|
-
MAGENTA: str = "\033[35m"
|
12
|
-
YELLOW: str = "\033[33m"
|
13
|
-
RESET: str = "\033[0m"
|
14
|
-
|
15
|
-
|
16
|
-
NO_ANSWER = "DO-NOT-KNOW"
|
17
|
-
DONE = "DONE"
|
18
|
-
USER_QUIT_STRINGS = ["q", "x", "quit", "exit", "bye", DONE]
|
19
|
-
PASS = "__PASS__"
|
20
|
-
PASS_TO = PASS + ":"
|
21
|
-
SEND_TO = "__SEND__:"
|
22
|
-
TOOL = "TOOL"
|
23
|
-
# This is a recommended setting for TaskConfig.addressing_prefix if using it at all;
|
24
|
-
# prefer to use `RecipientTool` to allow agents addressing others.
|
25
|
-
# Caution the AT string should NOT contain any 'word' characters, i.e.
|
26
|
-
# it no letters, digits or underscores.
|
27
|
-
# See tests/main/test_msg_routing for example usage
|
28
|
-
AT = "|@|"
|
29
|
-
TOOL_BEGIN = "TOOL_BEGIN"
|
30
|
-
TOOL_END = "TOOL_END"
|
langroid/utils/docker.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
import os
|
3
|
-
import subprocess
|
4
|
-
|
5
|
-
import docker
|
6
|
-
|
7
|
-
logger = logging.getLogger(__name__)
|
8
|
-
|
9
|
-
|
10
|
-
def docker_compose_up(file_path: str, name: str) -> None:
|
11
|
-
"""
|
12
|
-
Launch docker-compose file with given name, using python SDK rather than CLI.
|
13
|
-
This lets us eliminate the extra step of having to `run docker-compose up` on the
|
14
|
-
command line before running the main script.
|
15
|
-
|
16
|
-
Args:
|
17
|
-
file_path: relative path to docker-compose file
|
18
|
-
name: name of docker-compose project (i.e. container prefix)
|
19
|
-
|
20
|
-
"""
|
21
|
-
# Load docker-compose file
|
22
|
-
compose_file = os.path.abspath(file_path)
|
23
|
-
|
24
|
-
# Connect to Docker daemon
|
25
|
-
client = docker.from_env()
|
26
|
-
|
27
|
-
# Get list of running containers
|
28
|
-
containers = client.containers.list()
|
29
|
-
|
30
|
-
# Check if containers defined in docker-compose file are already running
|
31
|
-
for container in containers:
|
32
|
-
if name in container.name:
|
33
|
-
logging.info(f"Containers are already running, e.g.: {container.name}")
|
34
|
-
return
|
35
|
-
|
36
|
-
compose_command = ["docker-compose", "-f", compose_file, "up", "-d"]
|
37
|
-
subprocess.run(compose_command)
|