webscout 1.2.4__tar.gz → 1.2.6__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 (41) hide show
  1. {webscout-1.2.4 → webscout-1.2.6}/PKG-INFO +66 -32
  2. {webscout-1.2.4 → webscout-1.2.6}/README.md +64 -29
  3. {webscout-1.2.4 → webscout-1.2.6}/setup.py +2 -3
  4. {webscout-1.2.4 → webscout-1.2.6}/webscout/AI.py +204 -0
  5. {webscout-1.2.4 → webscout-1.2.6}/webscout/AIutel.py +1 -1
  6. {webscout-1.2.4 → webscout-1.2.6}/webscout/__init__.py +5 -2
  7. webscout-1.2.6/webscout/transcriber.py +498 -0
  8. webscout-1.2.6/webscout/version.py +2 -0
  9. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/PKG-INFO +66 -32
  10. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/SOURCES.txt +1 -1
  11. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/requires.txt +0 -1
  12. webscout-1.2.4/webscout/offlineAI.py +0 -206
  13. webscout-1.2.4/webscout/version.py +0 -2
  14. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/__init__.py +0 -0
  15. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/documents/__init__.py +0 -0
  16. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/documents/query_results_extractor.py +0 -0
  17. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/documents/webpage_content_extractor.py +0 -0
  18. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/networks/__init__.py +0 -0
  19. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/networks/filepath_converter.py +0 -0
  20. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/networks/google_searcher.py +0 -0
  21. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/networks/network_configs.py +0 -0
  22. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/networks/webpage_fetcher.py +0 -0
  23. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/utilsdw/__init__.py +0 -0
  24. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/utilsdw/enver.py +0 -0
  25. {webscout-1.2.4 → webscout-1.2.6}/DeepWEBS/utilsdw/logger.py +0 -0
  26. {webscout-1.2.4 → webscout-1.2.6}/LICENSE.md +0 -0
  27. {webscout-1.2.4 → webscout-1.2.6}/setup.cfg +0 -0
  28. {webscout-1.2.4 → webscout-1.2.6}/webscout/AIbase.py +0 -0
  29. {webscout-1.2.4 → webscout-1.2.6}/webscout/DWEBS.py +0 -0
  30. {webscout-1.2.4 → webscout-1.2.6}/webscout/HelpingAI.py +0 -0
  31. {webscout-1.2.4 → webscout-1.2.6}/webscout/LLM.py +0 -0
  32. {webscout-1.2.4 → webscout-1.2.6}/webscout/__main__.py +0 -0
  33. {webscout-1.2.4 → webscout-1.2.6}/webscout/cli.py +0 -0
  34. {webscout-1.2.4 → webscout-1.2.6}/webscout/exceptions.py +0 -0
  35. {webscout-1.2.4 → webscout-1.2.6}/webscout/models.py +0 -0
  36. {webscout-1.2.4 → webscout-1.2.6}/webscout/utils.py +0 -0
  37. {webscout-1.2.4 → webscout-1.2.6}/webscout/webscout_search.py +0 -0
  38. {webscout-1.2.4 → webscout-1.2.6}/webscout/webscout_search_async.py +0 -0
  39. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/dependency_links.txt +0 -0
  40. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/entry_points.txt +0 -0
  41. {webscout-1.2.4 → webscout-1.2.6}/webscout.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: webscout
3
- Version: 1.2.4
4
- Summary: Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models
3
+ Version: 1.2.6
4
+ Summary: Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models and now can transcribe yt videos
5
5
  Author: OEvortex
6
6
  Author-email: helpingai5@gmail.com
7
7
  License: HelpingAI Simplified Universal License
@@ -45,7 +45,6 @@ Requires-Dist: sse_starlette
45
45
  Requires-Dist: termcolor
46
46
  Requires-Dist: tiktoken
47
47
  Requires-Dist: tldextract
48
- Requires-Dist: gpt4all
49
48
  Requires-Dist: orjson
50
49
  Provides-Extra: dev
51
50
  Requires-Dist: ruff>=0.1.6; extra == "dev"
@@ -57,8 +56,7 @@ Requires-Dist: pytest>=7.4.2; extra == "dev"
57
56
  <a href="#"><img alt="Python version" src="https://img.shields.io/pypi/pyversions/webscout"/></a>
58
57
  <a href="https://pepy.tech/project/webscout"><img alt="Downloads" src="https://static.pepy.tech/badge/webscout"></a>
59
58
 
60
- Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models
61
- Also containes AI models that you can use
59
+ Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models and now can transcribe yt videos
62
60
 
63
61
 
64
62
  ## Table of Contents
@@ -69,6 +67,7 @@ Also containes AI models that you can use
69
67
  - [CLI version of webscout.AI](#cli-version-of-webscoutai)
70
68
  - [CLI to use LLM](#cli-to-use-llm)
71
69
  - [Regions](#regions)
70
+ - [Transcriber](#transcriber)
72
71
  - [DeepWEBS: Advanced Web Searches](#deepwebs-advanced-web-searches)
73
72
  - [Activating DeepWEBS](#activating-deepwebs)
74
73
  - [Point to remember before using `DeepWEBS`](#point-to-remember-before-using-deepwebs)
@@ -94,7 +93,7 @@ Also containes AI models that you can use
94
93
  - [6. `BlackBox` - Search/chat With BlackBox](#6-blackbox---searchchat-with-blackbox)
95
94
  - [7. `PERPLEXITY` - Search With PERPLEXITY](#7-perplexity---search-with-perplexity)
96
95
  - [8. `OpenGPT` - chat With OPENGPT](#8-opengpt---chat-with-opengpt)
97
- - [9. `GPT4ALL` - chat offline with Language models using gpt4all from webscout](#9-gpt4all---chat-offline-with-language-models-using-gpt4all-from-webscout)
96
+ - [9. `KOBOLDIA` -](#9-koboldia--)
98
97
  - [usage of special .LLM file from webscout (webscout.LLM)](#usage-of-special-llm-file-from-webscout-webscoutllm)
99
98
  - [`LLM`](#llm)
100
99
 
@@ -219,7 +218,55 @@ ___
219
218
  [Go To TOP](#TOP)
220
219
 
221
220
 
221
+ ## Transcriber
222
+ The transcriber function in webscout is a handy tool that transcribes YouTube videos. Here's an example code demonstrating its usage:
223
+ ```python
224
+ import sys
225
+ from webscout import transcriber
226
+
227
+ def extract_transcript(video_id):
228
+ """Extracts the transcript from a YouTube video."""
229
+ try:
230
+ transcript_list = transcriber.list_transcripts(video_id)
231
+ for transcript in transcript_list:
232
+ transcript_text_list = transcript.fetch()
233
+ lang = transcript.language
234
+ transcript_text = ""
235
+ if transcript.language_code == 'en':
236
+ for line in transcript_text_list:
237
+ transcript_text += " " + line["text"]
238
+ return transcript_text
239
+ elif transcript.is_translatable:
240
+ english_transcript_list = transcript.translate('en').fetch()
241
+ for line in english_transcript_list:
242
+ transcript_text += " " + line["text"]
243
+ return transcript_text
244
+ print("Transcript extraction failed. Please check the video URL.")
245
+ except Exception as e:
246
+ print(f"Error: {e}")
222
247
 
248
+ def main():
249
+ video_url = input("Enter the video link: ")
250
+
251
+ if video_url:
252
+ video_id = video_url.split("=")[1]
253
+ print("Video URL:", video_url)
254
+ submit = input("Press 'Enter' to get the transcript or type 'exit' to quit: ")
255
+ if submit == '':
256
+ print("Extracting Transcript...")
257
+ transcript = extract_transcript(video_id)
258
+ print('Transcript:')
259
+ print(transcript)
260
+ print("__________________________________________________________________________________")
261
+ elif submit.lower() == 'exit':
262
+ print("Exiting...")
263
+ sys.exit()
264
+ else:
265
+ print("Invalid input. Please try again.")
266
+
267
+ if __name__ == "__main__":
268
+ main()
269
+ ```
223
270
  ## DeepWEBS: Advanced Web Searches
224
271
 
225
272
  `DeepWEBS` is a standalone feature designed to perform advanced web searches with enhanced capabilities. It is particularly powerful in extracting relevant information directly from webpages and Search engine, focusing exclusively on text (web) searches. Unlike the `WEBS` , which provides a broader range of search functionalities, `DeepWEBS` is specifically tailored for in-depth web searches.
@@ -608,36 +655,23 @@ prompt = "tell me about india"
608
655
  response_str = opengpt.chat(prompt)
609
656
  print(response_str)
610
657
  ```
611
- ### 9. `GPT4ALL` - chat offline with Language models using gpt4all from webscout
658
+ ### 9. `KOBOLDIA` -
612
659
  ```python
613
- from webscout import GPT4ALL
660
+ from webscout.AI import KOBOLDAI
614
661
 
615
- # Initialize the GPT4ALL class with your model path and other optional parameters
616
- gpt4all_instance = GPT4ALL(
617
- model="path/to/your/model/file", # Replace with the actual path to your model file
618
- is_conversation=True,
619
- max_tokens=800,
620
- temperature=0.7,
621
- presence_penalty=0,
622
- frequency_penalty=1.18,
623
- top_p=0.4,
624
- intro="Hello, how can I assist you today?",
625
- filepath="path/to/conversation/history/file", # Optional, for conversation history
626
- update_file=True,
627
- history_offset=10250,
628
- act=None # Optional, for using an awesome prompt as intro
629
- )
662
+ # Instantiate the KOBOLDAI class with default parameters
663
+ koboldai = KOBOLDAI()
630
664
 
631
- # Generate a response from the AI model
632
- response = gpt4all_instance.chat(
633
- prompt="What is the weather like today?",
634
- stream=False, # Set to True if you want to stream the response
635
- optimizer=None, # Optional, specify an optimizer if needed
636
- conversationally=False # Set to True for conversationally generated responses
637
- )
665
+ # Define a prompt to send to the AI
666
+ prompt = "What is the capital of France?"
667
+
668
+ # Use the 'ask' method to get a response from the AI
669
+ response = koboldai.ask(prompt)
670
+
671
+ # Extract and print the message from the response
672
+ message = koboldai.get_message(response)
673
+ print(message)
638
674
 
639
- # Print the generated response
640
- print(response)
641
675
  ```
642
676
 
643
677
  ## usage of special .LLM file from webscout (webscout.LLM)
@@ -4,8 +4,7 @@
4
4
  <a href="#"><img alt="Python version" src="https://img.shields.io/pypi/pyversions/webscout"/></a>
5
5
  <a href="https://pepy.tech/project/webscout"><img alt="Downloads" src="https://static.pepy.tech/badge/webscout"></a>
6
6
 
7
- Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models
8
- Also containes AI models that you can use
7
+ Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models and now can transcribe yt videos
9
8
 
10
9
 
11
10
  ## Table of Contents
@@ -16,6 +15,7 @@ Also containes AI models that you can use
16
15
  - [CLI version of webscout.AI](#cli-version-of-webscoutai)
17
16
  - [CLI to use LLM](#cli-to-use-llm)
18
17
  - [Regions](#regions)
18
+ - [Transcriber](#transcriber)
19
19
  - [DeepWEBS: Advanced Web Searches](#deepwebs-advanced-web-searches)
20
20
  - [Activating DeepWEBS](#activating-deepwebs)
21
21
  - [Point to remember before using `DeepWEBS`](#point-to-remember-before-using-deepwebs)
@@ -41,7 +41,7 @@ Also containes AI models that you can use
41
41
  - [6. `BlackBox` - Search/chat With BlackBox](#6-blackbox---searchchat-with-blackbox)
42
42
  - [7. `PERPLEXITY` - Search With PERPLEXITY](#7-perplexity---search-with-perplexity)
43
43
  - [8. `OpenGPT` - chat With OPENGPT](#8-opengpt---chat-with-opengpt)
44
- - [9. `GPT4ALL` - chat offline with Language models using gpt4all from webscout](#9-gpt4all---chat-offline-with-language-models-using-gpt4all-from-webscout)
44
+ - [9. `KOBOLDIA` -](#9-koboldia--)
45
45
  - [usage of special .LLM file from webscout (webscout.LLM)](#usage-of-special-llm-file-from-webscout-webscoutllm)
46
46
  - [`LLM`](#llm)
47
47
 
@@ -166,7 +166,55 @@ ___
166
166
  [Go To TOP](#TOP)
167
167
 
168
168
 
169
+ ## Transcriber
170
+ The transcriber function in webscout is a handy tool that transcribes YouTube videos. Here's an example code demonstrating its usage:
171
+ ```python
172
+ import sys
173
+ from webscout import transcriber
174
+
175
+ def extract_transcript(video_id):
176
+ """Extracts the transcript from a YouTube video."""
177
+ try:
178
+ transcript_list = transcriber.list_transcripts(video_id)
179
+ for transcript in transcript_list:
180
+ transcript_text_list = transcript.fetch()
181
+ lang = transcript.language
182
+ transcript_text = ""
183
+ if transcript.language_code == 'en':
184
+ for line in transcript_text_list:
185
+ transcript_text += " " + line["text"]
186
+ return transcript_text
187
+ elif transcript.is_translatable:
188
+ english_transcript_list = transcript.translate('en').fetch()
189
+ for line in english_transcript_list:
190
+ transcript_text += " " + line["text"]
191
+ return transcript_text
192
+ print("Transcript extraction failed. Please check the video URL.")
193
+ except Exception as e:
194
+ print(f"Error: {e}")
169
195
 
196
+ def main():
197
+ video_url = input("Enter the video link: ")
198
+
199
+ if video_url:
200
+ video_id = video_url.split("=")[1]
201
+ print("Video URL:", video_url)
202
+ submit = input("Press 'Enter' to get the transcript or type 'exit' to quit: ")
203
+ if submit == '':
204
+ print("Extracting Transcript...")
205
+ transcript = extract_transcript(video_id)
206
+ print('Transcript:')
207
+ print(transcript)
208
+ print("__________________________________________________________________________________")
209
+ elif submit.lower() == 'exit':
210
+ print("Exiting...")
211
+ sys.exit()
212
+ else:
213
+ print("Invalid input. Please try again.")
214
+
215
+ if __name__ == "__main__":
216
+ main()
217
+ ```
170
218
  ## DeepWEBS: Advanced Web Searches
171
219
 
172
220
  `DeepWEBS` is a standalone feature designed to perform advanced web searches with enhanced capabilities. It is particularly powerful in extracting relevant information directly from webpages and Search engine, focusing exclusively on text (web) searches. Unlike the `WEBS` , which provides a broader range of search functionalities, `DeepWEBS` is specifically tailored for in-depth web searches.
@@ -555,36 +603,23 @@ prompt = "tell me about india"
555
603
  response_str = opengpt.chat(prompt)
556
604
  print(response_str)
557
605
  ```
558
- ### 9. `GPT4ALL` - chat offline with Language models using gpt4all from webscout
606
+ ### 9. `KOBOLDIA` -
559
607
  ```python
560
- from webscout import GPT4ALL
608
+ from webscout.AI import KOBOLDAI
561
609
 
562
- # Initialize the GPT4ALL class with your model path and other optional parameters
563
- gpt4all_instance = GPT4ALL(
564
- model="path/to/your/model/file", # Replace with the actual path to your model file
565
- is_conversation=True,
566
- max_tokens=800,
567
- temperature=0.7,
568
- presence_penalty=0,
569
- frequency_penalty=1.18,
570
- top_p=0.4,
571
- intro="Hello, how can I assist you today?",
572
- filepath="path/to/conversation/history/file", # Optional, for conversation history
573
- update_file=True,
574
- history_offset=10250,
575
- act=None # Optional, for using an awesome prompt as intro
576
- )
610
+ # Instantiate the KOBOLDAI class with default parameters
611
+ koboldai = KOBOLDAI()
577
612
 
578
- # Generate a response from the AI model
579
- response = gpt4all_instance.chat(
580
- prompt="What is the weather like today?",
581
- stream=False, # Set to True if you want to stream the response
582
- optimizer=None, # Optional, specify an optimizer if needed
583
- conversationally=False # Set to True for conversationally generated responses
584
- )
613
+ # Define a prompt to send to the AI
614
+ prompt = "What is the capital of France?"
615
+
616
+ # Use the 'ask' method to get a response from the AI
617
+ response = koboldai.ask(prompt)
618
+
619
+ # Extract and print the message from the response
620
+ message = koboldai.get_message(response)
621
+ print(message)
585
622
 
586
- # Print the generated response
587
- print(response)
588
623
  ```
589
624
 
590
625
  ## usage of special .LLM file from webscout (webscout.LLM)
@@ -9,8 +9,8 @@ with open("README.md", encoding="utf-8") as f:
9
9
 
10
10
  setup(
11
11
  name="webscout",
12
- version="1.2.4", # Use the version variable from the version.py file
13
- description="Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models",
12
+ version="1.2.6",
13
+ description="Search for words, documents, images, videos, news, maps and text translation using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models and now can transcribe yt videos",
14
14
  long_description=README,
15
15
  long_description_content_type="text/markdown",
16
16
  author="OEvortex",
@@ -53,7 +53,6 @@ setup(
53
53
  "termcolor",
54
54
  "tiktoken",
55
55
  "tldextract",
56
- "gpt4all",
57
56
  "orjson",
58
57
  ],
59
58
  entry_points={
@@ -21,9 +21,199 @@ import yaml
21
21
  from webscout.AIutel import Optimizers
22
22
  from webscout.AIutel import Conversation
23
23
  from webscout.AIutel import AwesomePrompts
24
+ from webscout.AIbase import Provider
24
25
  from Helpingai_T2 import Perplexity
25
26
  from typing import Any
26
27
  import logging
28
+ #------------------------------------------------------KOBOLDAI-----------------------------------------------------------
29
+ class KOBOLDAI(Provider):
30
+ def __init__(
31
+ self,
32
+ is_conversation: bool = True,
33
+ max_tokens: int = 600,
34
+ temperature: float = 1,
35
+ top_p: float = 1,
36
+ timeout: int = 30,
37
+ intro: str = None,
38
+ filepath: str = None,
39
+ update_file: bool = True,
40
+ proxies: dict = {},
41
+ history_offset: int = 10250,
42
+ act: str = None,
43
+ ):
44
+ """Instantiate TGPT
45
+
46
+ Args:
47
+ is_conversation (str, optional): Flag for chatting conversationally. Defaults to True.
48
+ max_tokens (int, optional): Maximum number of tokens to be generated upon completion. Defaults to 600.
49
+ temperature (float, optional): Charge of the generated text's randomness. Defaults to 0.2.
50
+ top_p (float, optional): Sampling threshold during inference time. Defaults to 0.999.
51
+ timeout (int, optional): Http requesting timeout. Defaults to 30
52
+ intro (str, optional): Conversation introductory prompt. Defaults to `Conversation.intro`.
53
+ filepath (str, optional): Path to file containing conversation history. Defaults to None.
54
+ update_file (bool, optional): Add new prompts and responses to the file. Defaults to True.
55
+ proxies (dict, optional) : Http reqiuest proxies (socks). Defaults to {}.
56
+ history_offset (int, optional): Limit conversation history to this number of last texts. Defaults to 10250.
57
+ act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
58
+ """
59
+ self.session = requests.Session()
60
+ self.is_conversation = is_conversation
61
+ self.max_tokens_to_sample = max_tokens
62
+ self.temperature = temperature
63
+ self.top_p = top_p
64
+ self.chat_endpoint = (
65
+ "https://koboldai-koboldcpp-tiefighter.hf.space/api/extra/generate/stream"
66
+ )
67
+ self.stream_chunk_size = 64
68
+ self.timeout = timeout
69
+ self.last_response = {}
70
+ self.headers = {
71
+ "Content-Type": "application/json",
72
+ "Accept": "application/json",
73
+ }
74
+
75
+ self.__available_optimizers = (
76
+ method
77
+ for method in dir(Optimizers)
78
+ if callable(getattr(Optimizers, method)) and not method.startswith("__")
79
+ )
80
+ self.session.headers.update(self.headers)
81
+ Conversation.intro = (
82
+ AwesomePrompts().get_act(
83
+ act, raise_not_found=True, default=None, case_insensitive=True
84
+ )
85
+ if act
86
+ else intro or Conversation.intro
87
+ )
88
+ self.conversation = Conversation(
89
+ is_conversation, self.max_tokens_to_sample, filepath, update_file
90
+ )
91
+ self.conversation.history_offset = history_offset
92
+ self.session.proxies = proxies
93
+
94
+ def ask(
95
+ self,
96
+ prompt: str,
97
+ stream: bool = False,
98
+ raw: bool = False,
99
+ optimizer: str = None,
100
+ conversationally: bool = False,
101
+ ) -> dict:
102
+ """Chat with AI
103
+
104
+ Args:
105
+ prompt (str): Prompt to be send.
106
+ stream (bool, optional): Flag for streaming response. Defaults to False.
107
+ raw (bool, optional): Stream back raw response as received. Defaults to False.
108
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
109
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
110
+ Returns:
111
+ dict : {}
112
+ ```json
113
+ {
114
+ "token" : "How may I assist you today?"
115
+ }
116
+ ```
117
+ """
118
+ conversation_prompt = self.conversation.gen_complete_prompt(prompt)
119
+ if optimizer:
120
+ if optimizer in self.__available_optimizers:
121
+ conversation_prompt = getattr(Optimizers, optimizer)(
122
+ conversation_prompt if conversationally else prompt
123
+ )
124
+ else:
125
+ raise Exception(
126
+ f"Optimizer is not one of {self.__available_optimizers}"
127
+ )
128
+
129
+ self.session.headers.update(self.headers)
130
+ payload = {
131
+ "prompt": conversation_prompt,
132
+ "temperature": self.temperature,
133
+ "top_p": self.top_p,
134
+ }
135
+
136
+ def for_stream():
137
+ response = self.session.post(
138
+ self.chat_endpoint, json=payload, stream=True, timeout=self.timeout
139
+ )
140
+ if not response.ok:
141
+ raise Exception(
142
+ f"Failed to generate response - ({response.status_code}, {response.reason}) - {response.text}"
143
+ )
144
+
145
+ message_load = ""
146
+ for value in response.iter_lines(
147
+ decode_unicode=True,
148
+ delimiter="" if raw else "event: message\ndata:",
149
+ chunk_size=self.stream_chunk_size,
150
+ ):
151
+ try:
152
+ resp = json.loads(value)
153
+ message_load += self.get_message(resp)
154
+ resp["token"] = message_load
155
+ self.last_response.update(resp)
156
+ yield value if raw else resp
157
+ except json.decoder.JSONDecodeError:
158
+ pass
159
+ self.conversation.update_chat_history(
160
+ prompt, self.get_message(self.last_response)
161
+ )
162
+
163
+ def for_non_stream():
164
+ # let's make use of stream
165
+ for _ in for_stream():
166
+ pass
167
+ return self.last_response
168
+
169
+ return for_stream() if stream else for_non_stream()
170
+
171
+ def chat(
172
+ self,
173
+ prompt: str,
174
+ stream: bool = False,
175
+ optimizer: str = None,
176
+ conversationally: bool = False,
177
+ ) -> str:
178
+ """Generate response `str`
179
+ Args:
180
+ prompt (str): Prompt to be send.
181
+ stream (bool, optional): Flag for streaming response. Defaults to False.
182
+ optimizer (str, optional): Prompt optimizer name - `[code, shell_command]`. Defaults to None.
183
+ conversationally (bool, optional): Chat conversationally when using optimizer. Defaults to False.
184
+ Returns:
185
+ str: Response generated
186
+ """
187
+
188
+ def for_stream():
189
+ for response in self.ask(
190
+ prompt, True, optimizer=optimizer, conversationally=conversationally
191
+ ):
192
+ yield self.get_message(response)
193
+
194
+ def for_non_stream():
195
+ return self.get_message(
196
+ self.ask(
197
+ prompt,
198
+ False,
199
+ optimizer=optimizer,
200
+ conversationally=conversationally,
201
+ )
202
+ )
203
+
204
+ return for_stream() if stream else for_non_stream()
205
+
206
+ def get_message(self, response: dict) -> str:
207
+ """Retrieves message only from response
208
+
209
+ Args:
210
+ response (dict): Response generated by `self.ask`
211
+
212
+ Returns:
213
+ str: Message extracted
214
+ """
215
+ assert isinstance(response, dict), "Response should be of dict data-type only"
216
+ return response.get("token")
27
217
  #------------------------------------------------------OpenGPT-----------------------------------------------------------
28
218
  class OPENGPT:
29
219
  def __init__(
@@ -1237,5 +1427,19 @@ def opengpt(prompt, stream):
1237
1427
  else:
1238
1428
  response_str = opengpt.chat(prompt)
1239
1429
  print(response_str)
1430
+
1431
+ @cli.command()
1432
+ @click.option('--prompt', prompt='Enter your prompt', help='The prompt to send.')
1433
+ @click.option('--stream', is_flag=True, help='Flag for streaming response.')
1434
+ @click.option('--raw', is_flag=True, help='Stream back raw response as received.')
1435
+ @click.option('--optimizer', type=str, help='Prompt optimizer name.')
1436
+ @click.option('--conversationally', is_flag=True, help='Chat conversationally when using optimizer.')
1437
+ def koboldai_cli(prompt, stream, raw, optimizer, conversationally):
1438
+ """Chat with KOBOLDAI using the provided prompt."""
1439
+ koboldai_instance = KOBOLDAI() # Initialize a KOBOLDAI instance
1440
+ response = koboldai_instance.ask(prompt, stream, raw, optimizer, conversationally)
1441
+ processed_response = koboldai_instance.get_message(response) # Process the response
1442
+ print(processed_response)
1443
+
1240
1444
  if __name__ == '__main__':
1241
1445
  cli()
@@ -11,7 +11,7 @@ import click
11
11
  from rich.markdown import Markdown
12
12
  from rich.console import Console
13
13
 
14
- appdir = appdirs.AppDirs("pytgpt", "Smartwa")
14
+ appdir = appdirs.AppDirs("AIWEBS", "vortex")
15
15
 
16
16
  default_path = appdir.user_cache_dir
17
17
 
@@ -1,7 +1,7 @@
1
1
  """Webscout.
2
2
 
3
3
  Search for words, documents, images, videos, news, maps and text translation
4
- using the DuckDuckGo.com search engine.
4
+ using the Google, DuckDuckGo.com, yep.com, phind.com, you.com, etc Also containes AI models
5
5
  """
6
6
 
7
7
  import logging
@@ -9,7 +9,10 @@ from .webscout_search import WEBS
9
9
  from .webscout_search_async import AsyncWEBS
10
10
  from .version import __version__
11
11
  from .DWEBS import DeepWEBS
12
- from .offlineAI import GPT4ALL
12
+ from .AIutel import appdir
13
+ from .transcriber import transcriber
14
+
15
+
13
16
  __all__ = ["WEBS", "AsyncWEBS", "__version__", "cli"]
14
17
 
15
18
  logging.getLogger("webscout").addHandler(logging.NullHandler())