langroid 0.45.7__py3-none-any.whl → 0.45.10__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.
@@ -28,7 +28,7 @@ class WebSearchResult:
28
28
  def __init__(
29
29
  self,
30
30
  title: str,
31
- link: str,
31
+ link: str | None,
32
32
  max_content_length: int = 3500,
33
33
  max_summary_length: int = 300,
34
34
  ):
@@ -50,6 +50,8 @@ class WebSearchResult:
50
50
  return self.full_content[: self.max_summary_length]
51
51
 
52
52
  def get_full_content(self) -> str:
53
+ if self.link is None:
54
+ return "Error: No Search Result"
53
55
  try:
54
56
  # First check headers only to get content length and type
55
57
  head_response: Response = requests.head(self.link, timeout=5)
@@ -83,7 +85,7 @@ class WebSearchResult:
83
85
  def to_dict(self) -> Dict[str, str]:
84
86
  return {
85
87
  "title": self.title,
86
- "link": self.link,
88
+ "link": self.link or "",
87
89
  "summary": self.summary,
88
90
  "full_content": self.full_content,
89
91
  }
@@ -175,21 +177,32 @@ def exa_search(query: str, num_results: int = 5) -> List[WebSearchResult]:
175
177
 
176
178
  client = Exa(api_key=api_key)
177
179
 
178
- response = client.search(
179
- query=query,
180
- num_results=num_results,
181
- )
182
- raw_results = response.results
183
-
184
- return [
185
- WebSearchResult(
186
- title=result.title or "",
187
- link=result.url,
188
- max_content_length=3500,
189
- max_summary_length=300,
180
+ try:
181
+ response = client.search(
182
+ query=query,
183
+ num_results=num_results,
190
184
  )
191
- for result in raw_results
192
- ]
185
+ raw_results = response.results
186
+
187
+ return [
188
+ WebSearchResult(
189
+ title=result.title or "",
190
+ link=result.url,
191
+ max_content_length=3500,
192
+ max_summary_length=300,
193
+ )
194
+ for result in raw_results
195
+ if result.url is not None
196
+ ]
197
+ except Exception:
198
+ return [
199
+ WebSearchResult(
200
+ title="Error",
201
+ link=None,
202
+ max_content_length=3500,
203
+ max_summary_length=300,
204
+ )
205
+ ]
193
206
 
194
207
 
195
208
  def duckduckgo_search(query: str, num_results: int = 5) -> List[WebSearchResult]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.45.7
3
+ Version: 0.45.10
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -93,6 +93,7 @@ Requires-Dist: python-socketio<6.0.0,>=5.11.0; extra == 'chainlit'
93
93
  Provides-Extra: chromadb
94
94
  Requires-Dist: chromadb<=0.4.23,>=0.4.21; extra == 'chromadb'
95
95
  Provides-Extra: db
96
+ Requires-Dist: psycopg2-binary>=2.9.10; extra == 'db'
96
97
  Requires-Dist: psycopg2<3.0.0,>=2.9.7; extra == 'db'
97
98
  Requires-Dist: pymysql<2.0.0,>=1.1.0; extra == 'db'
98
99
  Requires-Dist: sqlalchemy<3.0.0,>=2.0.19; extra == 'db'
@@ -94,7 +94,7 @@ langroid/parsing/table_loader.py,sha256=qNM4obT_0Y4tjrxNBCNUYjKQ9oETCZ7FbolKBTcz
94
94
  langroid/parsing/url_loader.py,sha256=obi_kj6ehBkdh5mXNtYCXpm3KCuExoy2D1ODVlFbXbQ,4895
95
95
  langroid/parsing/urls.py,sha256=Tjzr64YsCusiYkY0LEGB5-rSuX8T2P_4DVoOFKAeKuI,8081
96
96
  langroid/parsing/utils.py,sha256=WwqzOhbQRlorbVvddDIZKv9b1KqZCBDm955lgIHDXRw,12828
97
- langroid/parsing/web_search.py,sha256=rGkeUGsv_nopRIRuB-OqbieGASuHUaEFWsXmVdBXi8g,7800
97
+ langroid/parsing/web_search.py,sha256=sARV1Tku4wiInhuCz0kRaMHcoF6Ok6CLu7vapLS8hjs,8222
98
98
  langroid/prompts/__init__.py,sha256=RW11vK6jiLPuaUh4GpeFvstti73gkm8_rDMtrbo2YsU,142
99
99
  langroid/prompts/dialog.py,sha256=SpfiSyofSgy2pwD1YboHR_yHO3LEEMbv6j2sm874jKo,331
100
100
  langroid/prompts/prompts_config.py,sha256=p_lp9nbMuQwhhMwAZsOxveRw9C0ZFZvql7pdIfgVZYo,143
@@ -127,7 +127,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
127
127
  langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
128
128
  langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
129
129
  langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
130
- langroid-0.45.7.dist-info/METADATA,sha256=iuFtKxQjQwkRMb8-5lLmVKETJMCCxRcRO0REeJyW9dw,63335
131
- langroid-0.45.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
- langroid-0.45.7.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
- langroid-0.45.7.dist-info/RECORD,,
130
+ langroid-0.45.10.dist-info/METADATA,sha256=wprB9hS3tbbIaV9FvHE7VTrTZq0Xv6b0TLu3YG21k6A,63390
131
+ langroid-0.45.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
132
+ langroid-0.45.10.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
133
+ langroid-0.45.10.dist-info/RECORD,,