PikoAi 0.1.13__py3-none-any.whl → 0.1.14__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.
- Agents/Executor/executor.py +2 -1
- OpenCopilot.py +3 -3
- Tools/web_search.py +49 -12
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/METADATA +1 -1
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/RECORD +9 -9
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/WHEEL +0 -0
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/entry_points.txt +0 -0
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/licenses/LICENSE +0 -0
- {pikoai-0.1.13.dist-info → pikoai-0.1.14.dist-info}/top_level.txt +0 -0
Agents/Executor/executor.py
CHANGED
@@ -83,7 +83,8 @@ class executor:
|
|
83
83
|
|
84
84
|
# Streaming is handled within LiteLLMInterface.chat()
|
85
85
|
# and TerminalInterface.process_markdown_chunk()
|
86
|
-
|
86
|
+
if response.strip():
|
87
|
+
self.message.append({"role": "assistant", "content": response})
|
87
88
|
return response
|
88
89
|
|
89
90
|
except Exception as e: # Catching generic Exception as LiteLLM maps to OpenAI exceptions
|
OpenCopilot.py
CHANGED
@@ -206,12 +206,12 @@ Examples:
|
|
206
206
|
|
207
207
|
try:
|
208
208
|
# Get initial prompt
|
209
|
-
user_input = self.session.prompt(HTML("<b>
|
209
|
+
user_input = self.session.prompt(HTML("<b>Piko></b>"))
|
210
210
|
|
211
211
|
# Handle special commands
|
212
212
|
if user_input.lower() == 'help':
|
213
213
|
self.display_help()
|
214
|
-
user_input = self.session.prompt(HTML("<b>
|
214
|
+
user_input = self.session.prompt(HTML("<b>Piko></b>"))
|
215
215
|
elif user_input.lower() == 'quit':
|
216
216
|
print("Goodbye!")
|
217
217
|
return
|
@@ -227,7 +227,7 @@ Examples:
|
|
227
227
|
# Continue conversation loop
|
228
228
|
while True:
|
229
229
|
try:
|
230
|
-
user_input = self.session.prompt(HTML("<b>\
|
230
|
+
user_input = self.session.prompt(HTML("<b>\nPiko></b>"))
|
231
231
|
|
232
232
|
# Handle special commands
|
233
233
|
if user_input.lower() == 'quit':
|
Tools/web_search.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
import os
|
1
2
|
from duckduckgo_search import DDGS
|
3
|
+
from serpapi import SerpApiClient
|
2
4
|
|
3
5
|
def web_search(max_results: int = 10, **kwargs) -> str:
|
4
6
|
"""
|
5
7
|
Performs a DuckDuckGo web search based on your query (think a Google search) then returns the top search results.
|
8
|
+
If DuckDuckGo search fails, it falls back to SerpAPI.
|
6
9
|
|
7
10
|
Args:
|
8
11
|
query (str): The search query to perform.
|
@@ -13,18 +16,52 @@ def web_search(max_results: int = 10, **kwargs) -> str:
|
|
13
16
|
str: Formatted string containing search results.
|
14
17
|
|
15
18
|
Raises:
|
16
|
-
ImportError: If the duckduckgo_search package is not installed.
|
17
|
-
Exception: If no results are found for the given query.
|
19
|
+
ImportError: If the duckduckgo_search or serpapi package is not installed.
|
20
|
+
Exception: If no results are found for the given query via both DuckDuckGo and SerpAPI, or if the SerpAPI key is not found.
|
21
|
+
|
22
|
+
Note:
|
23
|
+
For SerpAPI fallback, the SERPAPI_API_KEY environment variable must be set.
|
18
24
|
"""
|
19
25
|
try:
|
20
|
-
|
26
|
+
ddgs_instance = DDGS()
|
21
27
|
except ImportError as e:
|
22
|
-
raise ImportError("You must install package `duckduckgo_search` to run this function: for instance run `pip install duckduckgo-search`."
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
raise ImportError("You must install package `duckduckgo_search` to run this function: for instance run `pip install duckduckgo-search`.") from e
|
29
|
+
|
30
|
+
try:
|
31
|
+
query = kwargs['query']
|
32
|
+
results = ddgs_instance.text(query, max_results=max_results)
|
33
|
+
if len(results) == 0:
|
34
|
+
raise Exception("No results found via DuckDuckGo.")
|
35
|
+
|
36
|
+
postprocessed_results = [f"[{result['title']}]({result['href']})\n{result['body']}" for result in results]
|
37
|
+
|
38
|
+
return "## Search Results (via DuckDuckGo)\n\n" + "\n\n".join(postprocessed_results)
|
39
|
+
|
40
|
+
except Exception as e:
|
41
|
+
# print(f"DuckDuckGo search failed: {e}. Falling back to SerpAPI.")
|
42
|
+
# If the exception was the specific DDGS ImportError, we re-raise it directly if it wasn't caught above.
|
43
|
+
# However, the structure above should prevent it from reaching here.
|
44
|
+
# The primary purpose of this block is to catch runtime errors from ddgs.text or the "No results" exception.
|
45
|
+
|
46
|
+
api_key = os.environ.get("SERPAPI_API_KEY")
|
47
|
+
if not api_key:
|
48
|
+
raise Exception("SerpAPI key not found. Please set the SERPAPI_API_KEY environment variable.")
|
49
|
+
|
50
|
+
try:
|
51
|
+
client = SerpApiClient({"api_key": api_key})
|
52
|
+
except ImportError as serp_e:
|
53
|
+
raise ImportError("You must install package `serpapi` to run this function: for instance run `pip install google-search-results`.") from serp_e
|
54
|
+
|
55
|
+
search_params = {
|
56
|
+
"engine": "google",
|
57
|
+
"q": query,
|
58
|
+
"num": max_results # SerpAPI uses 'num' for number of results
|
59
|
+
}
|
60
|
+
serp_results = client.search(search_params)
|
61
|
+
|
62
|
+
if "organic_results" in serp_results and serp_results["organic_results"]:
|
63
|
+
organic_results = serp_results["organic_results"]
|
64
|
+
postprocessed_results = [f"[{result['title']}]({result['link']})\n{result.get('snippet', '')}" for result in organic_results]
|
65
|
+
return "## Search Results (via SerpAPI)\n\n" + "\n\n".join(postprocessed_results)
|
66
|
+
else:
|
67
|
+
raise Exception(f"No results found via DuckDuckGo or SerpAPI! Original error: {e}")
|
@@ -1,8 +1,8 @@
|
|
1
|
-
OpenCopilot.py,sha256=
|
1
|
+
OpenCopilot.py,sha256=kPTs0-ly84h4dM7AmBlK4uwst5Sj2AM6UAlE3okkD8U,12157
|
2
2
|
cli.py,sha256=hY6KUxvKvJOFThZT--r6m2nzOEMIOVtiVptewsi9Z9w,13868
|
3
3
|
Agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
Agents/Executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
Agents/Executor/executor.py,sha256
|
5
|
+
Agents/Executor/executor.py,sha256=NHdPXL_jhSHqgXxbkCfvkxI-M2I-cRcv_y77i_szpow,8232
|
6
6
|
Agents/Executor/prompts.py,sha256=dWmUiAloNN_NKwWgaG_IqHDhCX1O-VhwbadUL-16gZw,2903
|
7
7
|
Env/__init__.py,sha256=KLe7UcNV5L395SxhMwbYGyu7KPrSNaoV_9QJo3mLop0,196
|
8
8
|
Env/base_env.py,sha256=K4PoWwPXn3pKeu7_-JOlUuyNbyYQ9itMhQybFOm-3K4,1563
|
@@ -21,15 +21,15 @@ Tools/tool_dir.json,sha256=pEqI-1rKud-VEWHYLF2Pbv6xwQZWy62HUF_1hjcdhCY,3128
|
|
21
21
|
Tools/tool_manager.py,sha256=86qwREw5an12dweIGCS1NNgINwHikyTxUpbjPWoLbt0,4118
|
22
22
|
Tools/userinp.py,sha256=vUhEj3y1W1_ZFHqo2xQwvqDyeOg3VsisSKTI0EurUH8,1205
|
23
23
|
Tools/web_loader.py,sha256=PyZk2g7WngZT0tCLs9Danx20dYspnaZwy4rlVE9Sx_4,5054
|
24
|
-
Tools/web_search.py,sha256=
|
24
|
+
Tools/web_search.py,sha256=mdbqWSJgMjxedrdFocHGfvOGsAq4R1H13yVev71UHkM,3164
|
25
25
|
Utils/__init__.py,sha256=oukU0ufroPRd8_N8d2xiFes9CTxSaw4NA6p2nS1kkSg,16
|
26
26
|
Utils/executor_utils.py,sha256=WwK3TKgw_hG_crg7ijRaqfidYnnNXYbbs37vKZRYK-0,491
|
27
27
|
Utils/ter_interface.py,sha256=2k32kVxcxVBewXnjSGSPbx25ZLhKindEMtL6wSC_wL4,3829
|
28
28
|
llm_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
29
|
llm_interface/llm.py,sha256=tI_KDOW14QLWowA7bB3GPe2qjlk0sjS5fBavs9XD1fo,5185
|
30
|
-
pikoai-0.1.
|
31
|
-
pikoai-0.1.
|
32
|
-
pikoai-0.1.
|
33
|
-
pikoai-0.1.
|
34
|
-
pikoai-0.1.
|
35
|
-
pikoai-0.1.
|
30
|
+
pikoai-0.1.14.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
|
31
|
+
pikoai-0.1.14.dist-info/METADATA,sha256=ayjtfHmfey5-P8lvSPW0p-q7jrV_p3nxd-r9dzNHwrU,2962
|
32
|
+
pikoai-0.1.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
33
|
+
pikoai-0.1.14.dist-info/entry_points.txt,sha256=xjZnheDymNDnQ0o84R0jZKEITrhNbzQWN-AhqfA_d6s,50
|
34
|
+
pikoai-0.1.14.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
|
35
|
+
pikoai-0.1.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|