webscout 3.8__py3-none-any.whl → 4.0__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,2 +1,4 @@
1
1
  from .gguf import *
2
- from .autollama import *
2
+ from .autollama import *
3
+ from .weather import *
4
+ from .weather_ascii import *
@@ -0,0 +1,49 @@
1
+ import requests
2
+
3
+ def get(location):
4
+ """Fetches weather data for the given location.
5
+
6
+ Args:
7
+ location (str): The location for which to fetch weather data.
8
+
9
+ Returns:
10
+ dict: A dictionary containing weather data if the request is successful,
11
+ otherwise a string indicating the error.
12
+ """
13
+ url = f"https://wttr.in/{location}?format=j1"
14
+
15
+ response = requests.get(url)
16
+
17
+ if response.status_code == 200:
18
+ return response.json()
19
+ else:
20
+ return f"Error: Unable to fetch weather data. Status code: {response.status_code}"
21
+
22
+ def print_weather(weather_data):
23
+ """Prints the weather data in a user-friendly format.
24
+
25
+ Args:
26
+ weather_data (dict or str): The weather data returned from get_weather()
27
+ or an error message.
28
+ """
29
+ if isinstance(weather_data, str):
30
+ print(weather_data)
31
+ return
32
+
33
+ current = weather_data['current_condition'][0]
34
+ location_name = weather_data['nearest_area'][0]['areaName'][0]['value']
35
+
36
+ print(f"Weather in {location_name}:")
37
+ print(f"Temperature: {current['temp_C']}°C / {current['temp_F']}°F")
38
+ print(f"Condition: {current['weatherDesc'][0]['value']}")
39
+ print(f"Humidity: {current['humidity']}%")
40
+ print(f"Wind: {current['windspeedKmph']} km/h, {current['winddir16Point']}")
41
+
42
+
43
+ print("\nForecast:")
44
+ for day in weather_data['weather']:
45
+ date = day['date']
46
+ max_temp = day['maxtempC']
47
+ min_temp = day['mintempC']
48
+ desc = day['hourly'][4]['weatherDesc'][0]['value']
49
+ print(f"{date}: {min_temp}°C to {max_temp}°C, {desc}")
@@ -0,0 +1,18 @@
1
+ import requests
2
+
3
+ def get(location):
4
+ """Fetches ASCII art weather data for the given location.
5
+ Args:
6
+ location (str): The location for which to fetch weather data.
7
+
8
+ Returns:
9
+ str: ASCII art weather report if the request is successful,
10
+ otherwise an error message.
11
+ """
12
+ url = f"https://wttr.in/{location}"
13
+ response = requests.get(url, headers={'User-Agent': 'curl'})
14
+
15
+ if response.status_code == 200:
16
+ return "\n".join(response.text.splitlines()[:-1])
17
+ else:
18
+ return f"Error: Unable to fetch weather data. Status code: {response.status_code}"
@@ -1,3 +1,3 @@
1
1
  from llama_cpp import __version__ as __llama_cpp_version__
2
2
 
3
- __version__ = '3.7'
3
+ __version__ = '4.0'
@@ -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
  ]