Skip to content

Commit

Permalink
feat: Add AsyncLEO class for asynchronous API calls
Browse files Browse the repository at this point in the history
fix: Remove deprecated init.py file
patch: Update get_message function to handle responses directly
  • Loading branch information
Simatwa committed Nov 10, 2024
1 parent 41831e3 commit d4d1651
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 959 deletions.
14 changes: 6 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
requests[socks]>=2.31.0
click==8.1.3
requests[socks]>=2.32.3
click==8.1.7
rich==13.3.4
clipman==3.1.0
pyperclip==1.8.2
appdirs==1.4.4
webchatgpt==0.3.0
GoogleBard1>=2.1.4
colorama==0.4.6
g4f>=0.2.6.1
g4f>=0.3.3.3
pyyaml==6.0.1
matplotlib
gpt4all==2.2.0
poe-api-wrapper==1.3.6
poe-api-wrapper==1.7.0
python-dotenv==1.0.0
brotli==1.1.0
Helpingai_T2-fork==0.3.2
Helpingai_T2-fork>=0.3.2
fastapi[all]==0.115.4
python-vlc>=3.0.20
httpx==0.27.2
httpx>=0.27.2
prompt-toolkit==3.0.48
15 changes: 6 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@


INSTALL_REQUIRE = [
"requests[socks]>=2.31.0",
"requests[socks]>=2.32.3",
"appdirs==1.4.4",
"pyyaml==6.0.1",
"webchatgpt==0.3.0",
"GoogleBard1>=2.1.4",
"poe-api-wrapper==1.3.6",
"poe-api-wrapper==1.7.0",
"brotli==1.1.0",
"g4f>=0.2.6.1",
"Helpingai_T2-fork==0.3.2",
"g4f>=0.3.3.3",
"Helpingai_T2-fork>=0.3.2",
"python-vlc>=3.0.20",
"httpx==0.27.2",
]

cli_reqs = [
"click==8.1.3",
"click==8.1.7",
"rich==13.3.4",
"clipman==3.1.0",
"pyperclip==1.8.2",
"colorama==0.4.6",
"g4f>=0.2.6.1",
"python-dotenv==1.0.0",
"prompt-toolkit==3.0.48",
]
Expand All @@ -45,7 +42,7 @@
"termux-all": termux + cli_reqs + api,
"cli": cli_reqs,
"api": api,
"all": ["g4f[all]>=0.2.6.1", "matplotlib", "gpt4all==2.2.0"] + cli_reqs + api,
"all": ["g4f[all]>=0.3.3.3", "matplotlib", "gpt4all==2.2.0"] + cli_reqs + api,
}

DOCS_PATH = Path(__file__).parents[0] / "docs/README.md"
Expand Down
3 changes: 0 additions & 3 deletions src/pytgpt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@

tgpt_providers = [
"auto",
"leo",
"openai",
"opengpt",
"koboldai",
"gemini",
"phind",
"llama2",
"blackboxai",
"gpt4all",
"webchatgpt",
"g4fauto",
"poe",
"groq",
Expand Down
68 changes: 0 additions & 68 deletions src/pytgpt/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
from pytgpt.utils import Audio
from pytgpt.utils import suggest_query

from WebChatGPT.console import chat as webchatgpt

# colorama
from colorama import Fore
from colorama import init as init_colorama
Expand Down Expand Up @@ -484,26 +482,6 @@ def __init__(
"Consider running 'pytgpt gpt4free test -y' first"
)

elif provider == "leo":
import pytgpt.leo as leo

self.bot = leo.LEO(
is_conversation=disable_conversation,
max_tokens=max_tokens,
temperature=temperature,
top_k=top_k,
top_p=top_p,
model=getOr(model, leo.main.model),
brave_key=getOr(auth, leo.main.key),
timeout=timeout,
intro=intro,
filepath=filepath,
update_file=update_file,
proxies=proxies,
history_offset=history_offset,
act=awesome_prompt,
)

elif provider == "openai":
assert auth, (
"OpenAI's API-key is required. " "Use the flag `--key` or `-k`"
Expand Down Expand Up @@ -560,19 +538,6 @@ def __init__(
act=awesome_prompt,
)

elif provider == "gemini":
from pytgpt.gemini import GEMINI

assert auth, (
"Path to gemini.google.com.cookies.json file is required. "
"Use the flag `--key` or `-k`"
)
self.bot = GEMINI(
cookie_file=auth,
proxy=proxies,
timeout=timeout,
)

elif provider == "phind":
import pytgpt.phind.main as phind

Expand Down Expand Up @@ -670,35 +635,6 @@ def __init__(
act=awesome_prompt,
)

elif provider == "webchatgpt":
assert auth, (
"Path to `chat.openai.cookies.com.json` is required. "
"Use the flag `--key` or `-k`"
)

from pytgpt.webchatgpt import main

self.bot = main.WEBCHATGPT(
cookie_file=auth,
model=getOr(model, main.default_model),
proxy=proxies,
timeout=timeout,
filepath=filepath,
update_file=update_file,
intro=intro,
act=awesome_prompt,
)
intro_response = self.bot.chat(self.bot.conversation.intro, stream=True)
if not quiet:
this.stream_output(
intro_response,
title="Intro Response",
is_markdown=True,
style=Style(
color="cyan",
),
)

elif provider == "poe":
assert auth, (
"Path to poe.com.cookies.json file or 'p-b' cookie-value is required. "
Expand Down Expand Up @@ -2754,10 +2690,6 @@ def clear(content: str, yes: bool):

def make_commands():
"""Make pytgpt chained commands"""
# webchatgpt
# Intergration with WebChatGPT https://github.com/Simatwa/WebChatGPT
EntryGroup.tgpt2_.add_command(webchatgpt, "webchatgpt")

# generate
EntryGroup.tgpt2_.add_command(ChatGenerate.generate)

Expand Down
5 changes: 0 additions & 5 deletions src/pytgpt/gemini/__init__.py

This file was deleted.

192 changes: 0 additions & 192 deletions src/pytgpt/gemini/main.py

This file was deleted.

Loading

0 comments on commit d4d1651

Please sign in to comment.