PikoAi 0.1.13__py3-none-any.whl → 0.1.15__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.
@@ -83,7 +83,8 @@ class executor:
83
83
 
84
84
  # Streaming is handled within LiteLLMInterface.chat()
85
85
  # and TerminalInterface.process_markdown_chunk()
86
- self.message.append({"role": "assistant", "content": response})
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>Please enter your prompt: </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>Please enter your prompt: </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>\nPlease enter your prompt (or 'quit' to exit): </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
- ddgs = DDGS()
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
- ) from e
24
- query = kwargs['query']
25
- results = ddgs.text(query, max_results=max_results)
26
- if len(results) == 0:
27
- raise Exception("No results found! Try a less restrictive/shorter query.")
28
-
29
- postprocessed_results = [f"[{result['title']}]({result['href']})\n{result['body']}" for result in results]
30
- return "## Search Results\n\n" + "\n\n".join(postprocessed_results)
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}")
cli.py CHANGED
@@ -12,7 +12,10 @@ AVAILABLE_MODELS = {
12
12
  "openai/gpt-3.5-turbo",
13
13
  "openai/gpt-4",
14
14
  "openai/gpt-4-turbo-preview",
15
- "openai/gpt-4o"
15
+ "openai/gpt-4o",
16
+ "openai/gpt-4o-mini",
17
+ "openai/gpt-4.1-nano",
18
+ "openai/gpt-4.1-mini"
16
19
  ],
17
20
  "mistral": [
18
21
  "mistral/mistral-tiny",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PikoAi
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: An AI-powered task automation tool
5
5
  Home-page: https://github.com/nihaaaar22/OS-Assistant
6
6
  Author: Nihar S
@@ -1,8 +1,8 @@
1
- OpenCopilot.py,sha256=vBAuU6MNhYdnyIIrDWOBSlxa0iyjADJLq5eCxUhlffw,12240
2
- cli.py,sha256=hY6KUxvKvJOFThZT--r6m2nzOEMIOVtiVptewsi9Z9w,13868
1
+ OpenCopilot.py,sha256=kPTs0-ly84h4dM7AmBlK4uwst5Sj2AM6UAlE3okkD8U,12157
2
+ cli.py,sha256=qDWlKyOUkhDHSBxQ2wjy1e6KGRsDxE7pjxUZKjQFC3k,13959
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=-HvywqfroHd0QYNt5AN8vV7wjR-91hWPbSuvNzIVMMU,8191
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=4EGq1VZqfDgG-_yXTd4_Ha1iEUcR-szdlgRV7oFPru4,1259
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.13.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
31
- pikoai-0.1.13.dist-info/METADATA,sha256=mjc1I8aWnP9tMaG0Mlvme1AX-dgDIul3ugC5C5yxbXc,2962
32
- pikoai-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- pikoai-0.1.13.dist-info/entry_points.txt,sha256=xjZnheDymNDnQ0o84R0jZKEITrhNbzQWN-AhqfA_d6s,50
34
- pikoai-0.1.13.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
35
- pikoai-0.1.13.dist-info/RECORD,,
30
+ pikoai-0.1.15.dist-info/licenses/LICENSE,sha256=cELUVOboOAderKFp8bdtcM5VyJi61YH1oDbRhOuoQZw,1067
31
+ pikoai-0.1.15.dist-info/METADATA,sha256=kWctaTcc3FCoOqkr-bS_lRCy4OK4HsIYvzd_dOqt9Jc,2962
32
+ pikoai-0.1.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ pikoai-0.1.15.dist-info/entry_points.txt,sha256=xjZnheDymNDnQ0o84R0jZKEITrhNbzQWN-AhqfA_d6s,50
34
+ pikoai-0.1.15.dist-info/top_level.txt,sha256=hWzBNE7UQsuNcENIOksGcJED08k3ZGRRn2X5jnStICU,53
35
+ pikoai-0.1.15.dist-info/RECORD,,