webscout 4.1__tar.gz → 4.2__tar.gz

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.

Files changed (73) hide show
  1. {webscout-4.1/webscout.egg-info → webscout-4.2}/PKG-INFO +10 -1
  2. {webscout-4.1 → webscout-4.2}/README.md +9 -0
  3. {webscout-4.1 → webscout-4.2}/setup.py +1 -1
  4. {webscout-4.1 → webscout-4.2}/webscout/AIutel.py +2 -1
  5. {webscout-4.1 → webscout-4.2}/webscout/Local/_version.py +1 -1
  6. webscout-4.2/webscout/Provider/OLLAMA.py +187 -0
  7. {webscout-4.1 → webscout-4.2}/webscout/Provider/__init__.py +2 -1
  8. {webscout-4.1 → webscout-4.2}/webscout/__init__.py +1 -0
  9. {webscout-4.1 → webscout-4.2}/webscout/version.py +1 -1
  10. {webscout-4.1 → webscout-4.2}/webscout/webai.py +14 -0
  11. {webscout-4.1 → webscout-4.2/webscout.egg-info}/PKG-INFO +10 -1
  12. {webscout-4.1 → webscout-4.2}/webscout.egg-info/SOURCES.txt +1 -0
  13. {webscout-4.1 → webscout-4.2}/LICENSE.md +0 -0
  14. {webscout-4.1 → webscout-4.2}/setup.cfg +0 -0
  15. {webscout-4.1 → webscout-4.2}/webscout/AIauto.py +0 -0
  16. {webscout-4.1 → webscout-4.2}/webscout/AIbase.py +0 -0
  17. {webscout-4.1 → webscout-4.2}/webscout/DWEBS.py +0 -0
  18. {webscout-4.1 → webscout-4.2}/webscout/Extra/__init__.py +0 -0
  19. {webscout-4.1 → webscout-4.2}/webscout/Extra/autollama.py +0 -0
  20. {webscout-4.1 → webscout-4.2}/webscout/Extra/gguf.py +0 -0
  21. {webscout-4.1 → webscout-4.2}/webscout/Extra/weather.py +0 -0
  22. {webscout-4.1 → webscout-4.2}/webscout/Extra/weather_ascii.py +0 -0
  23. {webscout-4.1 → webscout-4.2}/webscout/LLM.py +0 -0
  24. {webscout-4.1 → webscout-4.2}/webscout/Local/__init__.py +0 -0
  25. {webscout-4.1 → webscout-4.2}/webscout/Local/formats.py +0 -0
  26. {webscout-4.1 → webscout-4.2}/webscout/Local/model.py +0 -0
  27. {webscout-4.1 → webscout-4.2}/webscout/Local/rawdog.py +0 -0
  28. {webscout-4.1 → webscout-4.2}/webscout/Local/samplers.py +0 -0
  29. {webscout-4.1 → webscout-4.2}/webscout/Local/thread.py +0 -0
  30. {webscout-4.1 → webscout-4.2}/webscout/Local/utils.py +0 -0
  31. {webscout-4.1 → webscout-4.2}/webscout/Provider/BasedGPT.py +0 -0
  32. {webscout-4.1 → webscout-4.2}/webscout/Provider/Berlin4h.py +0 -0
  33. {webscout-4.1 → webscout-4.2}/webscout/Provider/Blackboxai.py +0 -0
  34. {webscout-4.1 → webscout-4.2}/webscout/Provider/ChatGPTUK.py +0 -0
  35. {webscout-4.1 → webscout-4.2}/webscout/Provider/Cohere.py +0 -0
  36. {webscout-4.1 → webscout-4.2}/webscout/Provider/Deepinfra.py +0 -0
  37. {webscout-4.1 → webscout-4.2}/webscout/Provider/Deepseek.py +0 -0
  38. {webscout-4.1 → webscout-4.2}/webscout/Provider/Gemini.py +0 -0
  39. {webscout-4.1 → webscout-4.2}/webscout/Provider/Geminiflash.py +0 -0
  40. {webscout-4.1 → webscout-4.2}/webscout/Provider/Geminipro.py +0 -0
  41. {webscout-4.1 → webscout-4.2}/webscout/Provider/Groq.py +0 -0
  42. {webscout-4.1 → webscout-4.2}/webscout/Provider/Koboldai.py +0 -0
  43. {webscout-4.1 → webscout-4.2}/webscout/Provider/Leo.py +0 -0
  44. {webscout-4.1 → webscout-4.2}/webscout/Provider/Llama2.py +0 -0
  45. {webscout-4.1 → webscout-4.2}/webscout/Provider/OpenGPT.py +0 -0
  46. {webscout-4.1 → webscout-4.2}/webscout/Provider/Openai.py +0 -0
  47. {webscout-4.1 → webscout-4.2}/webscout/Provider/Perplexity.py +0 -0
  48. {webscout-4.1 → webscout-4.2}/webscout/Provider/Phind.py +0 -0
  49. {webscout-4.1 → webscout-4.2}/webscout/Provider/Poe.py +0 -0
  50. {webscout-4.1 → webscout-4.2}/webscout/Provider/Reka.py +0 -0
  51. {webscout-4.1 → webscout-4.2}/webscout/Provider/ThinkAnyAI.py +0 -0
  52. {webscout-4.1 → webscout-4.2}/webscout/Provider/VTLchat.py +0 -0
  53. {webscout-4.1 → webscout-4.2}/webscout/Provider/Xjai.py +0 -0
  54. {webscout-4.1 → webscout-4.2}/webscout/Provider/Yepchat.py +0 -0
  55. {webscout-4.1 → webscout-4.2}/webscout/Provider/Youchat.py +0 -0
  56. {webscout-4.1 → webscout-4.2}/webscout/YTdownloader.py +0 -0
  57. {webscout-4.1 → webscout-4.2}/webscout/__main__.py +0 -0
  58. {webscout-4.1 → webscout-4.2}/webscout/async_providers.py +0 -0
  59. {webscout-4.1 → webscout-4.2}/webscout/cli.py +0 -0
  60. {webscout-4.1 → webscout-4.2}/webscout/exceptions.py +0 -0
  61. {webscout-4.1 → webscout-4.2}/webscout/g4f.py +0 -0
  62. {webscout-4.1 → webscout-4.2}/webscout/models.py +0 -0
  63. {webscout-4.1 → webscout-4.2}/webscout/tempid.py +0 -0
  64. {webscout-4.1 → webscout-4.2}/webscout/transcriber.py +0 -0
  65. {webscout-4.1 → webscout-4.2}/webscout/utils.py +0 -0
  66. {webscout-4.1 → webscout-4.2}/webscout/voice.py +0 -0
  67. {webscout-4.1 → webscout-4.2}/webscout/webscout_search.py +0 -0
  68. {webscout-4.1 → webscout-4.2}/webscout/webscout_search_async.py +0 -0
  69. {webscout-4.1 → webscout-4.2}/webscout/websx_search.py +0 -0
  70. {webscout-4.1 → webscout-4.2}/webscout.egg-info/dependency_links.txt +0 -0
  71. {webscout-4.1 → webscout-4.2}/webscout.egg-info/entry_points.txt +0 -0
  72. {webscout-4.1 → webscout-4.2}/webscout.egg-info/requires.txt +0 -0
  73. {webscout-4.1 → webscout-4.2}/webscout.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 4.1
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
@@ -1397,6 +1397,15 @@ print(response)
1397
1397
 
1398
1398
  ### 21. GeminiFlash and geminipro
1399
1399
  **Usage similar to other providers**
1400
+
1401
+ ### 22. `Ollama` - chat will AI models locally
1402
+ ```python
1403
+ from webscout import OLLAMA
1404
+ ollama_provider = OLLAMA(model="qwen2:0.5b")
1405
+ response = ollama_provider.chat("What is the meaning of life?")
1406
+ print(response)
1407
+ ```
1408
+
1400
1409
  ### `LLM`
1401
1410
  ```python
1402
1411
  from webscout.LLM import LLM
@@ -5,7 +5,7 @@ with open("README.md", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="webscout",
8
- version="4.1",
8
+ version="4.2",
9
9
  description="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",
10
10
  long_description=README,
11
11
  long_description_content_type="text/markdown",
@@ -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
@@ -1,3 +1,3 @@
1
1
  from llama_cpp import __version__ as __llama_cpp_version__
2
2
 
3
- __version__ = '4.1'
3
+ __version__ = '4.2'
@@ -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)
@@ -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
  ]
@@ -44,6 +44,7 @@ webai = [
44
44
  "vtlchat",
45
45
  "geminiflash",
46
46
  "geminipro",
47
+ "ollama"
47
48
  ]
48
49
 
49
50
  gpt4free_providers = [
@@ -1,2 +1,2 @@
1
- __version__ = "4.1"
1
+ __version__ = "4.2"
2
2
  __prog__ = "webscout"
@@ -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.1
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
@@ -56,6 +56,7 @@ webscout/Provider/Groq.py
56
56
  webscout/Provider/Koboldai.py
57
57
  webscout/Provider/Leo.py
58
58
  webscout/Provider/Llama2.py
59
+ webscout/Provider/OLLAMA.py
59
60
  webscout/Provider/OpenGPT.py
60
61
  webscout/Provider/Openai.py
61
62
  webscout/Provider/Perplexity.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes