webscout 4.1__py3-none-any.whl → 4.2__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 +2 -1
- webscout/Local/_version.py +1 -1
- webscout/Provider/OLLAMA.py +187 -0
- webscout/Provider/__init__.py +2 -1
- webscout/__init__.py +1 -0
- webscout/version.py +1 -1
- webscout/webai.py +14 -0
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/METADATA +10 -1
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/RECORD +13 -12
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/LICENSE.md +0 -0
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/WHEEL +0 -0
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/entry_points.txt +0 -0
- {webscout-4.1.dist-info → webscout-4.2.dist-info}/top_level.txt +0 -0
webscout/AIutel.py
CHANGED
|
@@ -52,6 +52,7 @@ webai = [
|
|
|
52
52
|
"vtlchat",
|
|
53
53
|
"geminiflash",
|
|
54
54
|
"geminipro",
|
|
55
|
+
"ollama"
|
|
55
56
|
]
|
|
56
57
|
|
|
57
58
|
gpt4free_providers = [
|
|
@@ -196,7 +197,7 @@ class Conversation:
|
|
|
196
197
|
"""
|
|
197
198
|
self.status = status
|
|
198
199
|
self.max_tokens_to_sample = max_tokens
|
|
199
|
-
self.chat_history =
|
|
200
|
+
self.chat_history = self.intro
|
|
200
201
|
self.history_format = "\nUser : %(user)s\nLLM :%(llm)s"
|
|
201
202
|
self.file = filepath
|
|
202
203
|
self.update_file = update_file
|
webscout/Local/_version.py
CHANGED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import uuid
|
|
3
|
+
import requests
|
|
4
|
+
from requests import get
|
|
5
|
+
from uuid import uuid4
|
|
6
|
+
from re import findall
|
|
7
|
+
from requests.exceptions import RequestException
|
|
8
|
+
from curl_cffi.requests import get, RequestsError
|
|
9
|
+
import g4f
|
|
10
|
+
from random import randint
|
|
11
|
+
from PIL import Image
|
|
12
|
+
import io
|
|
13
|
+
import re
|
|
14
|
+
import json
|
|
15
|
+
import yaml
|
|
16
|
+
from ..AIutel import Optimizers
|
|
17
|
+
from ..AIutel import Conversation
|
|
18
|
+
from ..AIutel import AwesomePrompts, sanitize_stream
|
|
19
|
+
from ..AIbase import Provider, AsyncProvider
|
|
20
|
+
from webscout import exceptions
|
|
21
|
+
from typing import Any, AsyncGenerator, Dict
|
|
22
|
+
import logging
|
|
23
|
+
import httpx
|
|
24
|
+
import ollama
|
|
25
|
+
|
|
26
|
+
class OLLAMA(Provider):
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
model: str = 'qwen2:0.5b',
|
|
30
|
+
is_conversation: bool = True,
|
|
31
|
+
max_tokens: int = 600,
|
|
32
|
+
timeout: int = 30,
|
|
33
|
+
intro: str = None,
|
|
34
|
+
filepath: str = None,
|
|
35
|
+
update_file: bool = True,
|
|
36
|
+
proxies: dict = {},
|
|
37
|
+
history_offset: int = 10250,
|
|
38
|
+
act: str = None,
|
|
39
|
+
):
|
|
40
|
+
"""Instantiates Ollama
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
model (str, optional): Model name. Defaults to 'llama2'.
|
|
44
|
+
is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
|
|
45
|
+
max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
|
|
46
|
+
timeout (int, optional): Http request timeout. Defaults to 30.
|
|
47
|
+
intro (str, optional): Conversation introductory prompt. Defaults to None.
|
|
48
|
+
filepath (str, optional): Path to file containing conversation history. Defaults to None.
|
|
49
|
+
update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
|
|
50
|
+
proxies (dict, optional): Http request proxies. Defaults to {}.
|
|
51
|
+
history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
|
|
52
|
+
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
|
|
53
|
+
"""
|
|
54
|
+
self.model = model
|
|
55
|
+
self.is_conversation = is_conversation
|
|
56
|
+
self.max_tokens_to_sample = max_tokens
|
|
57
|
+
self.timeout = timeout
|
|
58
|
+
self.last_response = {}
|
|
59
|
+
|
|
60
|
+
self.__available_optimizers = (
|
|
61
|
+
method
|
|
62
|
+
for method in dir(Optimizers)
|
|
63
|
+
if callable(getattr(Optimizers, method)) and not method.startswith("__")
|
|
64
|
+
)
|
|
65
|
+
Conversation.intro = (
|
|
66
|
+
AwesomePrompts().get_act(
|
|
67
|
+
act, raise_not_found=True, default=None, case_insensitive=True
|
|
68
|
+
)
|
|
69
|
+
if act
|
|
70
|
+
else intro or Conversation.intro
|
|
71
|
+
)
|
|
72
|
+
self.conversation = Conversation(
|
|
73
|
+
is_conversation, self.max_tokens_to_sample, filepath, update_file
|
|
74
|
+
)
|
|
75
|
+
self.conversation.history_offset = history_offset
|
|
76
|
+
|
|
77
|
+
def ask(
|
|
78
|
+
self,
|
|
79
|
+
prompt: str,
|
|
80
|
+
stream: bool = False,
|
|
81
|
+
raw: bool = False,
|
|
82
|
+
optimizer: str = None,
|
|
83
|
+
conversationally: bool = False,
|
|
84
|
+
) -> dict | AsyncGenerator:
|
|
85
|
+
"""Chat with AI
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
prompt (str): Prompt to be send.
|
|
89
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
90
|
+
raw (bool, optional): Stream back raw response as received. Defaults to False.
|
|
91
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
92
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
93
|
+
Returns:
|
|
94
|
+
dict|AsyncGenerator : ai content
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"text" : "print('How may I help you today?')"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
"""
|
|
101
|
+
conversation_prompt = self.conversation.gen_complete_prompt(prompt)
|
|
102
|
+
if optimizer:
|
|
103
|
+
if optimizer in self.__available_optimizers:
|
|
104
|
+
conversation_prompt = getattr(Optimizers, optimizer)(
|
|
105
|
+
conversation_prompt if conversationally else prompt
|
|
106
|
+
)
|
|
107
|
+
else:
|
|
108
|
+
raise Exception(
|
|
109
|
+
f"Optimizer is not one of {self.__available_optimizers}"
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def for_stream():
|
|
113
|
+
stream = ollama.chat(model=self.model, messages=[
|
|
114
|
+
{'role': 'user', 'content': conversation_prompt}
|
|
115
|
+
], stream=True)
|
|
116
|
+
|
|
117
|
+
message_load = ""
|
|
118
|
+
for chunk in stream:
|
|
119
|
+
message_load += chunk['message']['content']
|
|
120
|
+
yield chunk['message']['content'] if raw else dict(text=message_load)
|
|
121
|
+
self.last_response.update(dict(text=message_load))
|
|
122
|
+
self.conversation.update_chat_history(
|
|
123
|
+
prompt, self.get_message(self.last_response)
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def for_non_stream():
|
|
127
|
+
response = ollama.chat(model=self.model, messages=[
|
|
128
|
+
{'role': 'user', 'content': conversation_prompt}
|
|
129
|
+
])
|
|
130
|
+
self.last_response.update(dict(text=response['message']['content']))
|
|
131
|
+
self.conversation.update_chat_history(
|
|
132
|
+
prompt, self.get_message(self.last_response)
|
|
133
|
+
)
|
|
134
|
+
return self.last_response
|
|
135
|
+
|
|
136
|
+
return for_stream() if stream else for_non_stream()
|
|
137
|
+
|
|
138
|
+
def chat(
|
|
139
|
+
self,
|
|
140
|
+
prompt: str,
|
|
141
|
+
stream: bool = False,
|
|
142
|
+
optimizer: str = None,
|
|
143
|
+
conversationally: bool = False,
|
|
144
|
+
) -> str | AsyncGenerator:
|
|
145
|
+
"""Generate response `str`
|
|
146
|
+
Args:
|
|
147
|
+
prompt (str): Prompt to be send.
|
|
148
|
+
stream (bool, optional): Flag for streaming response. Defaults to False.
|
|
149
|
+
optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
|
|
150
|
+
conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
|
|
151
|
+
Returns:
|
|
152
|
+
str: Response generated
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
def for_stream():
|
|
156
|
+
for response in self.ask(
|
|
157
|
+
prompt, True, optimizer=optimizer, conversationally=conversationally
|
|
158
|
+
):
|
|
159
|
+
yield self.get_message(response)
|
|
160
|
+
|
|
161
|
+
def for_non_stream():
|
|
162
|
+
return self.get_message(
|
|
163
|
+
self.ask(
|
|
164
|
+
prompt,
|
|
165
|
+
False,
|
|
166
|
+
optimizer=optimizer,
|
|
167
|
+
conversationally=conversationally,
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
return for_stream() if stream else for_non_stream()
|
|
172
|
+
|
|
173
|
+
def get_message(self, response: dict) -> str:
|
|
174
|
+
"""Retrieves message only from response
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
response (dict): Response generated by `self.ask`
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
str: Message extracted
|
|
181
|
+
"""
|
|
182
|
+
assert isinstance(response, dict), "Response should be of dict data-type only"
|
|
183
|
+
return response["text"]
|
|
184
|
+
if __name__ == "__main__":
|
|
185
|
+
ollama_provider = OLLAMA(model="qwen2:0.5b")
|
|
186
|
+
response = ollama_provider.chat("What is the meaning of life?")
|
|
187
|
+
print(response)
|
webscout/Provider/__init__.py
CHANGED
|
@@ -37,7 +37,7 @@ from .Deepinfra import DeepInfra, VLM, AsyncDeepInfra
|
|
|
37
37
|
from .VTLchat import VTLchat
|
|
38
38
|
from .Geminipro import GEMINIPRO
|
|
39
39
|
from .Geminiflash import GEMINIFLASH
|
|
40
|
-
|
|
40
|
+
from .OLLAMA import OLLAMA
|
|
41
41
|
__all__ = [
|
|
42
42
|
'ThinkAnyAI',
|
|
43
43
|
'Xjai',
|
|
@@ -78,6 +78,7 @@ __all__ = [
|
|
|
78
78
|
'OPENGPTv2',
|
|
79
79
|
'GEMINIPRO',
|
|
80
80
|
'GEMINIFLASH',
|
|
81
|
+
'OLLAMA'
|
|
81
82
|
|
|
82
83
|
|
|
83
84
|
]
|
webscout/__init__.py
CHANGED
webscout/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "4.
|
|
1
|
+
__version__ = "4.2"
|
|
2
2
|
__prog__ = "webscout"
|
webscout/webai.py
CHANGED
|
@@ -831,7 +831,21 @@ class Main(cmd.Cmd):
|
|
|
831
831
|
act=awesome_prompt,
|
|
832
832
|
quiet=quiet,
|
|
833
833
|
)
|
|
834
|
+
elif provider == "ollama":
|
|
835
|
+
from webscout import OLLAMA
|
|
834
836
|
|
|
837
|
+
self.bot = OLLAMA(
|
|
838
|
+
is_conversation=disable_conversation,
|
|
839
|
+
max_tokens=max_tokens,
|
|
840
|
+
timeout=timeout,
|
|
841
|
+
intro=intro,
|
|
842
|
+
filepath=filepath,
|
|
843
|
+
update_file=update_file,
|
|
844
|
+
proxies=proxies,
|
|
845
|
+
history_offset=history_offset,
|
|
846
|
+
act=awesome_prompt,
|
|
847
|
+
model=getOr(model, "qwen2:0.5b")
|
|
848
|
+
)
|
|
835
849
|
else:
|
|
836
850
|
raise NotImplementedError(
|
|
837
851
|
f"The provider `{provider}` is not yet implemented."
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: webscout
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2
|
|
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
|
|
@@ -1463,6 +1463,15 @@ print(response)
|
|
|
1463
1463
|
|
|
1464
1464
|
### 21. GeminiFlash and geminipro
|
|
1465
1465
|
**Usage similar to other providers**
|
|
1466
|
+
|
|
1467
|
+
### 22. `Ollama` - chat will AI models locally
|
|
1468
|
+
```python
|
|
1469
|
+
from webscout import OLLAMA
|
|
1470
|
+
ollama_provider = OLLAMA(model="qwen2:0.5b")
|
|
1471
|
+
response = ollama_provider.chat("What is the meaning of life?")
|
|
1472
|
+
print(response)
|
|
1473
|
+
```
|
|
1474
|
+
|
|
1466
1475
|
### `LLM`
|
|
1467
1476
|
```python
|
|
1468
1477
|
from webscout.LLM import LLM
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
webscout/AIauto.py,sha256=DycblRfFsQiLJVeP1sRQ0C-eNX7iO3a_y1wt8wChM8Y,20005
|
|
2
2
|
webscout/AIbase.py,sha256=GoHbN8r0gq2saYRZv6LA-Fr9Jlcjv80STKFXUq2ZeGU,4710
|
|
3
|
-
webscout/AIutel.py,sha256=
|
|
3
|
+
webscout/AIutel.py,sha256=xNqNnGO9st2aR2CdT4AePXt5yYFG4xgI2nKMo1UcQQ4,33980
|
|
4
4
|
webscout/DWEBS.py,sha256=QLuT1IKu0lnwdl7W6c-ctBAO7Jj0Zk3PYm6-13BC7rU,25740
|
|
5
5
|
webscout/LLM.py,sha256=LbGCZdJf8A5dwfoGS4tyy39tAh5BDdhMZP0ScKaaQfU,4184
|
|
6
6
|
webscout/YTdownloader.py,sha256=uWpUWnw9pxeEGw9KJ_3XDyQ5gd38gH1dJpr-HJo4vzU,39144
|
|
7
|
-
webscout/__init__.py,sha256=
|
|
7
|
+
webscout/__init__.py,sha256=bNfobn_GZVhf8CZVos1dX19xbON5tjsoTGFCeEwetnk,2211
|
|
8
8
|
webscout/__main__.py,sha256=ZtTRgsRjUi2JOvYFLF1ZCh55Sdoz94I-BS-TlJC7WDU,126
|
|
9
9
|
webscout/async_providers.py,sha256=holBv5SxanxVXc_92CBBaXHlB2IakB_fHnhyZaFjYF8,684
|
|
10
10
|
webscout/cli.py,sha256=EDxqTmcIshvhg9P0n2ZPaApj2-MEFY3uawS92zbBV_s,14705
|
|
@@ -14,9 +14,9 @@ webscout/models.py,sha256=5iQIdtedT18YuTZ3npoG7kLMwcrKwhQ7928dl_7qZW0,692
|
|
|
14
14
|
webscout/tempid.py,sha256=5oc3UbXhPGKxrMRTfRABT-V-dNzH_hOKWtLYM6iCWd4,5896
|
|
15
15
|
webscout/transcriber.py,sha256=EddvTSq7dPJ42V3pQVnGuEiYQ7WjJ9uyeR9kMSxN7uY,20622
|
|
16
16
|
webscout/utils.py,sha256=CxeXvp0rWIulUrEaPZMaNfg_tSuQLRSV8uuHA2chyKE,2603
|
|
17
|
-
webscout/version.py,sha256=
|
|
17
|
+
webscout/version.py,sha256=lOw9hPXXgs_Wlw6Px5eyN37MYJbDYnOuwXrI1TPkDXc,44
|
|
18
18
|
webscout/voice.py,sha256=0QjXTHAQmCK07IDZXRc7JXem47cnPJH7u3X0sVP1-UQ,967
|
|
19
|
-
webscout/webai.py,sha256=
|
|
19
|
+
webscout/webai.py,sha256=LPn9XKvc5SLxJ68slMsPUXxzkzfa4b0kzsiJyWs-yq0,88897
|
|
20
20
|
webscout/webscout_search.py,sha256=lFAot1-Qil_YfXieeLakDVDEX8Ckcima4ueXdOYwiMc,42804
|
|
21
21
|
webscout/webscout_search_async.py,sha256=dooKGwLm0cwTml55Vy6NHPPY-nymEqX2h8laX94Zg5A,14537
|
|
22
22
|
webscout/websx_search.py,sha256=n-qVwiHozJEF-GFRPcAfh4k1d_tscTmDe1dNL-1ngcU,12094
|
|
@@ -26,7 +26,7 @@ webscout/Extra/gguf.py,sha256=5zTNE5HxM_VQ5ONoocL8GG5fRXrgyLdEEjNzndG0oUw,7811
|
|
|
26
26
|
webscout/Extra/weather.py,sha256=ocGwJYp5B9FwVWvIZ9wtoJTQsPFt64Vt8TitxJcdvAU,1687
|
|
27
27
|
webscout/Extra/weather_ascii.py,sha256=sy6EEh2kN1CO1hKda8chD-mVCxH4p0NHyP7Uxr0-rgo,630
|
|
28
28
|
webscout/Local/__init__.py,sha256=RN6klpbabPGNX2YzPm_hdeUcQvieUwvJt22uAO2RKSM,238
|
|
29
|
-
webscout/Local/_version.py,sha256=
|
|
29
|
+
webscout/Local/_version.py,sha256=ZbCLJLHnrzQdwnxadyRSHEGRQY77fO8BRjE8sVITcnw,83
|
|
30
30
|
webscout/Local/formats.py,sha256=BiZZSoN3e8S6-S-ykBL9ogSUs0vK11GaZ3ghc9U8GRk,18994
|
|
31
31
|
webscout/Local/model.py,sha256=T_bzNNrxEyOyLyhp6fKwiuVBBkXC2a37LzJVCxFIxOU,30710
|
|
32
32
|
webscout/Local/rawdog.py,sha256=ojY_O8Vb1KvR34OwWdfLgllgaAK_7HMf64ElMATvCXs,36689
|
|
@@ -47,6 +47,7 @@ webscout/Provider/Groq.py,sha256=QfgP3hKUcqq5vUA4Pzuu3HAgpJkKwLWNjjsnxtkCYd8,210
|
|
|
47
47
|
webscout/Provider/Koboldai.py,sha256=KwWx2yPlvT9BGx37iNvSbgzWkJ9I8kSOmeg7sL1hb0M,15806
|
|
48
48
|
webscout/Provider/Leo.py,sha256=wbuDR-vFjLptfRC6yDlk74tINqNvCOzpISsK92lIgGg,19987
|
|
49
49
|
webscout/Provider/Llama2.py,sha256=gVMotyiBaDSqliwuDtFefHoOBn9V5m5Ze_YVtV0trt8,17525
|
|
50
|
+
webscout/Provider/OLLAMA.py,sha256=G8sz_P7OZINFI1qGnpDhNPWU789Sv2cpDnShOA5Nbmw,7075
|
|
50
51
|
webscout/Provider/OpenGPT.py,sha256=ZymwLgNJSPlGZHW3msMlnRR7NxmALqJw9yuToqrRrhw,35515
|
|
51
52
|
webscout/Provider/Openai.py,sha256=SjfVOwY94unVnXhvN0Fkome-q2-wi4mPJk_vCGq5Fjc,20617
|
|
52
53
|
webscout/Provider/Perplexity.py,sha256=CPdKqkdlVejXDcf1uycNO4LPCVNUADSCetvyJEGepSw,8826
|
|
@@ -58,10 +59,10 @@ webscout/Provider/VTLchat.py,sha256=_sErGr-wOi16ZAfiGOo0bPsAEMkjzzwreEsIqjIZMIU,
|
|
|
58
59
|
webscout/Provider/Xjai.py,sha256=BIlk2ouz9Kh_0Gg9hPvTqhI7XtcmWdg5vHSX_4uGrIs,9039
|
|
59
60
|
webscout/Provider/Yepchat.py,sha256=2Eit-A7w1ph1GQKNQuur_yaDzI64r0yBGxCIjDefJxQ,19875
|
|
60
61
|
webscout/Provider/Youchat.py,sha256=fhMpt94pIPE_XDbC4z9xyfgA7NbkNE2wlRFJabsjv90,8069
|
|
61
|
-
webscout/Provider/__init__.py,sha256=
|
|
62
|
-
webscout-4.
|
|
63
|
-
webscout-4.
|
|
64
|
-
webscout-4.
|
|
65
|
-
webscout-4.
|
|
66
|
-
webscout-4.
|
|
67
|
-
webscout-4.
|
|
62
|
+
webscout/Provider/__init__.py,sha256=ETLFpBrQsE5yCrrHXSnQtQfB9SF65oBDrylCi0bq5GY,1963
|
|
63
|
+
webscout-4.2.dist-info/LICENSE.md,sha256=9P0imsudI7MEvZe2pOcg8rKBn6E5FGHQ-riYozZI-Bk,2942
|
|
64
|
+
webscout-4.2.dist-info/METADATA,sha256=op8wqdzv0qTjR3MTqHSKYVOT-8QYOeDtffvjDz0dw_s,57080
|
|
65
|
+
webscout-4.2.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
|
66
|
+
webscout-4.2.dist-info/entry_points.txt,sha256=Hh4YIIjvkqB9SVxZ2ri4DZUkgEu_WF_5_r_nZDIvfG8,73
|
|
67
|
+
webscout-4.2.dist-info/top_level.txt,sha256=nYIw7OKBQDr_Z33IzZUKidRD3zQEo8jOJYkMVMeN334,9
|
|
68
|
+
webscout-4.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|