webscout 3.8__py3-none-any.whl → 3.9__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.

Potentially problematic release.


This version of webscout might be problematic. Click here for more details.

webscout/AIutel.py CHANGED
@@ -19,7 +19,7 @@ from playsound import playsound
19
19
  from time import sleep as wait
20
20
  import pathlib
21
21
  import urllib.parse
22
- appdir = appdirs.AppDirs("AIWEBS", "vortex")
22
+ appdir = appdirs.AppDirs("AIWEBS", "webscout")
23
23
 
24
24
  default_path = appdir.user_cache_dir
25
25
 
@@ -49,7 +49,11 @@ webai = [
49
49
  "basedgpt",
50
50
  "deepseek",
51
51
  "deepinfra",
52
+ "vtlchat",
53
+ "geminiflash",
54
+ "geminipro",
52
55
  ]
56
+
53
57
  gpt4free_providers = [
54
58
  provider.__name__ for provider in g4f.Provider.__providers__ # if provider.working
55
59
  ]
@@ -1,3 +1,3 @@
1
1
  from llama_cpp import __version__ as __llama_cpp_version__
2
2
 
3
- __version__ = '3.7'
3
+ __version__ = '3.9'
@@ -0,0 +1,152 @@
1
+ import requests
2
+ from ..AIbase import Provider
3
+ from ..AIutel import Conversation
4
+ from ..AIutel import Optimizers
5
+ from ..AIutel import AwesomePrompts
6
+ from webscout import exceptions
7
+
8
+ class GEMINIFLASH(Provider):
9
+ def __init__(
10
+ self,
11
+ is_conversation: bool = True,
12
+ max_tokens: int = 600,
13
+ timeout: int = 30,
14
+ intro: str = None,
15
+ filepath: str = None,
16
+ update_file: bool = True,
17
+ proxies: dict = {},
18
+ history_offset: int = 10250,
19
+ act: str = None,
20
+ ):
21
+ """Initializes GEMINI
22
+
23
+ Args:
24
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
25
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
26
+ timeout (int, optional): Http request timeout. Defaults to 30.
27
+ intro (str, optional): Conversation introductory prompt. Defaults to None.
28
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
29
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
30
+ proxies (dict, optional): Http request proxies. Defaults to {}.
31
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
32
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
33
+ """
34
+ self.session = requests.Session()
35
+ self.is_conversation = is_conversation
36
+ self.max_tokens_to_sample = max_tokens
37
+ self.chat_endpoint = "https://gemini-flash.developer-house.workers.dev"
38
+ self.timeout = timeout
39
+ self.last_response = {}
40
+ self.__available_optimizers = (
41
+ method
42
+ for method in dir(Optimizers)
43
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
44
+ )
45
+ Conversation.intro = (
46
+ AwesomePrompts().get_act(
47
+ act, raise_not_found=True, default=None, case_insensitive=True
48
+ )
49
+ if act
50
+ else intro or Conversation.intro
51
+ )
52
+ self.conversation = Conversation(
53
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
54
+ )
55
+ self.conversation.history_offset = history_offset
56
+ self.session.proxies = proxies
57
+
58
+ def ask(
59
+ self,
60
+ prompt: str,
61
+ stream: bool = False,
62
+ raw: bool = False,
63
+ optimizer: str = None,
64
+ conversationally: bool = False,
65
+ ) -> dict:
66
+ """Chat with AI
67
+
68
+ Args:
69
+ prompt (str): Prompt to be send.
70
+ stream (bool, optional): Flag for streaming response. Defaults to False.
71
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
72
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
73
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
74
+ Returns:
75
+ dict : {}
76
+ ```json
77
+ {
78
+ "text" : "How may I assist you today?"
79
+ }
80
+ ```
81
+ """
82
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
83
+ if optimizer:
84
+ if optimizer in self.__available_optimizers:
85
+ conversation_prompt = getattr(Optimizers, optimizer)(
86
+ conversation_prompt if conversationally else prompt
87
+ )
88
+ else:
89
+ raise Exception(
90
+ f"Optimizer is not one of {self.__available_optimizers}"
91
+ )
92
+ self.session.headers.update(
93
+ {
94
+ "Content-Type": "application/json",
95
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
96
+ }
97
+ )
98
+ payload = {"question": conversation_prompt}
99
+
100
+ response = self.session.get(
101
+ self.chat_endpoint, params=payload, stream=True, timeout=self.timeout
102
+ )
103
+ if not response.ok:
104
+ raise exceptions.FailedToGenerateResponseError(
105
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
106
+ )
107
+
108
+ resp = response.json()
109
+ self.last_response.update(resp)
110
+ self.conversation.update_chat_history(
111
+ prompt, self.get_message(self.last_response)
112
+ )
113
+ return resp
114
+
115
+ def chat(
116
+ self,
117
+ prompt: str,
118
+ stream: bool = False,
119
+ optimizer: str = None,
120
+ conversationally: bool = False,
121
+ ) -> str:
122
+ """Generate response `str`
123
+ Args:
124
+ prompt (str): Prompt to be send.
125
+ stream (bool, optional): Flag for streaming response. Defaults to False.
126
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
127
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
128
+ Returns:
129
+ str: Response generated
130
+ """
131
+ return self.get_message(
132
+ self.ask(
133
+ prompt,
134
+ optimizer=optimizer,
135
+ conversationally=conversationally,
136
+ )
137
+ )
138
+
139
+ def get_message(self, response: dict) -> str:
140
+ """Retrieves message only from response
141
+
142
+ Args:
143
+ response (dict): Response generated by `self.ask`
144
+
145
+ Returns:
146
+ str: Message extracted
147
+ """
148
+ assert isinstance(response, dict), "Response should be of dict data-type only"
149
+ try:
150
+ return response["content"]
151
+ except KeyError:
152
+ return ""
@@ -0,0 +1,152 @@
1
+ import requests
2
+ from ..AIbase import Provider
3
+ from ..AIutel import Conversation
4
+ from ..AIutel import Optimizers
5
+ from ..AIutel import AwesomePrompts
6
+ from webscout import exceptions
7
+
8
+ class GEMINIPRO(Provider):
9
+ def __init__(
10
+ self,
11
+ is_conversation: bool = True,
12
+ max_tokens: int = 600,
13
+ timeout: int = 30,
14
+ intro: str = None,
15
+ filepath: str = None,
16
+ update_file: bool = True,
17
+ proxies: dict = {},
18
+ history_offset: int = 10250,
19
+ act: str = None,
20
+ ):
21
+ """Initializes GEMINI
22
+
23
+ Args:
24
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
25
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
26
+ timeout (int, optional): Http request timeout. Defaults to 30.
27
+ intro (str, optional): Conversation introductory prompt. Defaults to None.
28
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
29
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
30
+ proxies (dict, optional): Http request proxies. Defaults to {}.
31
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
32
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
33
+ """
34
+ self.session = requests.Session()
35
+ self.is_conversation = is_conversation
36
+ self.max_tokens_to_sample = max_tokens
37
+ self.chat_endpoint = "https://gemini-pro.developer-house.workers.dev/"
38
+ self.timeout = timeout
39
+ self.last_response = {}
40
+ self.__available_optimizers = (
41
+ method
42
+ for method in dir(Optimizers)
43
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
44
+ )
45
+ Conversation.intro = (
46
+ AwesomePrompts().get_act(
47
+ act, raise_not_found=True, default=None, case_insensitive=True
48
+ )
49
+ if act
50
+ else intro or Conversation.intro
51
+ )
52
+ self.conversation = Conversation(
53
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
54
+ )
55
+ self.conversation.history_offset = history_offset
56
+ self.session.proxies = proxies
57
+
58
+ def ask(
59
+ self,
60
+ prompt: str,
61
+ stream: bool = False,
62
+ raw: bool = False,
63
+ optimizer: str = None,
64
+ conversationally: bool = False,
65
+ ) -> dict:
66
+ """Chat with AI
67
+
68
+ Args:
69
+ prompt (str): Prompt to be send.
70
+ stream (bool, optional): Flag for streaming response. Defaults to False.
71
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
72
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
73
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
74
+ Returns:
75
+ dict : {}
76
+ ```json
77
+ {
78
+ "text" : "How may I assist you today?"
79
+ }
80
+ ```
81
+ """
82
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
83
+ if optimizer:
84
+ if optimizer in self.__available_optimizers:
85
+ conversation_prompt = getattr(Optimizers, optimizer)(
86
+ conversation_prompt if conversationally else prompt
87
+ )
88
+ else:
89
+ raise Exception(
90
+ f"Optimizer is not one of {self.__available_optimizers}"
91
+ )
92
+ self.session.headers.update(
93
+ {
94
+ "Content-Type": "application/json",
95
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
96
+ }
97
+ )
98
+ payload = {"question": conversation_prompt}
99
+
100
+ response = self.session.get(
101
+ self.chat_endpoint, params=payload, stream=True, timeout=self.timeout
102
+ )
103
+ if not response.ok:
104
+ raise exceptions.FailedToGenerateResponseError(
105
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
106
+ )
107
+
108
+ resp = response.json()
109
+ self.last_response.update(resp)
110
+ self.conversation.update_chat_history(
111
+ prompt, self.get_message(self.last_response)
112
+ )
113
+ return resp
114
+
115
+ def chat(
116
+ self,
117
+ prompt: str,
118
+ stream: bool = False,
119
+ optimizer: str = None,
120
+ conversationally: bool = False,
121
+ ) -> str:
122
+ """Generate response `str`
123
+ Args:
124
+ prompt (str): Prompt to be send.
125
+ stream (bool, optional): Flag for streaming response. Defaults to False.
126
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
127
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
128
+ Returns:
129
+ str: Response generated
130
+ """
131
+ return self.get_message(
132
+ self.ask(
133
+ prompt,
134
+ optimizer=optimizer,
135
+ conversationally=conversationally,
136
+ )
137
+ )
138
+
139
+ def get_message(self, response: dict) -> str:
140
+ """Retrieves message only from response
141
+
142
+ Args:
143
+ response (dict): Response generated by `self.ask`
144
+
145
+ Returns:
146
+ str: Message extracted
147
+ """
148
+ assert isinstance(response, dict), "Response should be of dict data-type only"
149
+ try:
150
+ return response["content"]
151
+ except KeyError:
152
+ return ""
@@ -218,4 +218,8 @@ class YouChat(Provider):
218
218
  str: Message extracted
219
219
  """
220
220
  assert isinstance(response, dict), "Response should be of dict data-type only"
221
- return response["text"]
221
+ return response["text"]
222
+
223
+ if __name__ == "__main__":
224
+ YouChat = YouChat()
225
+ print(YouChat.chat("hello"))
@@ -35,6 +35,9 @@ from .BasedGPT import BasedGPT
35
35
  from .Deepseek import DeepSeek
36
36
  from .Deepinfra import DeepInfra, VLM, AsyncDeepInfra
37
37
  from .VTLchat import VTLchat
38
+ from .Geminipro import GEMINIPRO
39
+ from .Geminiflash import GEMINIFLASH
40
+
38
41
  __all__ = [
39
42
  'ThinkAnyAI',
40
43
  'Xjai',
@@ -73,5 +76,8 @@ __all__ = [
73
76
  'AsyncPhindv2',
74
77
  'Phindv2',
75
78
  'OPENGPTv2',
79
+ 'GEMINIPRO',
80
+ 'GEMINIFLASH',
81
+
76
82
 
77
83
  ]
webscout/__init__.py CHANGED
@@ -39,6 +39,9 @@ webai = [
39
39
  "basedgpt",
40
40
  "deepseek",
41
41
  "deepinfra",
42
+ "vtlchat",
43
+ "geminiflash",
44
+ "geminipro",
42
45
  ]
43
46
 
44
47
  gpt4free_providers = [
webscout/version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "3.7"
1
+ __version__ = "3.9"
2
2
 
webscout/webai.py CHANGED
@@ -689,7 +689,55 @@ class Main(cmd.Cmd):
689
689
  history_offset=history_offset,
690
690
  act=awesome_prompt,
691
691
  )
692
+ elif provider == "geminiflash":
693
+ from webscout import GEMINIFLASH
692
694
 
695
+ self.bot = GEMINIFLASH(
696
+ is_conversation=disable_conversation,
697
+ max_tokens=max_tokens,
698
+ temperature=temperature,
699
+ top_p=top_p,
700
+ timeout=timeout,
701
+ intro=intro,
702
+ filepath=filepath,
703
+ update_file=update_file,
704
+ proxies=proxies,
705
+ history_offset=history_offset,
706
+ act=awesome_prompt,
707
+ )
708
+ elif provider == "geminipro":
709
+ from webscout import GEMINIPRO
710
+
711
+ self.bot = GEMINIPRO(
712
+ is_conversation=disable_conversation,
713
+ max_tokens=max_tokens,
714
+ temperature=temperature,
715
+ top_p=top_p,
716
+ timeout=timeout,
717
+ intro=intro,
718
+ filepath=filepath,
719
+ update_file=update_file,
720
+ proxies=proxies,
721
+ history_offset=history_offset,
722
+ act=awesome_prompt,
723
+ )
724
+
725
+ elif provider == "vtlchat":
726
+ from webscout import VTLchat
727
+
728
+ self.bot = VTLchat(
729
+ is_conversation=disable_conversation,
730
+ max_tokens=max_tokens,
731
+ temperature=temperature,
732
+ top_p=top_p,
733
+ timeout=timeout,
734
+ intro=intro,
735
+ filepath=filepath,
736
+ update_file=update_file,
737
+ proxies=proxies,
738
+ history_offset=history_offset,
739
+ act=awesome_prompt,
740
+ )
693
741
  elif provider == "gemini":
694
742
  from webscout import GEMINI
695
743
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 3.8
3
+ Version: 3.9
4
4
  Summary: Search for anything using Google, DuckDuckGo, brave, qwant, phind.com, Contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, webai (terminal gpt and open interpreter) and offline LLMs and more
5
5
  Author: OEvortex
6
6
  Author-email: helpingai5@gmail.com
@@ -1421,6 +1421,9 @@ provider = VTLchat()
1421
1421
  response = provider.chat("Hello, how are you?")
1422
1422
  print(response)
1423
1423
  ```
1424
+
1425
+ ### 21. GeminiFlash and geminipro
1426
+ **Usage similar to other providers**
1424
1427
  ### `LLM`
1425
1428
  ```python
1426
1429
  from webscout.LLM import LLM
@@ -1698,335 +1701,7 @@ if __name__ == "__main__":
1698
1701
  ```
1699
1702
 
1700
1703
  ## `Webai` - terminal gpt and a open interpeter
1701
-
1702
- ```python
1703
- import time
1704
- import uuid
1705
- from typing import Dict, Any, Optional, AsyncGenerator
1706
- from rich.console import Console
1707
- from rich.markdown import Markdown
1708
- from rich.panel import Panel
1709
- from rich.style import Style
1710
- import webscout
1711
- import webscout.AIutel
1712
- import g4f
1713
- from webscout.g4f import *
1714
- from webscout.async_providers import mapper as async_provider_map
1715
-
1716
- class TaskExecutor:
1717
- """
1718
- Manages an interactive chat session, handling user input, AI responses,
1719
- and optional features like web search, code execution, and text-to-speech.
1720
- """
1721
-
1722
- def __init__(self) -> None:
1723
- """Initializes the conversational assistant with default settings."""
1724
- self._console: Console = Console()
1725
-
1726
- # Session configuration
1727
- self._selected_provider: str = "phind"
1728
- self._selected_model: str = "Phind Model"
1729
- self._conversation_enabled: bool = True
1730
- self._max_tokens: int = 600
1731
- self._temperature: float = 0.2
1732
- self._top_k: int = -1
1733
- self._top_p: float = 0.999
1734
- self._timeout: int = 30
1735
- self._auth_token: str = None # API key, if required
1736
- self._chat_completion_enabled: bool = True # g4fauto
1737
- self._ignore_working: bool = False # Ignore working status of providers
1738
- self._proxy_path: str = None # Path to proxy configuration
1739
-
1740
- # History Management
1741
- self._history_filepath: str = "history.txt"
1742
- self._update_history_file: bool = True
1743
- self._history_offset: int = 10250
1744
-
1745
- # Prompt Engineering
1746
- self._initial_prompt: str = None
1747
- self._awesome_prompt_content: str = None
1748
-
1749
- # Optional Features
1750
- self._web_search_enabled: bool = False # Enable web search
1751
- self._rawdog_enabled: bool = True
1752
- self._internal_script_execution_enabled: bool = True
1753
- self._script_confirmation_required: bool = False
1754
- self._selected_interpreter: str = "python"
1755
- self._selected_optimizer: str = "code"
1756
- self._suppress_output: bool = False # Suppress verbose output
1757
-
1758
- # AI provider mapping
1759
- self._ai_provider_mapping: Dict[str, Any] = {
1760
- "phind": webscout.PhindSearch,
1761
- "opengpt": webscout.OPENGPT,
1762
- "koboldai": webscout.KOBOLDAI,
1763
- "blackboxai": webscout.BLACKBOXAI,
1764
- "llama2": webscout.LLAMA2,
1765
- "yepchat": webscout.YEPCHAT,
1766
- "leo": webscout.LEO,
1767
- "groq": webscout.GROQ,
1768
- "openai": webscout.OPENAI,
1769
- "perplexity": webscout.PERPLEXITY,
1770
- "you": webscout.YouChat,
1771
- "xjai": webscout.Xjai,
1772
- "cohere": webscout.Cohere,
1773
- "reka": webscout.REKA,
1774
- "thinkany": webscout.ThinkAnyAI,
1775
- "gemini": webscout.GEMINI,
1776
- "berlin4h": webscout.Berlin4h,
1777
- "chatgptuk": webscout.ChatGPTUK,
1778
- "poe": webscout.POE,
1779
- "basedgpt": webscout.BasedGPT,
1780
- "deepseek": webscout.DeepSeek,
1781
- "deepinfra": webscout.DeepInfra,
1782
- "opengenptv2": webscout.OPENGPTv2
1783
- }
1784
-
1785
- # Initialize Rawdog if enabled
1786
- if self._rawdog_enabled:
1787
- self._rawdog_instance: webscout.AIutel.RawDog = webscout.AIutel.RawDog(
1788
- quiet=self._suppress_output,
1789
- internal_exec=self._internal_script_execution_enabled,
1790
- confirm_script=self._script_confirmation_required,
1791
- interpreter=self._selected_interpreter,
1792
- )
1793
-
1794
- self._initial_prompt = self._rawdog_instance.intro_prompt
1795
-
1796
- # Initialize the selected AI model
1797
- self._ai_model = self._get_ai_model()
1798
-
1799
- def _get_ai_model(self):
1800
- """
1801
- Determines the appropriate AI model based on the selected provider,
1802
- including automatic provider selection and g4fauto support.
1803
- """
1804
- if self._selected_provider == "g4fauto":
1805
- # Automatically select the best provider from g4f
1806
- test = TestProviders(quiet=self._suppress_output, timeout=self._timeout)
1807
- g4fauto = test.best if not self._ignore_working else test.auto
1808
- if isinstance(g4fauto, str):
1809
- self._selected_provider = "g4fauto+" + g4fauto
1810
- self._ai_model = self._create_g4f_model(g4fauto)
1811
- else:
1812
- raise Exception(
1813
- "No working g4f provider found. "
1814
- "Consider running 'webscout.webai gpt4free test -y' first"
1815
- )
1816
- else:
1817
- # Use the specified provider
1818
- self._ai_model = self._ai_provider_mapping[self._selected_provider](
1819
- is_conversation=self._conversation_enabled,
1820
- max_tokens=self._max_tokens,
1821
- timeout=self._timeout,
1822
- intro=self._initial_prompt,
1823
- filepath=self._history_filepath,
1824
- update_file=self._update_history_file,
1825
- proxies={}, # Load proxies from config if needed
1826
- history_offset=self._history_offset,
1827
- act=self._awesome_prompt_content,
1828
- model=self._selected_model,
1829
- quiet=self._suppress_output,
1830
- # auth=self._auth_token, # Pass API key if required
1831
- )
1832
- return self._ai_model
1833
-
1834
- def _create_g4f_model(self, provider: str):
1835
- """
1836
- Creates a g4f model instance using the provided provider and webscout.WEBS for web search.
1837
- """
1838
- return webscout.g4f.GPT4FREE(
1839
- provider=provider,
1840
- auth=self._auth_token,
1841
- max_tokens=self._max_tokens,
1842
- chat_completion=self._chat_completion_enabled,
1843
- ignore_working=self._ignore_working,
1844
- timeout=self._timeout,
1845
- intro=self._initial_prompt,
1846
- filepath=self._history_filepath,
1847
- update_file=self._update_history_file,
1848
- proxies={}, # Load proxies from config if needed
1849
- history_offset=self._history_offset,
1850
- act=self._awesome_prompt_content,
1851
- )
1852
-
1853
- def process_query(self, query: str) -> None:
1854
- """
1855
- Processes a user query, potentially enhancing it with web search results,
1856
- passing it to the AI model, and handling the response.
1857
-
1858
- Args:
1859
- query: The user's text input.
1860
-
1861
- Returns:
1862
- None
1863
- """
1864
- if self._web_search_enabled:
1865
- query = self._augment_query_with_web_search(query)
1866
-
1867
- # Apply code optimization if configured
1868
- if self._selected_optimizer == "code":
1869
- query = webscout.AIutel.Optimizers.code(query)
1870
-
1871
- try:
1872
- response: str = self._ai_model.chat(query)
1873
- except webscout.exceptions.FailedToGenerateResponseError as e:
1874
- self._console.print(Markdown(f"LLM: [red]{e}[/red]"))
1875
- return
1876
-
1877
- # Handle Rawdog responses if enabled
1878
- if self._rawdog_enabled:
1879
- self._handle_rawdog_response(response)
1880
- else:
1881
- self._console.print(Markdown(f"LLM: {response}"))
1882
-
1883
- def _augment_query_with_web_search(self, query: str) -> str:
1884
- """Performs a web search and appends the results to the query.
1885
-
1886
- Args:
1887
- query: The user's text input.
1888
-
1889
- Returns:
1890
- str: The augmented query with web search results.
1891
- """
1892
- web_search_results = webscout.WEBS().text(query, max_results=3)
1893
- if web_search_results:
1894
- formatted_results = "\n".join(
1895
- f"{i+1}. {result['title']} - {result['href']}\n\nBody: {result['body']}"
1896
- for i, result in enumerate(web_search_results)
1897
- )
1898
- query += f"\n\n## Web Search Results are:\n\n{formatted_results}"
1899
- return query
1900
-
1901
- def _handle_rawdog_response(self, response: str) -> None:
1902
- """Handles AI responses, potentially executing them as code with Rawdog.
1903
-
1904
- Args:
1905
- response: The AI model's response.
1906
-
1907
- Returns:
1908
- None
1909
- """
1910
- try:
1911
- is_feedback = self._rawdog_instance.main(response)
1912
- if is_feedback and "PREVIOUS SCRIPT EXCEPTION" in is_feedback:
1913
- self._console.print(Markdown(f"LLM: {is_feedback}"))
1914
- error_message = is_feedback.split("PREVIOUS SCRIPT EXCEPTION:\n")[1].strip()
1915
- # Generate a solution for the error and execute it
1916
- error_solution_query = (
1917
- f"The following code was executed and resulted in an error:\n\n"
1918
- f"{response}\n\n"
1919
- f"Error: {error_message}\n\n"
1920
- f"Please provide a solution to fix this error in the code and execute it."
1921
- )
1922
- try:
1923
- new_response = self._ai_model.chat(error_solution_query)
1924
- self._handle_rawdog_response(new_response)
1925
- except webscout.exceptions.FailedToGenerateResponseError as e:
1926
- self._console.print(Markdown(f"LLM: [red]Error while generating solution: {e}[/red]"))
1927
- else:
1928
- self._console.print(Markdown("LLM: (Script executed successfully)"))
1929
- except Exception as e:
1930
- self._console.print(Markdown(f"LLM: [red]Error: {e}[/red]"))
1931
-
1932
-
1933
- async def process_async_query(self, query: str) -> None:
1934
- """
1935
- Asynchronously processes a user query, potentially enhancing it with web search results,
1936
- passing it to the AI model, and handling the response.
1937
-
1938
- Args:
1939
- query: The user's text input.
1940
-
1941
- Returns:
1942
- None
1943
- """
1944
- if self._web_search_enabled:
1945
- query = self._augment_query_with_web_search(query)
1946
-
1947
- # Apply code optimization if configured
1948
- if self._selected_optimizer == "code":
1949
- query = webscout.AIutel.Optimizers.code(query)
1950
-
1951
- async_model = self._get_async_ai_model()
1952
-
1953
- try:
1954
- async for response in async_model.chat(query, stream=True):
1955
- self._console.print(Markdown(f"LLM: {response}"), end="")
1956
- except webscout.exceptions.FailedToGenerateResponseError as e:
1957
- self._console.print(Markdown(f"LLM: [red]{e}[/red]"))
1958
- return
1959
-
1960
- # Handle Rawdog responses if enabled
1961
- if self._rawdog_enabled:
1962
- self._handle_rawdog_response(response)
1963
- else:
1964
- self._console.print(Markdown(f"LLM: {response}"))
1965
-
1966
- def _get_async_ai_model(self):
1967
- """
1968
- Determines the appropriate asynchronous AI model based on the selected provider.
1969
- """
1970
- if self._selected_provider == "g4fauto":
1971
- # Automatically select the best provider from g4f
1972
- test = TestProviders(quiet=self._suppress_output, timeout=self._timeout)
1973
- g4fauto = test.best if not self._ignore_working else test.auto
1974
- if isinstance(g4fauto, str):
1975
- self._selected_provider = "g4fauto+" + g4fauto
1976
- self._ai_model = self._create_async_g4f_model(g4fauto)
1977
- else:
1978
- raise Exception(
1979
- "No working g4f provider found. "
1980
- "Consider running 'webscout gpt4free test -y' first"
1981
- )
1982
- else:
1983
- # Use the specified provider
1984
- if self._selected_provider in async_provider_map:
1985
- self._ai_model = async_provider_map[self._selected_provider](
1986
- is_conversation=self._conversation_enabled,
1987
- max_tokens=self._max_tokens,
1988
- timeout=self._timeout,
1989
- intro=self._initial_prompt,
1990
- filepath=self._history_filepath,
1991
- update_file=self._update_history_file,
1992
- proxies={}, # Load proxies from config if needed
1993
- history_offset=self._history_offset,
1994
- act=self._awesome_prompt_content,
1995
- model=self._selected_model,
1996
- quiet=self._suppress_output,
1997
- auth=self._auth_token, # Pass API key if required
1998
- )
1999
- else:
2000
- raise Exception(
2001
- f"Asynchronous provider '{self._selected_provider}' is not yet supported"
2002
- )
2003
- return self._ai_model
2004
-
2005
- def _create_async_g4f_model(self, provider: str):
2006
- """
2007
- Creates an asynchronous g4f model instance using the provided provider and webscout.WEBS for web search.
2008
- """
2009
- return webscout.g4f.AsyncGPT4FREE(
2010
- provider=provider,
2011
- auth=self._auth_token,
2012
- max_tokens=self._max_tokens,
2013
- chat_completion=self._chat_completion_enabled,
2014
- ignore_working=self._ignore_working,
2015
- timeout=self._timeout,
2016
- intro=self._initial_prompt,
2017
- filepath=self._history_filepath,
2018
- update_file=self._update_history_file,
2019
- proxies={}, # Load proxies from config if needed
2020
- history_offset=self._history_offset,
2021
- act=self._awesome_prompt_content,
2022
- )
2023
-
2024
- if __name__ == "__main__":
2025
- assistant = TaskExecutor()
2026
- while True:
2027
- input_query = input("Enter your query: ")
2028
- assistant.process_query(input_query)
2029
-
1704
+ Code is in rawdog.py file
2030
1705
  ```
2031
1706
  ```shell
2032
1707
  python -m webscout.webai webai --provider "phind" --rawdog
@@ -1,9 +1,9 @@
1
1
  webscout/AIauto.py,sha256=xPGr_Z0h27XXNh4Wiufjn9TksDOqxqlaGcLUYKNP55w,18246
2
2
  webscout/AIbase.py,sha256=GoHbN8r0gq2saYRZv6LA-Fr9Jlcjv80STKFXUq2ZeGU,4710
3
- webscout/AIutel.py,sha256=MMfUvTQXYDtaFXsXtwKgv9V_qMK6WgOxdx7Wagdm2Lw,33542
3
+ webscout/AIutel.py,sha256=akfyVlJnIdo8jf8c1vzKDITtNdwAJHFqC5bEVGh7554,33597
4
4
  webscout/DWEBS.py,sha256=QLuT1IKu0lnwdl7W6c-ctBAO7Jj0Zk3PYm6-13BC7rU,25740
5
5
  webscout/LLM.py,sha256=LbGCZdJf8A5dwfoGS4tyy39tAh5BDdhMZP0ScKaaQfU,4184
6
- webscout/__init__.py,sha256=427p-hwpbqr0RdzzkvRAPYfSCAyiPte-JeHnUWG_nHA,2091
6
+ webscout/__init__.py,sha256=znxNHlt9EDBgWP1uD71EN9eKO4-WFpmN8_bPPmJaNLw,2142
7
7
  webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
8
8
  webscout/async_providers.py,sha256=holBv5SxanxVXc_92CBBaXHlB2IakB_fHnhyZaFjYF8,684
9
9
  webscout/cli.py,sha256=enw_dPTCG3sNC1TXt96XccnpRmF4Etr99nh-RbGYags,18784
@@ -13,9 +13,9 @@ webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
13
13
  webscout/tempid.py,sha256=5oc3UbXhPGKxrMRTfRABT-V-dNzH_hOKWtLYM6iCWd4,5896
14
14
  webscout/transcriber.py,sha256=EddvTSq7dPJ42V3pQVnGuEiYQ7WjJ9uyeR9kMSxN7uY,20622
15
15
  webscout/utils.py,sha256=CxeXvp0rWIulUrEaPZMaNfg_tSuQLRSV8uuHA2chyKE,2603
16
- webscout/version.py,sha256=IuTIikIXiglYKmugXFivfp0USNzx9FUxd_CVlae9bgk,23
16
+ webscout/version.py,sha256=-NWv4nLXKlNPAmvsqgPMnu9sdeUQAtJ95GCckHBql6M,23
17
17
  webscout/voice.py,sha256=0QjXTHAQmCK07IDZXRc7JXem47cnPJH7u3X0sVP1-UQ,967
18
- webscout/webai.py,sha256=qkvhYdyF5wNdmW4rNdH3RbfQxabEWlGvCyAk2SbH04k,86602
18
+ webscout/webai.py,sha256=Bs6HtPAxupTsUmuCGlylYQ325EDuYjFTJgmnbe5Gj5w,88471
19
19
  webscout/webscout_search.py,sha256=lFAot1-Qil_YfXieeLakDVDEX8Ckcima4ueXdOYwiMc,42804
20
20
  webscout/webscout_search_async.py,sha256=dooKGwLm0cwTml55Vy6NHPPY-nymEqX2h8laX94Zg5A,14537
21
21
  webscout/websx_search.py,sha256=n-qVwiHozJEF-GFRPcAfh4k1d_tscTmDe1dNL-1ngcU,12094
@@ -23,7 +23,7 @@ webscout/Extra/__init__.py,sha256=vlW4RoSl5v3d7j_Yq1XEMydrG9JM-On_afgK-HtRZsk,45
23
23
  webscout/Extra/autollama.py,sha256=DDdnb1tKEZWJaADVn9GXTZkMSwLKCcUGIjMKNlOBtK8,5419
24
24
  webscout/Extra/gguf.py,sha256=5zTNE5HxM_VQ5ONoocL8GG5fRXrgyLdEEjNzndG0oUw,7811
25
25
  webscout/Local/__init__.py,sha256=RN6klpbabPGNX2YzPm_hdeUcQvieUwvJt22uAO2RKSM,238
26
- webscout/Local/_version.py,sha256=3sFn1tDa2mT9Pb1-OGW4K3_zbiJ0mhPRqB2rnLfp28Q,83
26
+ webscout/Local/_version.py,sha256=J-XfaHI4CMBbIor8FPDPPUHW5Q1Y8wrhkVocEjQJ0qg,83
27
27
  webscout/Local/formats.py,sha256=BiZZSoN3e8S6-S-ykBL9ogSUs0vK11GaZ3ghc9U8GRk,18994
28
28
  webscout/Local/model.py,sha256=T_bzNNrxEyOyLyhp6fKwiuVBBkXC2a37LzJVCxFIxOU,30710
29
29
  webscout/Local/rawdog.py,sha256=ojY_O8Vb1KvR34OwWdfLgllgaAK_7HMf64ElMATvCXs,36689
@@ -38,6 +38,8 @@ webscout/Provider/Cohere.py,sha256=IXnRosYOaMAA65nvsKmN6ZkJGSdZFYQYBidzuNaCqX8,8
38
38
  webscout/Provider/Deepinfra.py,sha256=kVnWARJdEtIeIsZwGw3POq8B2dO87bDcJso3uOeCeOA,18750
39
39
  webscout/Provider/Deepseek.py,sha256=pnOB44ObuOfAsoi_bUGUvha3tfwd0rTJ9rnX-14QkL4,10550
40
40
  webscout/Provider/Gemini.py,sha256=_4DHWvlWuNAmVHPwHB1RjmryjTZZCthLa6lvPEHLvkQ,8451
41
+ webscout/Provider/Geminiflash.py,sha256=1kMPA-ypi1gmJoms606Z7j_51znpdofM2aAyo4Hl7wU,5951
42
+ webscout/Provider/Geminipro.py,sha256=nOifT5CRmnUg28iifSbOHkNLoKucLRr5zCj607mVrhw,5948
41
43
  webscout/Provider/Groq.py,sha256=QfgP3hKUcqq5vUA4Pzuu3HAgpJkKwLWNjjsnxtkCYd8,21094
42
44
  webscout/Provider/Koboldai.py,sha256=KwWx2yPlvT9BGx37iNvSbgzWkJ9I8kSOmeg7sL1hb0M,15806
43
45
  webscout/Provider/Leo.py,sha256=wbuDR-vFjLptfRC6yDlk74tINqNvCOzpISsK92lIgGg,19987
@@ -52,11 +54,11 @@ webscout/Provider/ThinkAnyAI.py,sha256=_qFjj0djxxrranyEY33w14oizyRjzlVwMv_hzvVtw
52
54
  webscout/Provider/VTLchat.py,sha256=_sErGr-wOi16ZAfiGOo0bPsAEMkjzzwreEsIqjIZMIU,10041
53
55
  webscout/Provider/Xjai.py,sha256=BIlk2ouz9Kh_0Gg9hPvTqhI7XtcmWdg5vHSX_4uGrIs,9039
54
56
  webscout/Provider/Yepchat.py,sha256=2Eit-A7w1ph1GQKNQuur_yaDzI64r0yBGxCIjDefJxQ,19875
55
- webscout/Provider/Youchat.py,sha256=UVGBuGSjv4uRibn1xflmCjYcfrRTKnDvX3adhag6T98,7976
56
- webscout/Provider/__init__.py,sha256=RaMdtYv7eQJ2vB8jXUHrkfNbx2DgRjbwc6DI40cOH1A,1809
57
- webscout-3.8.dist-info/LICENSE.md,sha256=9P0imsudI7MEvZe2pOcg8rKBn6E5FGHQ-riYozZI-Bk,2942
58
- webscout-3.8.dist-info/METADATA,sha256=hCQOSbTlIUBKkcTP9W8hPxuo0yXhkMbRHi7E0bSg4S4,69105
59
- webscout-3.8.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
60
- webscout-3.8.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
61
- webscout-3.8.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
62
- webscout-3.8.dist-info/RECORD,,
57
+ webscout/Provider/Youchat.py,sha256=fhMpt94pIPE_XDbC4z9xyfgA7NbkNE2wlRFJabsjv90,8069
58
+ webscout/Provider/__init__.py,sha256=nFRM7vno2a7y2lG-7mDXvzytI8irb_loC0BPGZtrh7w,1923
59
+ webscout-3.9.dist-info/LICENSE.md,sha256=9P0imsudI7MEvZe2pOcg8rKBn6E5FGHQ-riYozZI-Bk,2942
60
+ webscout-3.9.dist-info/METADATA,sha256=BGlQ0WLKmc-jx8j7dQhYR_tM8IZGORpTSWqEzSKYlSk,55625
61
+ webscout-3.9.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
62
+ webscout-3.9.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
63
+ webscout-3.9.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
64
+ webscout-3.9.dist-info/RECORD,,
File without changes