langroid 0.1.34__py3-none-any.whl → 0.1.36__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/agent/base.py +2 -2
- langroid/agent/special/table_chat_agent.py +2 -1
- langroid/parsing/utils.py +33 -0
- {langroid-0.1.34.dist-info → langroid-0.1.36.dist-info}/METADATA +1 -1
- {langroid-0.1.34.dist-info → langroid-0.1.36.dist-info}/RECORD +7 -7
- {langroid-0.1.34.dist-info → langroid-0.1.36.dist-info}/LICENSE +0 -0
- {langroid-0.1.34.dist-info → langroid-0.1.36.dist-info}/WHEEL +0 -0
langroid/agent/base.py
CHANGED
@@ -525,8 +525,8 @@ class Agent(ABC):
|
|
525
525
|
try:
|
526
526
|
result = handler_method(tool)
|
527
527
|
except Exception as e:
|
528
|
-
|
529
|
-
|
528
|
+
# return the error message to the LLM so it can try to fix the error
|
529
|
+
result = f"Error in tool/function-call {tool_name} usage: {type(e)}: {e}"
|
530
530
|
return result # type: ignore
|
531
531
|
|
532
532
|
def num_tokens(self, prompt: str) -> int:
|
@@ -77,8 +77,9 @@ class TableChatAgent(ChatAgent):
|
|
77
77
|
df = read_tabular_data(config.data, config.separator)
|
78
78
|
|
79
79
|
self.df = df
|
80
|
+
columns_with_quotes = [f"'{c}'" for c in df.columns]
|
80
81
|
config.system_message = config.system_message.format(
|
81
|
-
columns=", ".join(
|
82
|
+
columns=", ".join(columns_with_quotes)
|
82
83
|
)
|
83
84
|
|
84
85
|
super().__init__(config)
|
langroid/parsing/utils.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
import difflib
|
1
2
|
import random
|
3
|
+
from typing import List
|
2
4
|
|
3
5
|
import nltk
|
4
6
|
from faker import Faker
|
@@ -30,3 +32,34 @@ def generate_random_text(num_sentences: int) -> str:
|
|
30
32
|
for _ in range(num_sentences):
|
31
33
|
text += fake.sentence() + " "
|
32
34
|
return text
|
35
|
+
|
36
|
+
|
37
|
+
def closest_string(query: str, string_list: List[str]) -> str:
|
38
|
+
"""Find the closest match to the query in a list of strings.
|
39
|
+
|
40
|
+
This function is case-insensitive and ignores leading and trailing whitespace.
|
41
|
+
If no match is found, it returns 'No match found'.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
query (str): The string to match.
|
45
|
+
string_list (List[str]): The list of strings to search.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
str: The closest match to the query from the list, or 'No match found'
|
49
|
+
if no match is found.
|
50
|
+
"""
|
51
|
+
# Create a dictionary where the keys are the standardized strings and
|
52
|
+
# the values are the original strings.
|
53
|
+
str_dict = {s.lower().strip(): s for s in string_list}
|
54
|
+
|
55
|
+
# Standardize the query and find the closest match in the list of keys.
|
56
|
+
closest_match = difflib.get_close_matches(
|
57
|
+
query.lower().strip(), str_dict.keys(), n=1
|
58
|
+
)
|
59
|
+
|
60
|
+
# Retrieve the original string from the value in the dictionary.
|
61
|
+
original_closest_match = (
|
62
|
+
str_dict[closest_match[0]] if closest_match else "No match found"
|
63
|
+
)
|
64
|
+
|
65
|
+
return original_closest_match
|
@@ -1,6 +1,6 @@
|
|
1
1
|
langroid/__init__.py,sha256=sEKJ_5WJBAMZApevfeE3gxLK-eotVzJMJlT83G0rAko,30
|
2
2
|
langroid/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
langroid/agent/base.py,sha256=
|
3
|
+
langroid/agent/base.py,sha256=ud_HNDxmidHAg_JBsP8KZjMn5GHt2hL3c9QBsBOhQ7g,21024
|
4
4
|
langroid/agent/chat_agent.py,sha256=mLCHlYxU1lB7PGOLjjkaEQUqMNKcq0-HOjlG4ZcDjQE,20522
|
5
5
|
langroid/agent/chat_document.py,sha256=Rj7Hfp_FrNjuKsTMA3KyZhno5zKpmvnPPk7WgAuAF2Y,5745
|
6
6
|
langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -9,7 +9,7 @@ langroid/agent/special/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
9
9
|
langroid/agent/special/doc_chat_agent.py,sha256=NhoS02rlLr3nAfRvLB1YNcmfsWZJH24K8O-m-uYnb-I,15741
|
10
10
|
langroid/agent/special/recipient_validator_agent.py,sha256=x2UprcGlh-fyxQCZbb_fkKrruU5Om0mgOnNzk_PYBNM,4527
|
11
11
|
langroid/agent/special/retriever_agent.py,sha256=dkG_-QdL5KvpeS4K4jnx1kV9h_KxVEhgHz2rzdilZss,7196
|
12
|
-
langroid/agent/special/table_chat_agent.py,sha256=
|
12
|
+
langroid/agent/special/table_chat_agent.py,sha256=FRkeEMvJxFievRgwschphIVNYYTLmheEyn7RQCggXdg,4953
|
13
13
|
langroid/agent/task.py,sha256=KJZt6lSfCAVctyFfBJWLFcfys73kjrQJV4Y3aMVwO1M,26233
|
14
14
|
langroid/agent/tool_message.py,sha256=7OdVcV7UyOZD2ihYgV1C_1fIwiWM-2pR8FFxoA1IgOo,5379
|
15
15
|
langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -39,7 +39,7 @@ langroid/parsing/table_loader.py,sha256=xr0aeMWN-vT2Tx9HwUkuwLnG7wxA1qNfh1uC9uct
|
|
39
39
|
langroid/parsing/url_loader.py,sha256=tdYPMC2V9zI_B207LFdU4aroZzJW4sY9y794XePFAVg,1824
|
40
40
|
langroid/parsing/url_loader_cookies.py,sha256=Lg4sNpRz9MByWq2mde6T0hKv68VZSV3mtMjNEHuFeSU,2327
|
41
41
|
langroid/parsing/urls.py,sha256=_Bcf1iRdT7cQrQ8hnbPX0Jtzxc0lVFaucTS5rJoKA14,3709
|
42
|
-
langroid/parsing/utils.py,sha256=
|
42
|
+
langroid/parsing/utils.py,sha256=__1Z6mFHk_TqHQY-9uU1aV_bIXeYw8H7NEXagUOEX0I,1818
|
43
43
|
langroid/prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
44
|
langroid/prompts/dialog.py,sha256=SpfiSyofSgy2pwD1YboHR_yHO3LEEMbv6j2sm874jKo,331
|
45
45
|
langroid/prompts/prompts_config.py,sha256=EMK1Fm7EmS8y3CV4AkrVgn5K4NipiM4m7J8819W1KeM,98
|
@@ -64,7 +64,7 @@ langroid/vector_store/base.py,sha256=QZx3NUNwf2I0r3A7iuoUHIRGbqt_pFGD0hq1R-Yg8iM
|
|
64
64
|
langroid/vector_store/chromadb.py,sha256=s5pQkKjaMP-Tt5A8M10EInFzttaALPbJAq7q4gf0TKg,5235
|
65
65
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
66
66
|
langroid/vector_store/qdrantdb.py,sha256=KRvIIj1IZG2zFqejofMnRs2hT86B-27LgBEnuczdqOU,9072
|
67
|
-
langroid-0.1.
|
68
|
-
langroid-0.1.
|
69
|
-
langroid-0.1.
|
70
|
-
langroid-0.1.
|
67
|
+
langroid-0.1.36.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
68
|
+
langroid-0.1.36.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
69
|
+
langroid-0.1.36.dist-info/METADATA,sha256=H5cDPR68T2YFa2Bz_4UI-sv2xXmyDrjq0m_IxlLNxfg,25190
|
70
|
+
langroid-0.1.36.dist-info/RECORD,,
|
File without changes
|
File without changes
|