nosible 0.3.1__tar.gz → 0.3.3__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.
- {nosible-0.3.1/src/nosible.egg-info → nosible-0.3.3}/PKG-INFO +1 -1
- {nosible-0.3.1 → nosible-0.3.3}/pyproject.toml +1 -1
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/result.py +3 -3
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/nosible_client.py +7 -29
- {nosible-0.3.1 → nosible-0.3.3/src/nosible.egg-info}/PKG-INFO +1 -1
- {nosible-0.3.1 → nosible-0.3.3}/LICENSE +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/README.md +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/setup.cfg +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/setup.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/__init__.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/result_set.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/search.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/search_set.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/snippet.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/snippet_set.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/classes/web_page.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/utils/json_tools.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible/utils/rate_limiter.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible.egg-info/SOURCES.txt +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible.egg-info/dependency_links.txt +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible.egg-info/requires.txt +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/src/nosible.egg-info/top_level.txt +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/tests/test_01_nosible.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/tests/test_02_results.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/tests/test_03_search_searchset.py +0 -0
- {nosible-0.3.1 → nosible-0.3.3}/tests/test_04_snippets.py +0 -0
|
@@ -356,7 +356,7 @@ class Result:
|
|
|
356
356
|
The response must be a float in [-1.0, 1.0]. No other text must be returned.
|
|
357
357
|
"""
|
|
358
358
|
from openai import OpenAI
|
|
359
|
-
llm_client = OpenAI(base_url="https://openrouter.ai/api/
|
|
359
|
+
llm_client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=client.llm_api_key)
|
|
360
360
|
|
|
361
361
|
# Call the chat completions endpoint.
|
|
362
362
|
resp = llm_client.chat.completions.create(
|
|
@@ -519,7 +519,6 @@ class Result:
|
|
|
519
519
|
try:
|
|
520
520
|
from nosible import Search
|
|
521
521
|
|
|
522
|
-
exclude_companies = [self.url_hash] if not exclude_companies else exclude_companies.append(self.url_hash)
|
|
523
522
|
s = Search(
|
|
524
523
|
question=self.title,
|
|
525
524
|
expansions=[],
|
|
@@ -554,7 +553,8 @@ class Result:
|
|
|
554
553
|
iab_tier_4=iab_tier_4,
|
|
555
554
|
instruction=instruction,
|
|
556
555
|
)
|
|
557
|
-
|
|
556
|
+
results = client.fast_search(search=s)
|
|
557
|
+
return results
|
|
558
558
|
except Exception as e:
|
|
559
559
|
raise RuntimeError(f"Failed to find similar results for title '{self.title}': {e}") from e
|
|
560
560
|
|
|
@@ -211,7 +211,7 @@ class Nosible:
|
|
|
211
211
|
self._post = retry(
|
|
212
212
|
reraise=True,
|
|
213
213
|
stop=stop_after_attempt(self.retries) | stop_after_delay(self.timeout),
|
|
214
|
-
wait=wait_exponential(multiplier=1, min=1, max=
|
|
214
|
+
wait=wait_exponential(multiplier=1, min=1, max=20),
|
|
215
215
|
retry=retry_if_exception_type(httpx.RequestError),
|
|
216
216
|
before_sleep=before_sleep_log(self.logger, logging.WARNING),
|
|
217
217
|
)(self._post)
|
|
@@ -220,7 +220,7 @@ class Nosible:
|
|
|
220
220
|
self._generate_expansions = retry(
|
|
221
221
|
reraise=True,
|
|
222
222
|
stop=stop_after_attempt(self.retries) | stop_after_delay(self.timeout),
|
|
223
|
-
wait=wait_exponential(multiplier=1, min=1, max=
|
|
223
|
+
wait=wait_exponential(multiplier=1, min=1, max=20),
|
|
224
224
|
retry=retry_if_exception_type(httpx.RequestError),
|
|
225
225
|
before_sleep=before_sleep_log(self.logger, logging.WARNING),
|
|
226
226
|
)(self._generate_expansions)
|
|
@@ -265,7 +265,6 @@ class Nosible:
|
|
|
265
265
|
def search(
|
|
266
266
|
self,
|
|
267
267
|
prompt: str = None,
|
|
268
|
-
recursions: int = 3,
|
|
269
268
|
agent: str = "cybernaut-1",
|
|
270
269
|
) -> ResultSet:
|
|
271
270
|
"""
|
|
@@ -277,8 +276,6 @@ class Nosible:
|
|
|
277
276
|
----------
|
|
278
277
|
prompt: str
|
|
279
278
|
The information you are looking for.
|
|
280
|
-
recursions: int
|
|
281
|
-
Maximum chain-of-search length.
|
|
282
279
|
agent: str
|
|
283
280
|
The search agent you want to use.
|
|
284
281
|
|
|
@@ -287,11 +284,6 @@ class Nosible:
|
|
|
287
284
|
ResultSet
|
|
288
285
|
The results of the search.
|
|
289
286
|
|
|
290
|
-
Raises
|
|
291
|
-
------
|
|
292
|
-
ValueError
|
|
293
|
-
If `recursions` is not [3,10].
|
|
294
|
-
|
|
295
287
|
Examples
|
|
296
288
|
--------
|
|
297
289
|
>>> from nosible import Nosible
|
|
@@ -299,21 +291,9 @@ class Nosible:
|
|
|
299
291
|
... results = nos.search("Interesting news from AI startups last week.")
|
|
300
292
|
... print(isinstance(results, ResultSet))
|
|
301
293
|
True
|
|
302
|
-
>>> with Nosible() as nos:
|
|
303
|
-
... results = nos.search(
|
|
304
|
-
... prompt="Interesting news from AI startups last week.",
|
|
305
|
-
... recursions=20
|
|
306
|
-
... ) # doctest: +ELLIPSIS
|
|
307
|
-
Traceback (most recent call last):
|
|
308
|
-
...
|
|
309
|
-
ValueError: Recursions must be [3,10].
|
|
310
294
|
"""
|
|
311
|
-
if recursions < 3 or recursions > 10:
|
|
312
|
-
raise ValueError("Recursions must be [3,10].")
|
|
313
|
-
|
|
314
295
|
payload = {
|
|
315
296
|
"prompt": prompt,
|
|
316
|
-
"recursions": recursions,
|
|
317
297
|
"agent": agent,
|
|
318
298
|
}
|
|
319
299
|
|
|
@@ -2047,14 +2027,14 @@ class Nosible:
|
|
|
2047
2027
|
|
|
2048
2028
|
# Include / exclude companies
|
|
2049
2029
|
if include_companies:
|
|
2050
|
-
company_list = "
|
|
2030
|
+
company_list = " OR ".join(f"ARRAY_CONTAINS(companies, '{c}')" for c in include_companies)
|
|
2051
2031
|
clauses.append(
|
|
2052
|
-
f"(
|
|
2032
|
+
f"(companies IS NOT NULL AND ({company_list}))"
|
|
2053
2033
|
)
|
|
2054
2034
|
if exclude_companies:
|
|
2055
|
-
company_list = "
|
|
2035
|
+
company_list = " OR ".join(f"ARRAY_CONTAINS(companies, '{c}')" for c in exclude_companies)
|
|
2056
2036
|
clauses.append(
|
|
2057
|
-
f"(
|
|
2037
|
+
f"(companies IS NULL OR NOT ({company_list}))"
|
|
2058
2038
|
)
|
|
2059
2039
|
|
|
2060
2040
|
if include_docs:
|
|
@@ -2111,9 +2091,7 @@ class Nosible:
|
|
|
2111
2091
|
"certain",
|
|
2112
2092
|
"netloc",
|
|
2113
2093
|
"language",
|
|
2114
|
-
"
|
|
2115
|
-
"company_2",
|
|
2116
|
-
"company_3",
|
|
2094
|
+
"companies"
|
|
2117
2095
|
"doc_hash",
|
|
2118
2096
|
]
|
|
2119
2097
|
import polars as pl # Lazy import
|
|
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
|