webscout 2.1__tar.gz → 2.2b0__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 (64) hide show
  1. {webscout-2.1 → webscout-2.2b0}/PKG-INFO +48 -13
  2. {webscout-2.1 → webscout-2.2b0}/README.md +42 -10
  3. webscout-2.2b0/setup.py +83 -0
  4. {webscout-2.1 → webscout-2.2b0}/webscout/AIauto.py +54 -13
  5. {webscout-2.1 → webscout-2.2b0}/webscout/AIutel.py +2 -1
  6. webscout-2.2b0/webscout/Provider/Berlin4h.py +211 -0
  7. webscout-2.2b0/webscout/Provider/ChatGPTUK.py +214 -0
  8. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/__init__.py +4 -2
  9. {webscout-2.1 → webscout-2.2b0}/webscout/__init__.py +27 -14
  10. {webscout-2.1 → webscout-2.2b0}/webscout/async_providers.py +9 -9
  11. {webscout-2.1 → webscout-2.2b0}/webscout/g4f.py +2 -2
  12. {webscout-2.1 → webscout-2.2b0}/webscout/webai.py +28 -14
  13. {webscout-2.1 → webscout-2.2b0}/webscout.egg-info/PKG-INFO +48 -13
  14. {webscout-2.1 → webscout-2.2b0}/webscout.egg-info/SOURCES.txt +2 -0
  15. webscout-2.2b0/webscout.egg-info/entry_points.txt +3 -0
  16. {webscout-2.1 → webscout-2.2b0}/webscout.egg-info/requires.txt +5 -1
  17. webscout-2.1/setup.py +0 -82
  18. webscout-2.1/webscout.egg-info/entry_points.txt +0 -6
  19. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/__init__.py +0 -0
  20. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/documents/__init__.py +0 -0
  21. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/documents/query_results_extractor.py +0 -0
  22. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/documents/webpage_content_extractor.py +0 -0
  23. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/networks/__init__.py +0 -0
  24. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/networks/filepath_converter.py +0 -0
  25. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/networks/google_searcher.py +0 -0
  26. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/networks/network_configs.py +0 -0
  27. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/networks/webpage_fetcher.py +0 -0
  28. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/utilsdw/__init__.py +0 -0
  29. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/utilsdw/enver.py +0 -0
  30. {webscout-2.1 → webscout-2.2b0}/DeepWEBS/utilsdw/logger.py +0 -0
  31. {webscout-2.1 → webscout-2.2b0}/LICENSE.md +0 -0
  32. {webscout-2.1 → webscout-2.2b0}/setup.cfg +0 -0
  33. {webscout-2.1 → webscout-2.2b0}/webscout/AIbase.py +0 -0
  34. {webscout-2.1 → webscout-2.2b0}/webscout/DWEBS.py +0 -0
  35. {webscout-2.1 → webscout-2.2b0}/webscout/LLM.py +0 -0
  36. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Blackboxai.py +0 -0
  37. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Cohere.py +0 -0
  38. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Gemini.py +0 -0
  39. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Groq.py +0 -0
  40. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Koboldai.py +0 -0
  41. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Leo.py +0 -0
  42. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Llama2.py +0 -0
  43. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/OpenGPT.py +0 -0
  44. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Openai.py +0 -0
  45. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Perplexity.py +0 -0
  46. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Phind.py +0 -0
  47. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Reka.py +0 -0
  48. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/ThinkAnyAI.py +0 -0
  49. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Xjai.py +0 -0
  50. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Yepchat.py +0 -0
  51. {webscout-2.1 → webscout-2.2b0}/webscout/Provider/Youchat.py +0 -0
  52. {webscout-2.1 → webscout-2.2b0}/webscout/__main__.py +0 -0
  53. {webscout-2.1 → webscout-2.2b0}/webscout/cli.py +0 -0
  54. {webscout-2.1 → webscout-2.2b0}/webscout/exceptions.py +0 -0
  55. {webscout-2.1 → webscout-2.2b0}/webscout/models.py +0 -0
  56. {webscout-2.1 → webscout-2.2b0}/webscout/tempid.py +0 -0
  57. {webscout-2.1 → webscout-2.2b0}/webscout/transcriber.py +0 -0
  58. {webscout-2.1 → webscout-2.2b0}/webscout/utils.py +0 -0
  59. {webscout-2.1 → webscout-2.2b0}/webscout/version.py +0 -0
  60. {webscout-2.1 → webscout-2.2b0}/webscout/voice.py +0 -0
  61. {webscout-2.1 → webscout-2.2b0}/webscout/webscout_search.py +0 -0
  62. {webscout-2.1 → webscout-2.2b0}/webscout/webscout_search_async.py +0 -0
  63. {webscout-2.1 → webscout-2.2b0}/webscout.egg-info/dependency_links.txt +0 -0
  64. {webscout-2.1 → webscout-2.2b0}/webscout.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 2.1
4
- Summary: Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI models, can transcribe yt videos, temporary email and phone number generation, have TTS support and webai(terminal gpt and open interpeter)
3
+ Version: 2.2b0
4
+ Summary: Search for anything using Google, DuckDuckGo, phind.com. Also contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, and webai (terminal gpt and open interpreter).
5
5
  Author: OEvortex
6
6
  Author-email: helpingai5@gmail.com
7
7
  License: HelpingAI Simplified Universal License
@@ -36,7 +36,6 @@ Requires-Dist: halo>=0.0.31
36
36
  Requires-Dist: g4f>=0.2.2.3
37
37
  Requires-Dist: rich
38
38
  Requires-Dist: python-dotenv
39
- Requires-Dist: Helpingai-T2
40
39
  Requires-Dist: beautifulsoup4
41
40
  Requires-Dist: markdownify
42
41
  Requires-Dist: pydantic
@@ -55,6 +54,10 @@ Requires-Dist: playsound
55
54
  Provides-Extra: dev
56
55
  Requires-Dist: ruff>=0.1.6; extra == "dev"
57
56
  Requires-Dist: pytest>=7.4.2; extra == "dev"
57
+ Provides-Extra: local
58
+ Requires-Dist: llama-cpp-python; extra == "local"
59
+ Requires-Dist: colorama; extra == "local"
60
+ Requires-Dist: numpy; extra == "local"
58
61
 
59
62
  <div align="center">
60
63
  <!-- Replace `#` with your actual links -->
@@ -120,15 +123,16 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
120
123
  - [2. `YepChat` - Chat with mistral 8x7b powered by yepchat](#2-yepchat---chat-with-mistral-8x7b-powered-by-yepchat)
121
124
  - [3. `You.com` - search/chat with you.com](#3-youcom---searchchat-with-youcom)
122
125
  - [4. `Gemini` - search with google gemini](#4-gemini---search-with-google-gemini)
123
- - [5. `Prodia` - make image using prodia](#5-prodia---make-image-using-prodia)
126
+ - [5. `Berlin4h` - chat with Berlin4h](#5-berlin4h---chat-with-berlin4h)
124
127
  - [6. `BlackBox` - Search/chat With BlackBox](#6-blackbox---searchchat-with-blackbox)
125
128
  - [7. `PERPLEXITY` - Search With PERPLEXITY](#7-perplexity---search-with-perplexity)
126
129
  - [8. `OpenGPT` - chat With OPENGPT](#8-opengpt---chat-with-opengpt)
127
- - [9. `KOBOLDIA` -](#9-koboldia--)
130
+ - [9. `KOBOLDAI` -](#9-koboldai--)
128
131
  - [10. `Reka` - chat with reka](#10-reka---chat-with-reka)
129
132
  - [11. `Cohere` - chat with cohere](#11-cohere---chat-with-cohere)
130
133
  - [12. `Xjai` - chat with free gpt 3.5](#12-xjai---chat-with-free-gpt-35)
131
134
  - [13. `ThinkAny` - AI search engine](#13-thinkany---ai-search-engine)
135
+ - [14. `chatgptuk` - Chat with gemini-pro](#14-chatgptuk---chat-with-gemini-pro)
132
136
  - [`LLM`](#llm)
133
137
  - [`LLM` with internet](#llm-with-internet)
134
138
  - [LLM with deepwebs](#llm-with-deepwebs)
@@ -1009,15 +1013,26 @@ gemini = GEMINI(cookie_file=COOKIE_FILE, proxy=PROXIES)
1009
1013
  response = gemini.chat("What is the meaning of life?")
1010
1014
  print(response)
1011
1015
  ```
1012
- ### 5. `Prodia` - make image using prodia
1016
+ ### 5. `Berlin4h` - chat with Berlin4h
1013
1017
  ```python
1014
- from webscout import Prodia
1015
-
1016
- # Define a prompt for the image generation
1017
- prompt = "A beautiful sunset over the ocean"
1018
+ from webscout import Berlin4h
1019
+ # Create an instance of the PERPLEXITY class
1020
+ ai = Berlin4h(
1021
+ is_conversation=True,
1022
+ max_tokens=800,
1023
+ timeout=30,
1024
+ intro=None,
1025
+ filepath=None,
1026
+ update_file=True,
1027
+ proxies={},
1028
+ history_offset=10250,
1029
+ act=None,
1030
+ )
1018
1031
 
1019
- # Use the prodia_cli method to generate an image based on the prompt
1020
- Prodia.prodia_cli(prompt)
1032
+ # Example usage:
1033
+ prompt = "Explain the concept of recursion in simple terms."
1034
+ response = ai.chat(prompt)
1035
+ print(response)
1021
1036
  ```
1022
1037
  ### 6. `BlackBox` - Search/chat With BlackBox
1023
1038
  ```python
@@ -1073,7 +1088,7 @@ while True:
1073
1088
  response_str = opengpt.chat(prompt)
1074
1089
  print(response_str)
1075
1090
  ```
1076
- ### 9. `KOBOLDIA` -
1091
+ ### 9. `KOBOLDAI` -
1077
1092
  ```python
1078
1093
  from webscout import KOBOLDAI
1079
1094
 
@@ -1162,7 +1177,27 @@ response = ai.ask(prompt)
1162
1177
  message = ai.get_message(response)
1163
1178
  print(message)
1164
1179
  ```
1180
+ ### 14. `chatgptuk` - Chat with gemini-pro
1181
+ ```python
1182
+ from webscout import ChatGPTUK
1183
+ # Create an instance of the PERPLEXITY class
1184
+ ai = ChatGPTUK(
1185
+ is_conversation=True,
1186
+ max_tokens=800,
1187
+ timeout=30,
1188
+ intro=None,
1189
+ filepath=None,
1190
+ update_file=True,
1191
+ proxies={},
1192
+ history_offset=10250,
1193
+ act=None,
1194
+ )
1165
1195
 
1196
+ # Example usage:
1197
+ prompt = "Explain the concept of recursion in simple terms."
1198
+ response = ai.chat(prompt)
1199
+ print(response)
1200
+ ```
1166
1201
  ### `LLM`
1167
1202
  ```python
1168
1203
  from webscout.LLM import LLM
@@ -62,15 +62,16 @@ Search for anything using the Google, DuckDuckGo, phind.com. Also containes AI m
62
62
  - [2. `YepChat` - Chat with mistral 8x7b powered by yepchat](#2-yepchat---chat-with-mistral-8x7b-powered-by-yepchat)
63
63
  - [3. `You.com` - search/chat with you.com](#3-youcom---searchchat-with-youcom)
64
64
  - [4. `Gemini` - search with google gemini](#4-gemini---search-with-google-gemini)
65
- - [5. `Prodia` - make image using prodia](#5-prodia---make-image-using-prodia)
65
+ - [5. `Berlin4h` - chat with Berlin4h](#5-berlin4h---chat-with-berlin4h)
66
66
  - [6. `BlackBox` - Search/chat With BlackBox](#6-blackbox---searchchat-with-blackbox)
67
67
  - [7. `PERPLEXITY` - Search With PERPLEXITY](#7-perplexity---search-with-perplexity)
68
68
  - [8. `OpenGPT` - chat With OPENGPT](#8-opengpt---chat-with-opengpt)
69
- - [9. `KOBOLDIA` -](#9-koboldia--)
69
+ - [9. `KOBOLDAI` -](#9-koboldai--)
70
70
  - [10. `Reka` - chat with reka](#10-reka---chat-with-reka)
71
71
  - [11. `Cohere` - chat with cohere](#11-cohere---chat-with-cohere)
72
72
  - [12. `Xjai` - chat with free gpt 3.5](#12-xjai---chat-with-free-gpt-35)
73
73
  - [13. `ThinkAny` - AI search engine](#13-thinkany---ai-search-engine)
74
+ - [14. `chatgptuk` - Chat with gemini-pro](#14-chatgptuk---chat-with-gemini-pro)
74
75
  - [`LLM`](#llm)
75
76
  - [`LLM` with internet](#llm-with-internet)
76
77
  - [LLM with deepwebs](#llm-with-deepwebs)
@@ -951,15 +952,26 @@ gemini = GEMINI(cookie_file=COOKIE_FILE, proxy=PROXIES)
951
952
  response = gemini.chat("What is the meaning of life?")
952
953
  print(response)
953
954
  ```
954
- ### 5. `Prodia` - make image using prodia
955
+ ### 5. `Berlin4h` - chat with Berlin4h
955
956
  ```python
956
- from webscout import Prodia
957
-
958
- # Define a prompt for the image generation
959
- prompt = "A beautiful sunset over the ocean"
957
+ from webscout import Berlin4h
958
+ # Create an instance of the PERPLEXITY class
959
+ ai = Berlin4h(
960
+ is_conversation=True,
961
+ max_tokens=800,
962
+ timeout=30,
963
+ intro=None,
964
+ filepath=None,
965
+ update_file=True,
966
+ proxies={},
967
+ history_offset=10250,
968
+ act=None,
969
+ )
960
970
 
961
- # Use the prodia_cli method to generate an image based on the prompt
962
- Prodia.prodia_cli(prompt)
971
+ # Example usage:
972
+ prompt = "Explain the concept of recursion in simple terms."
973
+ response = ai.chat(prompt)
974
+ print(response)
963
975
  ```
964
976
  ### 6. `BlackBox` - Search/chat With BlackBox
965
977
  ```python
@@ -1015,7 +1027,7 @@ while True:
1015
1027
  response_str = opengpt.chat(prompt)
1016
1028
  print(response_str)
1017
1029
  ```
1018
- ### 9. `KOBOLDIA` -
1030
+ ### 9. `KOBOLDAI` -
1019
1031
  ```python
1020
1032
  from webscout import KOBOLDAI
1021
1033
 
@@ -1104,7 +1116,27 @@ response = ai.ask(prompt)
1104
1116
  message = ai.get_message(response)
1105
1117
  print(message)
1106
1118
  ```
1119
+ ### 14. `chatgptuk` - Chat with gemini-pro
1120
+ ```python
1121
+ from webscout import ChatGPTUK
1122
+ # Create an instance of the PERPLEXITY class
1123
+ ai = ChatGPTUK(
1124
+ is_conversation=True,
1125
+ max_tokens=800,
1126
+ timeout=30,
1127
+ intro=None,
1128
+ filepath=None,
1129
+ update_file=True,
1130
+ proxies={},
1131
+ history_offset=10250,
1132
+ act=None,
1133
+ )
1107
1134
 
1135
+ # Example usage:
1136
+ prompt = "Explain the concept of recursion in simple terms."
1137
+ response = ai.chat(prompt)
1138
+ print(response)
1139
+ ```
1108
1140
  ### `LLM`
1109
1141
  ```python
1110
1142
  from webscout.LLM import LLM
@@ -0,0 +1,83 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", encoding="utf-8") as f:
4
+ README = f.read()
5
+
6
+ setup(
7
+ name="webscout",
8
+ version="2.2-beta",
9
+ description="Search for anything using Google, DuckDuckGo, phind.com. Also contains AI models, can transcribe yt videos, temporary email and phone number generation, has TTS support, and webai (terminal gpt and open interpreter).",
10
+ long_description=README,
11
+ long_description_content_type="text/markdown",
12
+ author="OEvortex",
13
+ author_email="helpingai5@gmail.com",
14
+ packages=find_packages(),
15
+ classifiers=[
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Intended Audience :: Developers",
18
+ "License :: Other/Proprietary License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: Implementation :: CPython",
27
+ "Topic :: Internet :: WWW/HTTP :: Indexing/Search",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ],
30
+ install_requires=[
31
+ "docstring_inheritance",
32
+ "click",
33
+ "curl_cffi",
34
+ "lxml",
35
+ "nest-asyncio",
36
+ "selenium",
37
+ "tqdm",
38
+ "webdriver-manager",
39
+ "halo>=0.0.31",
40
+ "g4f>=0.2.2.3",
41
+ "rich",
42
+ "python-dotenv",
43
+ "beautifulsoup4",
44
+ "markdownify",
45
+ "pydantic",
46
+ "requests",
47
+ "sse_starlette",
48
+ "termcolor",
49
+ "tiktoken",
50
+ "tldextract",
51
+ "orjson",
52
+ "PyYAML",
53
+ "appdirs",
54
+ "GoogleBard1>=2.1.4",
55
+ "tls_client",
56
+ "clipman",
57
+ "playsound",
58
+ ],
59
+ entry_points={
60
+ "console_scripts": [
61
+ "WEBS = webscout.cli:cli",
62
+ "webscout = webscout.webai:main",
63
+ ],
64
+ },
65
+ extras_require={
66
+ "dev": [
67
+ "ruff>=0.1.6",
68
+ "pytest>=7.4.2",
69
+ ],
70
+ "local": [
71
+ 'llama-cpp-python',
72
+ 'colorama',
73
+ 'numpy',
74
+ ],
75
+ },
76
+ license="HelpingAI Simplified Universal License",
77
+ project_urls={
78
+ "Documentation": "https://github.com/OE-LUCIFER/Webscout/wiki",
79
+ "Source": "https://github.com/OE-LUCIFER/Webscout",
80
+ "Tracker": "https://github.com/OE-LUCIFER/Webscout/issues",
81
+ "YouTube": "https://youtube.com/@OEvortex",
82
+ },
83
+ )
@@ -1,13 +1,29 @@
1
- from webscout.AI import Provider, AsyncProvider
2
- from webscout.AI import OPENGPT, AsyncOPENGPT
3
- from webscout.AI import KOBOLDAI, AsyncKOBOLDAI
4
- from webscout.AI import PhindSearch, AsyncPhindSearch
5
- from webscout.AI import LLAMA2, AsyncLLAMA2
6
- from webscout.AI import BLACKBOXAI, AsyncBLACKBOXAI
7
- from webscout.AI import PERPLEXITY
8
- from webscout.AI import ThinkAnyAI
9
- from webscout.AI import YouChat
10
- from webscout.AI import YEPCHAT
1
+ from webscout.AIbase import Provider, AsyncProvider
2
+ from webscout import OPENGPT, AsyncOPENGPT
3
+ from webscout import KOBOLDAI, AsyncKOBOLDAI
4
+ from webscout import PhindSearch, AsyncPhindSearch
5
+ from webscout import LLAMA2, AsyncLLAMA2
6
+ from webscout import BLACKBOXAI, AsyncBLACKBOXAI
7
+ from webscout import PERPLEXITY
8
+ from webscout import ThinkAnyAI
9
+ from webscout import YouChat
10
+ from webscout import YEPCHAT
11
+ from webscout.AIbase import Provider, AsyncProvider
12
+ from webscout import KOBOLDAI, AsyncKOBOLDAI
13
+ from webscout import PhindSearch, AsyncPhindSearch
14
+ from webscout import LLAMA2, AsyncLLAMA2
15
+ from webscout import BLACKBOXAI, AsyncBLACKBOXAI
16
+ from webscout import PERPLEXITY
17
+ from webscout import ThinkAnyAI
18
+ from webscout import YouChat
19
+ from webscout import YEPCHAT, AsyncYEPCHAT
20
+ from webscout import LEO, AsyncLEO
21
+ from webscout import GROQ, AsyncGROQ
22
+ from webscout import OPENAI, AsyncOPENAI
23
+ from webscout import REKA
24
+ from webscout import Xjai
25
+ from webscout import Berlin4h
26
+ from webscout import ChatGPTUK
11
27
  from webscout.g4f import GPT4FREE, AsyncGPT4FREE
12
28
  from webscout.g4f import TestProviders
13
29
  from webscout.exceptions import AllProvidersFailure
@@ -20,7 +36,26 @@ import logging
20
36
 
21
37
 
22
38
  provider_map: dict[
23
- str, Union[OPENGPT, KOBOLDAI, PhindSearch, LLAMA2, BLACKBOXAI, PERPLEXITY, GPT4FREE, ThinkAnyAI, YEPCHAT, YouChat]
39
+ str, Union[ ThinkAnyAI,
40
+ Xjai,
41
+ LLAMA2,
42
+ AsyncLLAMA2,
43
+ LEO,
44
+ AsyncLEO,
45
+ KOBOLDAI,
46
+ AsyncKOBOLDAI,
47
+ OPENGPT,
48
+ AsyncOPENGPT,
49
+ PERPLEXITY,
50
+ BLACKBOXAI,
51
+ AsyncBLACKBOXAI,
52
+ PhindSearch,
53
+ AsyncPhindSearch,
54
+ YEPCHAT,
55
+ AsyncYEPCHAT,
56
+ YouChat,
57
+ Berlin4h,
58
+ ChatGPTUK,]
24
59
  ] = {
25
60
  "PhindSearch": PhindSearch,
26
61
  "perplexity": PERPLEXITY,
@@ -32,6 +67,12 @@ provider_map: dict[
32
67
  "thinkany": ThinkAnyAI,
33
68
  "yepchat": YEPCHAT,
34
69
  "you": YouChat,
70
+ "leo": LEO,
71
+ "xjai": Xjai,
72
+ "berlin4h": Berlin4h,
73
+ "chatgptuk": ChatGPTUK,
74
+ "gpt4free": GPT4FREE,
75
+
35
76
  }
36
77
 
37
78
 
@@ -113,13 +154,13 @@ class AUTO(Provider):
113
154
  "conversationally": conversationally,
114
155
  }
115
156
 
116
- # tgpt-based providers
157
+ # webscout-based providers
117
158
  for provider_name, provider_obj in provider_map.items():
118
159
  # continue
119
160
  if provider_name in self.exclude:
120
161
  continue
121
162
  try:
122
- self.provider_name = f"tgpt-{provider_name}"
163
+ self.provider_name = f"webscout-{provider_name}"
123
164
  self.provider = provider_obj(
124
165
  is_conversation=self.is_conversation,
125
166
  max_tokens=self.max_tokens,
@@ -42,8 +42,9 @@ webai = [
42
42
  "you",
43
43
  "xjai",
44
44
  "thinkany",
45
+ "berlin4h",
46
+ "chatgptuk",
45
47
  "auto",
46
-
47
48
  ]
48
49
 
49
50
  gpt4free_providers = [
@@ -0,0 +1,211 @@
1
+ import requests
2
+ import json
3
+ import uuid
4
+ from typing import Any, Dict, Optional
5
+ from ..AIutel import Optimizers
6
+ from ..AIutel import Conversation
7
+ from ..AIutel import AwesomePrompts, sanitize_stream
8
+ from ..AIbase import Provider, AsyncProvider
9
+ from webscout import exceptions
10
+
11
+ class Berlin4h(Provider):
12
+ """
13
+ A class to interact with the Berlin4h AI API.
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ api_token: str = "3bf369cd84339603f8a5361e964f9ebe",
19
+ api_endpoint: str = "https://ai.berlin4h.top/api/chat/completions",
20
+ model: str = "gpt-3.5-turbo",
21
+ temperature: float = 0.9,
22
+ presence_penalty: float = 0,
23
+ frequency_penalty: float = 0,
24
+ max_tokens: int = 4000,
25
+ is_conversation: bool = True,
26
+ timeout: int = 30,
27
+ intro: str = None,
28
+ filepath: str = None,
29
+ update_file: bool = True,
30
+ proxies: dict = {},
31
+ history_offset: int = 10250,
32
+ act: str = None,
33
+ ) -> None:
34
+ """
35
+ Initializes the Berlin4h API with given parameters.
36
+
37
+ Args:
38
+ api_token (str): The API token for authentication.
39
+ api_endpoint (str): The API endpoint to use for requests.
40
+ model (str): The AI model to use for text generation.
41
+ temperature (float): The temperature parameter for the model.
42
+ presence_penalty (float): The presence penalty parameter for the model.
43
+ frequency_penalty (float): The frequency penalty parameter for the model.
44
+ max_tokens (int): The maximum number of tokens to generate.
45
+ is_conversation (bool, optional): Flag for chatting conversationally. Defaults to True.
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.api_token = api_token
55
+ self.api_endpoint = api_endpoint
56
+ self.model = model
57
+ self.temperature = temperature
58
+ self.presence_penalty = presence_penalty
59
+ self.frequency_penalty = frequency_penalty
60
+ self.max_tokens = max_tokens
61
+ self.parent_message_id: Optional[str] = None
62
+ self.session = requests.Session()
63
+ self.is_conversation = is_conversation
64
+ self.max_tokens_to_sample = max_tokens
65
+ self.stream_chunk_size = 1
66
+ self.timeout = timeout
67
+ self.last_response = {}
68
+ self.headers = {"Content-Type": "application/json", "Token": self.api_token}
69
+ self.__available_optimizers = (
70
+ method
71
+ for method in dir(Optimizers)
72
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
73
+ )
74
+ self.session.headers.update(self.headers)
75
+ Conversation.intro = (
76
+ AwesomePrompts().get_act(
77
+ act, raise_not_found=True, default=None, case_insensitive=True
78
+ )
79
+ if act
80
+ else intro or Conversation.intro
81
+ )
82
+ self.conversation = Conversation(
83
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
84
+ )
85
+ self.conversation.history_offset = history_offset
86
+ self.session.proxies = proxies
87
+
88
+ def ask(
89
+ self,
90
+ prompt: str,
91
+ stream: bool = False,
92
+ raw: bool = False,
93
+ optimizer: str = None,
94
+ conversationally: bool = False,
95
+ ) -> Dict[str, Any]:
96
+ """
97
+ Sends a prompt to the Berlin4h AI API and returns the response.
98
+
99
+ Args:
100
+ prompt: The text prompt to generate text from.
101
+ stream (bool, optional): Whether to stream the response. Defaults to False.
102
+ raw (bool, optional): Whether to return the raw response. Defaults to False.
103
+ optimizer (str, optional): The name of the optimizer to use. Defaults to None.
104
+ conversationally (bool, optional): Whether to chat conversationally. Defaults to False.
105
+
106
+ Returns:
107
+ The response from the API.
108
+ """
109
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
110
+ if optimizer:
111
+ if optimizer in self.__available_optimizers:
112
+ conversation_prompt = getattr(Optimizers, optimizer)(
113
+ conversation_prompt if conversationally else prompt
114
+ )
115
+ else:
116
+ raise Exception(
117
+ f"Optimizer is not one of {self.__available_optimizers}"
118
+ )
119
+
120
+ payload: Dict[str, any] = {
121
+ "prompt": conversation_prompt,
122
+ "parentMessageId": self.parent_message_id or str(uuid.uuid4()),
123
+ "options": {
124
+ "model": self.model,
125
+ "temperature": self.temperature,
126
+ "presence_penalty": self.presence_penalty,
127
+ "frequency_penalty": self.frequency_penalty,
128
+ "max_tokens": self.max_tokens,
129
+ },
130
+ }
131
+
132
+ def for_stream():
133
+ response = self.session.post(
134
+ self.api_endpoint, json=payload, headers=self.headers, stream=True, timeout=self.timeout
135
+ )
136
+
137
+ if not response.ok:
138
+ raise exceptions.FailedToGenerateResponseError(
139
+ f"Failed to generate response - ({response.status_code}, {response.reason})"
140
+ )
141
+
142
+ streaming_response = ""
143
+ # Collect the entire line before processing
144
+ for line in response.iter_lines(decode_unicode=True):
145
+ if line:
146
+ try:
147
+ json_data = json.loads(line)
148
+ content = json_data['content']
149
+ if ">" in content: break
150
+ streaming_response += content
151
+ yield content if raw else dict(text=streaming_response) # Yield accumulated response
152
+ except:
153
+ continue
154
+ self.last_response.update(dict(text=streaming_response))
155
+ self.conversation.update_chat_history(
156
+ prompt, self.get_message(self.last_response)
157
+ )
158
+
159
+ def for_non_stream():
160
+ for _ in for_stream():
161
+ pass
162
+ return self.last_response
163
+
164
+ return for_stream() if stream else for_non_stream()
165
+
166
+ def chat(
167
+ self,
168
+ prompt: str,
169
+ stream: bool = False,
170
+ optimizer: str = None,
171
+ conversationally: bool = False,
172
+ ) -> str:
173
+ """Generate response `str`
174
+ Args:
175
+ prompt (str): Prompt to be send.
176
+ stream (bool, optional): Flag for streaming response. Defaults to False.
177
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
178
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
179
+ Returns:
180
+ str: Response generated
181
+ """
182
+
183
+ def for_stream():
184
+ for response in self.ask(
185
+ prompt, True, optimizer=optimizer, conversationally=conversationally
186
+ ):
187
+ yield self.get_message(response)
188
+
189
+ def for_non_stream():
190
+ return self.get_message(
191
+ self.ask(
192
+ prompt,
193
+ False,
194
+ optimizer=optimizer,
195
+ conversationally=conversationally,
196
+ )
197
+ )
198
+
199
+ return for_stream() if stream else for_non_stream()
200
+
201
+ def get_message(self, response: dict) -> str:
202
+ """Retrieves message only from response
203
+
204
+ Args:
205
+ response (dict): Response generated by `self.ask`
206
+
207
+ Returns:
208
+ str: Message extracted
209
+ """
210
+ assert isinstance(response, dict), "Response should be of dict data-type only"
211
+ return response["text"]