webscout 4.3__py3-none-any.whl → 4.5__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/AIauto.py +5 -7
- webscout/AIutel.py +2 -1
- webscout/Agents/Onlinesearcher.py +175 -0
- webscout/Agents/__init__.py +2 -0
- webscout/Agents/functioncall.py +126 -0
- webscout/Extra/autollama.py +20 -9
- webscout/Extra/gguf.py +5 -19
- webscout/Extra/weather.py +27 -9
- webscout/Extra/weather_ascii.py +5 -0
- webscout/GoogleS.py +342 -0
- webscout/Provider/Andi.py +275 -0
- webscout/Provider/__init__.py +3 -1
- webscout/__init__.py +8 -4
- webscout/cli.py +22 -21
- webscout/utils.py +13 -3
- webscout/voice.py +8 -1
- webscout/webai.py +16 -0
- webscout/webscout_search.py +35 -26
- webscout/websx_search.py +18 -369
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/METADATA +17 -25
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/RECORD +25 -20
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/LICENSE.md +0 -0
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/WHEEL +0 -0
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/entry_points.txt +0 -0
- {webscout-4.3.dist-info → webscout-4.5.dist-info}/top_level.txt +0 -0
webscout/AIauto.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from webscout.AIbase import Provider, AsyncProvider
|
|
2
2
|
from webscout.Provider.ThinkAnyAI import ThinkAnyAI
|
|
3
3
|
from webscout.Provider.Xjai import Xjai
|
|
4
|
-
from webscout.Provider.Llama import
|
|
5
|
-
from webscout.Provider.Llama import AsyncLLAMA2
|
|
4
|
+
from webscout.Provider.Llama import LLAMA
|
|
6
5
|
from webscout.Provider.Leo import LEO
|
|
7
6
|
from webscout.Provider.Leo import AsyncLEO
|
|
8
7
|
from webscout.Provider.Koboldai import KOBOLDAI
|
|
@@ -44,7 +43,7 @@ provider_map: dict[
|
|
|
44
43
|
Union[
|
|
45
44
|
ThinkAnyAI,
|
|
46
45
|
Xjai,
|
|
47
|
-
|
|
46
|
+
LLAMA,
|
|
48
47
|
LEO,
|
|
49
48
|
KOBOLDAI,
|
|
50
49
|
OPENGPT,
|
|
@@ -69,7 +68,7 @@ provider_map: dict[
|
|
|
69
68
|
] = {
|
|
70
69
|
"ThinkAnyAI": ThinkAnyAI,
|
|
71
70
|
"Xjai": Xjai,
|
|
72
|
-
"LLAMA2":
|
|
71
|
+
"LLAMA2": LLAMA,
|
|
73
72
|
"LEO": LEO,
|
|
74
73
|
"KOBOLDAI": KOBOLDAI,
|
|
75
74
|
"OPENGPT": OPENGPT,
|
|
@@ -124,7 +123,7 @@ class AUTO(Provider):
|
|
|
124
123
|
self.provider: Union[
|
|
125
124
|
ThinkAnyAI,
|
|
126
125
|
Xjai,
|
|
127
|
-
|
|
126
|
+
LLAMA,
|
|
128
127
|
LEO,
|
|
129
128
|
KOBOLDAI,
|
|
130
129
|
OPENGPT,
|
|
@@ -353,13 +352,12 @@ class AsyncAUTO(AsyncProvider):
|
|
|
353
352
|
AsyncOPENGPT,
|
|
354
353
|
AsyncKOBOLDAI,
|
|
355
354
|
AsyncPhindSearch,
|
|
356
|
-
AsyncLLAMA2,
|
|
357
355
|
AsyncBLACKBOXAI,
|
|
358
356
|
AsyncGPT4FREE,
|
|
359
357
|
AsyncLEO,
|
|
360
358
|
ThinkAnyAI,
|
|
361
359
|
Xjai,
|
|
362
|
-
|
|
360
|
+
LLAMA,
|
|
363
361
|
LEO,
|
|
364
362
|
KOBOLDAI,
|
|
365
363
|
OPENGPT,
|
webscout/AIutel.py
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from webscout import WEBS
|
|
3
|
+
import httpx
|
|
4
|
+
from bs4 import BeautifulSoup
|
|
5
|
+
from typing import List, Dict
|
|
6
|
+
|
|
7
|
+
class DeepInfra:
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
model: str = "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
|
11
|
+
max_tokens: int = 8000,
|
|
12
|
+
timeout: int = 120,
|
|
13
|
+
system_prompt: str = "You are a helpful AI assistant.",
|
|
14
|
+
proxies: dict = {}
|
|
15
|
+
):
|
|
16
|
+
self.model = model
|
|
17
|
+
self.max_tokens = max_tokens
|
|
18
|
+
self.timeout = timeout
|
|
19
|
+
self.system_prompt = system_prompt
|
|
20
|
+
self.chat_endpoint = "https://api.deepinfra.com/v1/openai/chat/completions"
|
|
21
|
+
|
|
22
|
+
self.headers = {
|
|
23
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
|
24
|
+
'Accept-Language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3',
|
|
25
|
+
'Cache-Control': 'no-cache',
|
|
26
|
+
'Connection': 'keep-alive',
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Origin': 'https://deepinfra.com',
|
|
29
|
+
'Pragma': 'no-cache',
|
|
30
|
+
'Referer': 'https://deepinfra.com/',
|
|
31
|
+
'Sec-Fetch-Dest': 'empty',
|
|
32
|
+
'Sec-Fetch-Mode': 'cors',
|
|
33
|
+
'Sec-Fetch-Site': 'same-site',
|
|
34
|
+
'X-Deepinfra-Source': 'web-embed',
|
|
35
|
+
'accept': 'text/event-stream',
|
|
36
|
+
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
|
|
37
|
+
'sec-ch-ua-mobile': '?0',
|
|
38
|
+
'sec-ch-ua-platform': '"macOS"'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
self.client = httpx.Client(proxies=proxies, headers=self.headers)
|
|
42
|
+
|
|
43
|
+
def ask(self, prompt: str, system_prompt: str = None) -> str:
|
|
44
|
+
payload = {
|
|
45
|
+
'model': self.model,
|
|
46
|
+
'messages': [
|
|
47
|
+
{"role": "system", "content": system_prompt or self.system_prompt},
|
|
48
|
+
{"role": "user", "content": prompt},
|
|
49
|
+
],
|
|
50
|
+
'temperature': 0.7,
|
|
51
|
+
'max_tokens': self.max_tokens,
|
|
52
|
+
'stop': []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
response = self.client.post(self.chat_endpoint, json=payload, timeout=self.timeout)
|
|
56
|
+
if response.status_code != 200:
|
|
57
|
+
raise Exception(f"Failed to generate response - ({response.status_code}, {response.reason_phrase}) - {response.text}")
|
|
58
|
+
|
|
59
|
+
resp = response.json()
|
|
60
|
+
return resp["choices"][0]["message"]["content"]
|
|
61
|
+
|
|
62
|
+
class WebSearchAgent:
|
|
63
|
+
|
|
64
|
+
def __init__(self, model="Qwen/Qwen2-72B-Instruct"):
|
|
65
|
+
self.webs = WEBS()
|
|
66
|
+
self.deepinfra = DeepInfra(model=model)
|
|
67
|
+
|
|
68
|
+
def generate_search_query(self, information):
|
|
69
|
+
prompt = f"""
|
|
70
|
+
Instructions:
|
|
71
|
+
You are a smart online searcher for a large language model.
|
|
72
|
+
Given information, you must create a search query to search the internet for relevant information.
|
|
73
|
+
Your search query must be in the form of a json response.
|
|
74
|
+
Exact json response format must be as follows:
|
|
75
|
+
|
|
76
|
+
{{
|
|
77
|
+
"search_query": "your search query"
|
|
78
|
+
}}
|
|
79
|
+
- You must only provide ONE search query
|
|
80
|
+
- You must provide the BEST search query for the given information
|
|
81
|
+
- The search query must be normal text.
|
|
82
|
+
|
|
83
|
+
Information: {information}
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
response = self.deepinfra.ask(prompt)
|
|
87
|
+
return json.loads(response)["search_query"]
|
|
88
|
+
|
|
89
|
+
def search(self, information, region='wt-wt', safesearch='off', timelimit='y', max_results=5):
|
|
90
|
+
search_query = self.generate_search_query(information)
|
|
91
|
+
|
|
92
|
+
results = []
|
|
93
|
+
with self.webs as webs:
|
|
94
|
+
for result in webs.text(search_query, region=region, safesearch=safesearch, timelimit=timelimit, max_results=max_results):
|
|
95
|
+
results.append(result)
|
|
96
|
+
|
|
97
|
+
return results
|
|
98
|
+
|
|
99
|
+
def extract_urls(self, results):
|
|
100
|
+
urls = []
|
|
101
|
+
for result in results:
|
|
102
|
+
url = result.get('href')
|
|
103
|
+
if url:
|
|
104
|
+
urls.append(url)
|
|
105
|
+
return list(set(urls)) # Remove duplicates
|
|
106
|
+
|
|
107
|
+
def fetch_webpage(self, url: str) -> str:
|
|
108
|
+
try:
|
|
109
|
+
response = httpx.get(url, timeout=120)
|
|
110
|
+
if response.status_code == 200:
|
|
111
|
+
html = response.text
|
|
112
|
+
soup = BeautifulSoup(html, 'html.parser')
|
|
113
|
+
|
|
114
|
+
# Extract text from <p> tags
|
|
115
|
+
paragraphs = soup.find_all('p')
|
|
116
|
+
text = ' '.join([p.get_text() for p in paragraphs])
|
|
117
|
+
|
|
118
|
+
# Limit the text to around 4000 words
|
|
119
|
+
words = text.split()
|
|
120
|
+
if len(words) > 4000:
|
|
121
|
+
text = ' '.join(words[:4000]) + '...'
|
|
122
|
+
|
|
123
|
+
return text
|
|
124
|
+
else:
|
|
125
|
+
return f"Failed to fetch {url}: HTTP {response.status}"
|
|
126
|
+
except Exception as e:
|
|
127
|
+
return f"Error fetching {url}: {str(e)}"
|
|
128
|
+
|
|
129
|
+
def fetch_all_webpages(self, urls: List[str]) -> List[Dict[str, str]]:
|
|
130
|
+
contents = []
|
|
131
|
+
for url in urls:
|
|
132
|
+
content = self.fetch_webpage(url)
|
|
133
|
+
contents.append({"url": url, "content": content})
|
|
134
|
+
return contents
|
|
135
|
+
|
|
136
|
+
class OnlineSearcher:
|
|
137
|
+
def __init__(self, model="meta-llama/Meta-Llama-3.1-405B-Instruct"):
|
|
138
|
+
self.agent = WebSearchAgent(model)
|
|
139
|
+
self.deepinfra = DeepInfra(model="model")
|
|
140
|
+
|
|
141
|
+
def answer_question(self, question: str) -> str:
|
|
142
|
+
# Perform web search
|
|
143
|
+
search_results = self.agent.search(question)
|
|
144
|
+
|
|
145
|
+
# Extract URLs
|
|
146
|
+
urls = self.agent.extract_urls(search_results)
|
|
147
|
+
|
|
148
|
+
# Fetch webpage contents
|
|
149
|
+
webpage_contents = self.agent.fetch_all_webpages(urls)
|
|
150
|
+
|
|
151
|
+
# Prepare context for AI
|
|
152
|
+
context = "Based on the following search results and webpage contents:\n\n"
|
|
153
|
+
for i, result in enumerate(search_results, 1):
|
|
154
|
+
context += f"{i}. Title: {result['title']}\n URL: {result['href']}\n Snippet: {result['body']}\n\n"
|
|
155
|
+
|
|
156
|
+
context += "Extracted webpage contents:\n"
|
|
157
|
+
for i, webpage in enumerate(webpage_contents):
|
|
158
|
+
context += f"{i}. URL: {webpage['url']}\n Content: {webpage['content'][:4000]}...\n\n"
|
|
159
|
+
|
|
160
|
+
# Generate answer using AI
|
|
161
|
+
prompt = f"{context}\n\nQuestion: {question}\n\nPlease provide a comprehensive answer to the question based on the search results and webpage contents above. Include relevant webpage URLs in your answer when appropriate. If the search results and webpage contents don't contain relevant information, please state that and provide the best answer you can based on your general knowledge. [YOUR RESPONSE WITH SOURCE LINKS ([➊](URL))"
|
|
162
|
+
|
|
163
|
+
answer = self.deepinfra.ask(prompt)
|
|
164
|
+
return answer
|
|
165
|
+
|
|
166
|
+
# Usage example
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
assistant = OnlineSearcher()
|
|
169
|
+
while True:
|
|
170
|
+
question = input(">>> ")
|
|
171
|
+
if question.lower() == 'quit':
|
|
172
|
+
break
|
|
173
|
+
answer = assistant.answer_question(question)
|
|
174
|
+
print(answer)
|
|
175
|
+
print("\n" + "-"*50 + "\n")
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from webscout import DeepInfra, WEBS
|
|
4
|
+
|
|
5
|
+
class FunctionCallingAgent:
|
|
6
|
+
def __init__(self, model: str = "Qwen/Qwen2-72B-Instruct", system_prompt: str = 'You are a helpful assistant that will always answer what user wants', tools: list = None):
|
|
7
|
+
self.deepinfra = DeepInfra(model=model, system_prompt=system_prompt)
|
|
8
|
+
self.tools = tools if tools is not None else []
|
|
9
|
+
# logging.basicConfig(level=logging.INFO)
|
|
10
|
+
# self.webs = WEBS() # Initialize a WEBS object for web search
|
|
11
|
+
|
|
12
|
+
def function_call_handler(self, message_text: str):
|
|
13
|
+
"""Handles function calls based on the provided message text
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
message_text (str): The input message text from the user.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
dict: The extracted function call and arguments.
|
|
20
|
+
"""
|
|
21
|
+
system_message = f'[SYSTEM]You are a helpful assistant. You have access to the following functions: \n {str(self.tools)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_2": "value_2", ... }} }} </functioncall> [USER] {message_text}'
|
|
22
|
+
|
|
23
|
+
response = self.deepinfra.chat(system_message)
|
|
24
|
+
# logging.info(f"Raw response: {response}")
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
# Extract the JSON-like part of the response
|
|
28
|
+
start_idx = response.find("{")
|
|
29
|
+
end_idx = response.rfind("}") + 1
|
|
30
|
+
if start_idx == -1 or end_idx == -1:
|
|
31
|
+
raise ValueError("JSON-like structure not found in the response")
|
|
32
|
+
|
|
33
|
+
response_json_str = response[start_idx:end_idx]
|
|
34
|
+
# Ensure the JSON string is properly formatted
|
|
35
|
+
response_json_str = response_json_str.replace("'", '"') # Replace single quotes with double quotes
|
|
36
|
+
response_json_str = response_json_str.strip()
|
|
37
|
+
response_data = json.loads(response_json_str)
|
|
38
|
+
except (ValueError, json.JSONDecodeError) as e:
|
|
39
|
+
# logging.error(f"An error occurred while parsing response: {e}")
|
|
40
|
+
return {"error": str(e)}
|
|
41
|
+
|
|
42
|
+
return response_data
|
|
43
|
+
|
|
44
|
+
def execute_function(self, function_call_data: dict) -> str:
|
|
45
|
+
"""Executes the specified function with the provided arguments.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
function_call_data (dict): A dictionary containing the function name and arguments.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
str: The result of the function execution.
|
|
52
|
+
"""
|
|
53
|
+
function_name = function_call_data.get("name")
|
|
54
|
+
arguments = function_call_data.get("arguments", "{}") # Default to empty dict if not present
|
|
55
|
+
|
|
56
|
+
# Parse the arguments string into a dictionary
|
|
57
|
+
try:
|
|
58
|
+
arguments_dict = json.loads(arguments)
|
|
59
|
+
except json.JSONDecodeError:
|
|
60
|
+
# logging.error("Failed to parse arguments as JSON.")
|
|
61
|
+
return "Invalid arguments format."
|
|
62
|
+
|
|
63
|
+
# logging.info(f"Executing function: {function_name} with arguments: {arguments_dict}")
|
|
64
|
+
|
|
65
|
+
# if function_name == "web_search":
|
|
66
|
+
# query = arguments_dict.get("query")
|
|
67
|
+
# if query:
|
|
68
|
+
# search_results = self.webs.text(query)
|
|
69
|
+
# # You can process the search results here, e.g., extract URLs, summarize, etc.
|
|
70
|
+
# return f"Here's what I found:\n\n{search_results}"
|
|
71
|
+
# else:
|
|
72
|
+
# return "Please provide a search query."
|
|
73
|
+
# else:
|
|
74
|
+
# return f"Function '{function_name}' is not yet implemented."
|
|
75
|
+
|
|
76
|
+
# Example usage
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
tools = [
|
|
79
|
+
{
|
|
80
|
+
"type": "function",
|
|
81
|
+
"function": {
|
|
82
|
+
"name": "UserDetail",
|
|
83
|
+
"parameters": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"title": "UserDetail",
|
|
86
|
+
"properties": {
|
|
87
|
+
"name": {
|
|
88
|
+
"title": "Name",
|
|
89
|
+
"type": "string"
|
|
90
|
+
},
|
|
91
|
+
"age": {
|
|
92
|
+
"title": "Age",
|
|
93
|
+
"type": "integer"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"required": ["name", "age"]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"type": "function",
|
|
102
|
+
"function": {
|
|
103
|
+
"name": "web_search",
|
|
104
|
+
"description": "Search query on google",
|
|
105
|
+
"parameters": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"properties": {
|
|
108
|
+
"query": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"description": "web search query"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"required": ["query"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
agent = FunctionCallingAgent(tools=tools)
|
|
120
|
+
message = "tell me about HelpingAI flash"
|
|
121
|
+
function_call_data = agent.function_call_handler(message)
|
|
122
|
+
print(f"Function Call Data: {function_call_data}")
|
|
123
|
+
|
|
124
|
+
if "error" not in function_call_data:
|
|
125
|
+
result = agent.execute_function(function_call_data)
|
|
126
|
+
# print(f"Function Execution Result: {result}")
|
webscout/Extra/autollama.py
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import subprocess
|
|
2
2
|
import argparse
|
|
3
3
|
import os
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.panel import Panel
|
|
6
|
+
from rich.progress import track
|
|
7
|
+
from yaspin import yaspin
|
|
8
|
+
from pyfiglet import figlet_format
|
|
9
|
+
import time
|
|
10
|
+
|
|
11
|
+
console = Console()
|
|
4
12
|
|
|
5
13
|
def autollama(model_path, gguf_file):
|
|
6
14
|
"""Manages models with Ollama using the autollama.sh script.
|
|
@@ -9,6 +17,7 @@ def autollama(model_path, gguf_file):
|
|
|
9
17
|
model_path (str): The path to the Hugging Face model.
|
|
10
18
|
gguf_file (str): The name of the GGUF file.
|
|
11
19
|
"""
|
|
20
|
+
console.print(f"[bold green]{figlet_format('Autollama')}[/]\n", justify="center")
|
|
12
21
|
|
|
13
22
|
# Check if autollama.sh exists in the current working directory
|
|
14
23
|
script_path = os.path.join(os.getcwd(), "autollama.sh")
|
|
@@ -172,25 +181,27 @@ echo "Use Ollama run $MODEL_NAME"
|
|
|
172
181
|
# Execute the command
|
|
173
182
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
174
183
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
print(line, end='')
|
|
178
|
-
|
|
179
|
-
for line in process.stderr:
|
|
180
|
-
print(line, end='')
|
|
184
|
+
for line in iter(process.stdout.readline, ''):
|
|
185
|
+
console.print(Panel(line.strip(), title="Autollama Output", expand=False))
|
|
181
186
|
|
|
187
|
+
for line in iter(process.stderr.readline, ''):
|
|
188
|
+
console.print(Panel(line.strip(), title="Autollama Errors (if any)", expand=False))
|
|
189
|
+
|
|
182
190
|
process.wait()
|
|
191
|
+
console.print("[green]Model is ready![/]")
|
|
183
192
|
|
|
184
193
|
def main():
|
|
185
194
|
parser = argparse.ArgumentParser(description='Automatically create and run an Ollama model in Ollama')
|
|
186
|
-
parser.add_argument('-m', '--model_path', required=True, help='Set the
|
|
195
|
+
parser.add_argument('-m', '--model_path', required=True, help='Set the huggingface model id to the Hugging Face model')
|
|
187
196
|
parser.add_argument('-g', '--gguf_file', required=True, help='Set the GGUF file name')
|
|
188
197
|
args = parser.parse_args()
|
|
189
198
|
|
|
190
199
|
try:
|
|
191
|
-
|
|
200
|
+
with yaspin(text="Processing...") as spinner:
|
|
201
|
+
autollama(args.model_path, args.gguf_file)
|
|
202
|
+
spinner.ok("Done!")
|
|
192
203
|
except Exception as e:
|
|
193
|
-
print(f"Error: {e}")
|
|
204
|
+
console.print(f"[red]Error: {e}[/]")
|
|
194
205
|
exit(1)
|
|
195
206
|
|
|
196
207
|
if __name__ == "__main__":
|
webscout/Extra/gguf.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# webscout/Extra/gguf.py
|
|
2
2
|
import subprocess
|
|
3
|
-
import argparse
|
|
4
3
|
import os
|
|
4
|
+
from pyfiglet import figlet_format
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
5
8
|
|
|
6
9
|
def convert(model_id, username=None, token=None, quantization_methods="q4_k_m,q5_k_m"):
|
|
7
10
|
"""Converts and quantizes a Hugging Face model to GGUF format.
|
|
@@ -17,6 +20,7 @@ def convert(model_id, username=None, token=None, quantization_methods="q4_k_m,q5
|
|
|
17
20
|
ValueError: If an invalid quantization method is provided.
|
|
18
21
|
"""
|
|
19
22
|
|
|
23
|
+
console.print(f"[bold green]{figlet_format('GGUF Converter')}[/]\n", justify="center")
|
|
20
24
|
# List of valid quantization methods
|
|
21
25
|
valid_methods = [
|
|
22
26
|
"q2_k", "q3_k_l", "q3_k_m", "q3_k_s",
|
|
@@ -220,21 +224,3 @@ echo "Script completed."
|
|
|
220
224
|
process.wait()
|
|
221
225
|
|
|
222
226
|
|
|
223
|
-
def main():
|
|
224
|
-
parser = argparse.ArgumentParser(description='Convert and quantize model using gguf.sh')
|
|
225
|
-
parser.add_argument('-m', '--model_id', required=True, help='Set the HF model ID (e.g., "google/flan-t5-xl")')
|
|
226
|
-
parser.add_argument('-u', '--username', help='Set your Hugging Face username (required for uploads)')
|
|
227
|
-
parser.add_argument('-t', '--token', help='Set your Hugging Face API token (required for uploads)')
|
|
228
|
-
parser.add_argument('-q', '--quantization_methods', default="q4_k_m,q5_k_m",
|
|
229
|
-
help='Comma-separated quantization methods (default: q4_k_m,q5_k_m). Valid methods: q2_k, q3_k_l, q3_k_m, q3_k_s, q4_0, q4_1, q4_k_m, q4_k_s, q5_0, q5_1, q5_k_m, q5_k_s, q6_k, q8_0')
|
|
230
|
-
|
|
231
|
-
args = parser.parse_args()
|
|
232
|
-
|
|
233
|
-
try:
|
|
234
|
-
convert(args.model_id, args.username, args.token, args.quantization_methods)
|
|
235
|
-
except ValueError as e:
|
|
236
|
-
print(e)
|
|
237
|
-
exit(1)
|
|
238
|
-
|
|
239
|
-
if __name__ == "__main__":
|
|
240
|
-
main()
|
webscout/Extra/weather.py
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import requests
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
from rich.table import Table
|
|
4
|
+
from yaspin import yaspin
|
|
5
|
+
from pyfiglet import figlet_format
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
2
8
|
|
|
3
9
|
def get(location):
|
|
4
10
|
"""Fetches weather data for the given location.
|
|
@@ -12,7 +18,9 @@ def get(location):
|
|
|
12
18
|
"""
|
|
13
19
|
url = f"https://wttr.in/{location}?format=j1"
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
with yaspin(text="Fetching weather data...") as spinner:
|
|
22
|
+
response = requests.get(url)
|
|
23
|
+
spinner.ok("✅ ")
|
|
16
24
|
|
|
17
25
|
if response.status_code == 200:
|
|
18
26
|
return response.json()
|
|
@@ -27,23 +35,33 @@ def print_weather(weather_data):
|
|
|
27
35
|
or an error message.
|
|
28
36
|
"""
|
|
29
37
|
if isinstance(weather_data, str):
|
|
30
|
-
print(weather_data)
|
|
38
|
+
console.print(f"[bold red]Error:[/] {weather_data}")
|
|
31
39
|
return
|
|
32
40
|
|
|
33
41
|
current = weather_data['current_condition'][0]
|
|
34
42
|
location_name = weather_data['nearest_area'][0]['areaName'][0]['value']
|
|
35
43
|
|
|
36
|
-
print(f"Weather
|
|
37
|
-
print(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']}")
|
|
44
|
+
console.print(f"[bold blue]\n{figlet_format('Weather Report')}[/]\n", justify="center")
|
|
45
|
+
console.print(f"[bold green]Weather in {location_name}:[/]\n")
|
|
41
46
|
|
|
47
|
+
table = Table(show_header=False, show_lines=True)
|
|
48
|
+
table.add_row("Temperature:", f"{current['temp_C']}°C / {current['temp_F']}°F")
|
|
49
|
+
table.add_row("Condition:", current['weatherDesc'][0]['value'])
|
|
50
|
+
table.add_row("Humidity:", f"{current['humidity']}%")
|
|
51
|
+
table.add_row("Wind:", f"{current['windspeedKmph']} km/h, {current['winddir16Point']}")
|
|
52
|
+
console.print(table)
|
|
42
53
|
|
|
43
|
-
print("\
|
|
54
|
+
console.print(f"\n[bold green]Forecast:[/]")
|
|
55
|
+
table = Table(show_header=True, header_style="bold cyan")
|
|
56
|
+
table.add_column("Date", style="dim", width=12)
|
|
57
|
+
table.add_column("Temperature Range")
|
|
58
|
+
table.add_column("Description")
|
|
59
|
+
|
|
44
60
|
for day in weather_data['weather']:
|
|
45
61
|
date = day['date']
|
|
46
62
|
max_temp = day['maxtempC']
|
|
47
63
|
min_temp = day['mintempC']
|
|
48
64
|
desc = day['hourly'][4]['weatherDesc'][0]['value']
|
|
49
|
-
|
|
65
|
+
table.add_row(date, f"{min_temp}°C to {max_temp}°C", desc)
|
|
66
|
+
console.print(table)
|
|
67
|
+
|
webscout/Extra/weather_ascii.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import requests
|
|
2
|
+
from rich.console import Console
|
|
3
|
+
from pyfiglet import figlet_format
|
|
2
4
|
|
|
5
|
+
console = Console()
|
|
3
6
|
def get(location):
|
|
4
7
|
"""Fetches ASCII art weather data for the given location.
|
|
5
8
|
Args:
|
|
@@ -9,6 +12,7 @@ def get(location):
|
|
|
9
12
|
str: ASCII art weather report if the request is successful,
|
|
10
13
|
otherwise an error message.
|
|
11
14
|
"""
|
|
15
|
+
console.print(f"[bold green]{figlet_format('Weather')}[/]\n", justify="center")
|
|
12
16
|
url = f"https://wttr.in/{location}"
|
|
13
17
|
response = requests.get(url, headers={'User-Agent': 'curl'})
|
|
14
18
|
|
|
@@ -16,3 +20,4 @@ def get(location):
|
|
|
16
20
|
return "\n".join(response.text.splitlines()[:-1])
|
|
17
21
|
else:
|
|
18
22
|
return f"Error: Unable to fetch weather data. Status code: {response.status_code}"
|
|
23
|
+
|