Skip to content

Commit f78f964

Browse files
committed
Add gpt4free based providers (#6) (#14)
1 parent 4eacc38 commit f78f964

File tree

11 files changed

+479
-14
lines changed

11 files changed

+479
-14
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,5 @@ cython_debug/
163163
*test.py
164164
*recons
165165
README.md
166-
*.txt
166+
*.txt
167+
test_working_models.py

docs/CHANGELOG.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,62 @@ Assume role of the LLM and give your response.*
186186

187187
- Combine both of piped and explicitly issued prompt #13
188188
- Support piping input in Windows. #13
189-
- Placeholder for piped input `{{stream}}` and copied text `{{copied}}`.
189+
- Placeholder for piped input `{{stream}}` and copied text `{{copied}}`.
190+
191+
## v0.3.1
192+
193+
**What's new?**
194+
195+
<details>
196+
197+
<summary>
198+
199+
41 New models. Thanks to [gpt4free](https://github.com/xtekky/gpt4free).
200+
201+
</summary>
202+
203+
- AiChatOnline
204+
- Aura
205+
- Bard
206+
- Bing
207+
- ChatBase
208+
- ChatForAi
209+
- Chatgpt4Online
210+
- ChatgptAi
211+
- ChatgptDemo
212+
- ChatgptNext
213+
- Chatxyz
214+
- DeepInfra
215+
- FakeGpt
216+
- FreeChatgpt
217+
- GPTalk
218+
- GeekGpt
219+
- GeminiProChat
220+
- Gpt6
221+
- GptChatly
222+
- GptForLove
223+
- GptGo
224+
- GptTalkRu
225+
- Hashnode
226+
- HuggingChat
227+
- Koala
228+
- Liaobots
229+
- Llama2
230+
- MyShell
231+
- OnlineGpt
232+
- OpenaiChat
233+
- PerplexityAi
234+
- Phind
235+
- Pi
236+
- Poe
237+
- Raycast
238+
- TalkAi
239+
- Theb
240+
- ThebApi
241+
- You
242+
- Yqcloud
243+
244+
</details>
245+
246+
- **Aura** is the default provider
247+
- Other minor fixes.

docs/README.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a href="https://github.com/Simatwa/python-tgpt/actions/workflows/python-test.yml"><img src="https://github.com/Simatwa/python-tgpt/actions/workflows/python-test.yml/badge.svg" alt="Python Test"/></a>
99
-->
1010
<a href="https://github.com/Simatwa/python-tgpt/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/static/v1?logo=GPL&color=Blue&message=MIT&label=License"/></a>
11-
<a href="https://pypi.org/project/python-tgpt"><img alt="PyPi" src="https://img.shields.io/static/v1?logo=pypi&label=Pypi&message=0.3.0&color=green"/></a>
11+
<a href="https://pypi.org/project/python-tgpt"><img alt="PyPi" src="https://img.shields.io/static/v1?logo=pypi&label=Pypi&message=0.3.1&color=green"/></a>
1212
<a href="https://github.com/psf/black"><img alt="Black" src="https://img.shields.io/static/v1?logo=Black&label=Code-style&message=Black"/></a>
1313
<a href="#"><img alt="Passing" src="https://img.shields.io/static/v1?logo=Docs&label=Docs&message=Passing&color=green"/></a>
1414
<a href="https://github.com/Simatwa/python-tgpt/actions/workflows/python-package.yml"><img alt="Python Package flow" src="https://github.com/Simatwa/python-tgpt/actions/workflows/python-package.yml/badge.svg?branch=master"/></a>
@@ -40,7 +40,7 @@ python-tgpt
4040
>>>
4141
```
4242

43-
This project enables seamless interaction with free LLMs without requiring an API Key.
43+
This project enables seamless interaction with over **45 free LLMs** without requiring an API Key.
4444

4545
The name *python-tgpt* draws inspiration from its parent project [tgpt](https://github.com/aandrew-me/tgpt), which operates on [Golang](https://go.dev/). Through this Python adaptation, users can effortlessly engage with a number of free LLMs available as well as OpenAI's Chapytgpt models, fostering a smoother AI interaction experience.
4646

@@ -55,7 +55,7 @@ The name *python-tgpt* draws inspiration from its parent project [tgpt](https://
5555
- 🚀 Ready to use (No API key required)
5656
- ⛓️ Chained requests via proxy
5757
- 🤖 Pass [awesome-chapytgpt prompts](https://github.com/f/awesome-chapytgpt-prompts) easily
58-
- 🧠 Multiple LLM providers
58+
- 🧠 Multiple LLM providers - **45+**
5959

6060
## Providers
6161

@@ -69,6 +69,57 @@ These are simply the hosts of the LLMs, which include:
6969
6. [WebChatGPT](https://github.com/Simatwa/WebChatGPT) - **OpenAI** *(Session ID required)*
7070
7. [Bard](https://github.com/acheong08/bard) - **Google** *(Session ID required)*
7171

72+
<details>
73+
74+
<summary>
75+
76+
+ 41 Other models proudly offered by [gpt4free](https://github.com/xtekky/gpt4free).
77+
78+
</summary>
79+
80+
- AiChatOnline
81+
- Aura
82+
- Bard
83+
- Bing
84+
- ChatBase
85+
- ChatForAi
86+
- Chatgpt4Online
87+
- ChatgptAi
88+
- ChatgptDemo
89+
- ChatgptNext
90+
- Chatxyz
91+
- DeepInfra
92+
- FakeGpt
93+
- FreeChatgpt
94+
- GPTalk
95+
- GeekGpt
96+
- GeminiProChat
97+
- Gpt6
98+
- GptChatly
99+
- GptForLove
100+
- GptGo
101+
- GptTalkRu
102+
- Hashnode
103+
- HuggingChat
104+
- Koala
105+
- Liaobots
106+
- Llama2
107+
- MyShell
108+
- OnlineGpt
109+
- OpenaiChat
110+
- PerplexityAi
111+
- Phind
112+
- Pi
113+
- Poe
114+
- Raycast
115+
- TalkAi
116+
- Theb
117+
- ThebApi
118+
- You
119+
- Yqcloud
120+
121+
</details>
122+
72123
## Prerequisites
73124

74125
- [x] [Python>=3.9](https://python.org) *(Optional)*
@@ -283,6 +334,25 @@ print(bot.chat("<Your-prompt>"))
283334
</details>
284335

285336

337+
</details>
338+
339+
<details>
340+
341+
<summary>
342+
343+
Gpt4free providers
344+
345+
</summary>
346+
347+
```python
348+
import pytgpt.gpt4free as gpt4free
349+
bot = gpt4free.GPT4FREE(provider="Aura")
350+
print(bot.chat("<Your-prompt>"))
351+
```
352+
353+
</details>
354+
355+
286356
</details>
287357

288358
<details>
@@ -312,7 +382,7 @@ bot = koboldai.KOBOLDAI(is_conversation=False)
312382

313383
Utilize the `--disable-conversation` flag in the console to achieve the same functionality.
314384

315-
> **Warning** : **Bard** and **WebChatGPT** autohandles context due to the obvious reason; the `is_conversation` parameter is not necessary at all hence not required when initializing the respective classes.
385+
> **Warning** : **Bard** and **WebChatGPT** autohandles context due to the obvious reason; the `is_conversation` parameter is not necessary at all hence not required when initializing the respective classes. Also be informed that majority of providers offered by *gpt4free* requires *Google Chrome* inorder to function.
316386
317387
### Advanced Usage of Placeholders
318388

@@ -337,4 +407,5 @@ For more usage info run `$ pytgpt --help`
337407
## Acknowledgements
338408

339409
1. [x] [tgpt](https://github.com/aandrew-me/tgpt)
340-
2. [x] You
410+
2. [x] [gpt4free](https://github.com/xtekky/gpt4free)
411+
3. [x] You

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ pyperclip==1.8.2
66
appdirs==1.4.4
77
webchatgpt==0.2.7
88
GoogleBard==1.4.0
9-
colorama==0.4.6
9+
colorama==0.4.6
10+
g4f==0.2.0.3

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setup(
1616
name="python-tgpt",
17-
version="0.3.0",
17+
version="0.3.1",
1818
license="MIT",
1919
author="Smartwa",
2020
maintainer="Smartwa",
@@ -46,6 +46,7 @@
4646
"webchatgpt==0.2.7",
4747
"GoogleBard==1.4.0",
4848
"colorama==0.4.6",
49+
"g4f==0.2.0.3",
4950
],
5051
python_requires=">=3.9",
5152
keywords=[

src/pytgpt/__init__.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
from .utils import appdir
22

3-
__version__ = "0.3.0"
3+
__version__ = "0.3.1"
44
__author__ = "Smartwa"
55
__repo__ = "https://github.com/Simatwa/python-tgpt"
66

7-
available_providers = ["leo", "openai", "fakeopen", "opengpt", "koboldai", "bard"]
7+
gpt4free_providers = [
8+
"AItianhuSpace",
9+
"AiChatOnline",
10+
"Aura",
11+
"Bard",
12+
"Bing",
13+
"ChatBase",
14+
"ChatForAi",
15+
"Chatgpt4Online",
16+
"ChatgptAi",
17+
"ChatgptDemo",
18+
"ChatgptNext",
19+
"Chatxyz",
20+
"DeepInfra",
21+
"FakeGpt",
22+
"FreeChatgpt",
23+
"GPTalk",
24+
"GeekGpt",
25+
"GeminiProChat",
26+
"Gpt6",
27+
"GptChatly",
28+
"GptForLove",
29+
"GptGo",
30+
"GptTalkRu",
31+
"Hashnode",
32+
"HuggingChat",
33+
"Koala",
34+
"Liaobots",
35+
"Llama2",
36+
"MyShell",
37+
"OnlineGpt",
38+
"OpenaiChat",
39+
"PerplexityAi",
40+
"Phind",
41+
"Pi",
42+
"Poe",
43+
"Raycast",
44+
"TalkAi",
45+
"Theb",
46+
"ThebApi",
47+
"You",
48+
"Yqcloud",
49+
]
50+
available_providers = ["leo", "openai", "fakeopen", "opengpt", "koboldai", "bard"] + gpt4free_providers
851

952
__all__ = [
1053
"appdir",

src/pytgpt/console.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
rich_code_themes = ["monokai", "paraiso-dark", "igor", "vs", "fruity", "xcode"]
3838

39-
default_provider = "leo"
39+
default_provider = "Aura"
4040

4141
logging.basicConfig(
4242
format="%(asctime)s - %(levelname)s : %(message)s ", # [%(module)s,%(lineno)s]", # for debug purposes
@@ -234,6 +234,7 @@ def __init__(
234234
proxy_path,
235235
provider,
236236
quiet=False,
237+
chat_completion=False,
237238
*args,
238239
**kwargs,
239240
):
@@ -314,6 +315,7 @@ def __init__(
314315

315316
self.bot = OPENGPT(
316317
is_conversation=disable_conversation,
318+
max_tokens=max_tokens,
317319
timeout=timeout,
318320
intro=intro,
319321
filepath=filepath,
@@ -352,6 +354,23 @@ def __init__(
352354
timeout=timeout,
353355
)
354356

357+
elif provider in pytgpt.gpt4free_providers:
358+
from pytgpt.gpt4free import GPT4FREE
359+
self.bot = GPT4FREE(
360+
provider=provider,
361+
is_conversation=disable_conversation,
362+
max_tokens=max_tokens,
363+
model=model,
364+
chat_completion=chat_completion,
365+
timeout=timeout,
366+
intro=intro,
367+
filepath=filepath,
368+
update_file=update_file,
369+
proxies=proxies,
370+
history_offset=history_offset,
371+
act=awesome_prompt,
372+
)
373+
355374
else:
356375
raise NotImplementedError(
357376
f"The provider `{provider}` is not yet implemented."
@@ -909,6 +928,12 @@ def tgpt2_():
909928
@click.option(
910929
"-nc", "--no-coloring", is_flag=True, help="Disable intro prompt font-coloring"
911930
)
931+
@click.option(
932+
"-cc",
933+
"--chat-completion",
934+
is_flag=True,
935+
help="Provide native context for gpt4free providers",
936+
)
912937
@click.help_option("-h", "--help")
913938
def interactive(
914939
model,
@@ -937,6 +962,7 @@ def interactive(
937962
new,
938963
with_copied,
939964
no_coloring,
965+
chat_completion,
940966
):
941967
"""Chat with AI interactively (Default)"""
942968
clear_history_file(filepath, new)
@@ -957,6 +983,7 @@ def interactive(
957983
proxy_path,
958984
provider,
959985
quiet,
986+
chat_completion,
960987
)
961988
busy_bar.spin_index = busy_bar_index
962989
bot.code_theme = code_theme

src/pytgpt/gpt4free/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from .main import GPT4FREE
2+
3+
from .main import working_providers
4+
5+
from .main import default_models
6+
7+
from .main import completion_allowed_models
8+
9+
__info__ = (
10+
"Interact with various free models bundled by https://github.com/xtekky/gpt4free"
11+
)
12+
13+
all = [
14+
"GPT4FREE",
15+
"working_providers",
16+
"default_models",
17+
"completion_allowed_models",
18+
]

0 commit comments

Comments
 (0)