Skip to content

Commit e5453d4

Browse files
committed
Revert "feat: Minor changes"
This reverts commit ffe2939.
1 parent ffe2939 commit e5453d4

File tree

12 files changed

+17
-200
lines changed

12 files changed

+17
-200
lines changed

.github/workflows/binaries-minimal-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up Python
3232
uses: actions/setup-python@v3
3333
with:
34-
python-version: '3.13'
34+
python-version: '3.12'
3535
- name: Install dependencies and python-tgpt
3636
run: |
3737
python -m pip install --upgrade pip pyinstaller pillow

.github/workflows/binaries-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up Python
3232
uses: actions/setup-python@v3
3333
with:
34-
python-version: '3.13'
34+
python-version: '3.12'
3535
- name: Install dependencies and python-tgpt
3636
run: |
3737
python -m pip install --upgrade pip pyinstaller pillow

.github/workflows/debian-minimal-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
python-version: ["3.13"]
15+
python-version: ["3.12"]
1616
include:
1717
- os: ubuntu-latest
1818
artifact_name: pytgpt.deb
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Python
2424
uses: actions/setup-python@v3
2525
with:
26-
python-version: '3.13'
26+
python-version: '3.12'
2727
- name: Install pip and pyinstaller
2828
run: python -m pip install --upgrade pip pyinstaller
2929
- name: Install python-tgpt

.github/workflows/debian-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
python-version: ["3.13"]
15+
python-version: ["3.12"]
1616
include:
1717
- os: ubuntu-latest
1818
artifact_name: pytgpt.deb
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Python
2424
uses: actions/setup-python@v3
2525
with:
26-
python-version: '3.13'
26+
python-version: '3.12'
2727
- name: Install pip and pyinstaller
2828
run: python -m pip install --upgrade pip pyinstaller
2929
- name: Install python-tgpt

.github/workflows/python-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ "main", "master" ]
8+
branches: [ "master" ]
99
pull_request:
10-
branches: [ "main", "master" ]
10+
branches: [ "master" ]
1111

1212
jobs:
1313
build:
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: [ "3.13", "3.12", "3.11", "3.10" ]
19+
python-version: ["3.12"]
2020

2121
steps:
2222
- uses: actions/checkout@v3

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v3
2727
with:
28-
python-version: '3.13'
28+
python-version: '3.12'
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ brotli==1.1.0
1717
Helpingai_T2-fork==0.3.2
1818
fastapi[all]==0.115.4
1919
python-vlc>=3.0.20
20-
httpx==0.27.2
21-
prompt-toolkit==3.0.48
20+
httpx==0.27.2

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"colorama==0.4.6",
2828
"g4f>=0.2.6.1",
2929
"python-dotenv==1.0.0",
30-
"prompt-toolkit==3.0.48",
3130
]
3231

3332
api = [
@@ -57,7 +56,7 @@
5756

5857
setup(
5958
name="python-tgpt",
60-
version="0.7.8",
59+
version="0.7.7",
6160
license="MIT",
6261
author="Smartwa",
6362
maintainer="Smartwa",

src/pytgpt/auto/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from pytgpt.gpt4free import GPT4FREE, AsyncGPT4FREE
99
from pytgpt.gpt4free.utils import TestProviders
1010
from pytgpt.auto.errors import AllProvidersFailure
11-
from pytgpt.utils import Conversation
1211
from pytgpt.async_providers import tgpt_mapper as async_provider_map
1312
from typing import AsyncGenerator
1413

@@ -78,7 +77,7 @@ def last_response(self) -> dict[str, Any]:
7877
return self.provider.last_response
7978

8079
@property
81-
def conversation(self) -> Conversation:
80+
def conversation(self) -> object:
8281
return self.provider.conversation
8382

8483
def ask(
@@ -289,7 +288,7 @@ def last_response(self) -> dict[str, Any]:
289288
return self.provider.last_response
290289

291290
@property
292-
def conversation(self) -> Conversation:
291+
def conversation(self) -> object:
293292
return self.provider.conversation
294293

295294
async def ask(

src/pytgpt/console.py

Lines changed: 3 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import subprocess
1515
from threading import Thread as thr
1616
from functools import wraps
17-
18-
# rich
19-
2017
from rich.panel import Panel
2118
from rich.style import Style
2219
from rich.markdown import Markdown
@@ -25,33 +22,19 @@
2522
from rich.table import Table
2623
from rich.prompt import Prompt
2724
from rich.progress import Progress
28-
2925
from typing import Iterable
30-
31-
#pytgpt
32-
3326
from pytgpt.utils import Optimizers
3427
from pytgpt.utils import default_path
3528
from pytgpt.utils import AwesomePrompts
3629
from pytgpt.utils import RawDog
3730
from pytgpt.imager import Imager
3831
from pytgpt.imager import Prodia
3932
from pytgpt.utils import Audio
40-
from pytgpt.utils import suggest_query
41-
4233
from WebChatGPT.console import chat as webchatgpt
43-
44-
# colorama
4534
from colorama import Fore
4635
from colorama import init as init_colorama
47-
4836
from dotenv import load_dotenv
4937

50-
# prompt-toolkit
51-
from prompt_toolkit import PromptSession
52-
from prompt_toolkit.completion import ThreadedCompleter, Completer, Completion
53-
from prompt_toolkit.document import Document
54-
5538
init_colorama(autoreset=True)
5639

5740
load_dotenv() # loads .env variables
@@ -346,40 +329,6 @@ def main(*args, **kwargs):
346329

347330
return decorator
348331

349-
class CustomCompleter(Completer):
350-
"""Suggests query based on user prompts"""
351-
352-
def __init__(
353-
self,
354-
caller: object,
355-
suggestions_limit: int = 15,
356-
special_commands: list[str] = [],
357-
):
358-
self.suggestions_limit = suggestions_limit
359-
self.caller = caller
360-
self.special_commands = special_commands
361-
362-
def get_completions(self, document: Document, complete_event):
363-
word = document.text
364-
if word and self.suggestions_limit > 0 and not word.startswith("./"):
365-
completions = []
366-
first_word = word.strip().split(" ")[0]
367-
if first_word in self.special_commands:
368-
completions.append(
369-
Completion(
370-
f"{first_word} [RESERVED] "
371-
+ getattr(self.caller, f"do_{first_word}").__doc__
372-
)
373-
)
374-
return completions
375-
for count, suggestion in enumerate(
376-
suggest_query(word, timeout=10, die_silently=True),
377-
start=1):
378-
completions.append(Completion(suggestion, start_position=-len(word)))
379-
if count >= self.suggestions_limit:
380-
break
381-
return completions
382-
return []
383332

384333
class Main(cmd.Cmd):
385334
intro = (
@@ -412,8 +361,6 @@ def __init__(
412361
internal_exec=False,
413362
confirm_script=False,
414363
interpreter="python",
415-
suggestions_limit=15,
416-
non_interactive=False,
417364
*args,
418365
**kwargs,
419366
):
@@ -825,22 +772,6 @@ def __init__(
825772
self.read_aloud = False
826773
self.read_aloud_voice = "Brian"
827774
self.path_to_last_response_audio = None
828-
if not non_interactive:
829-
self.completer_session = PromptSession(
830-
"",
831-
completer=ThreadedCompleter(
832-
CustomCompleter(
833-
self,
834-
suggestions_limit,
835-
[
836-
"cd", "copy_this", "h", "last_response", "rawdog",
837-
"settings", "with_copied",
838-
"clear", "exec", "help", "load", "reread", "shell",
839-
"code", "exit", "history", "new_intro", "reset", "sys",
840-
],
841-
)
842-
),
843-
)
844775
self.__init_time = time.time()
845776
self.__start_time = time.time()
846777
self.__end_time = time.time()
@@ -871,7 +802,7 @@ def find_range(start, end, hms: bool = False):
871802
f"~[`{Fore.LIGHTWHITE_EX}🕒{Fore.BLUE}{current_time}-`"
872803
f"{Fore.LIGHTWHITE_EX}💻{Fore.RED}{find_range(self.__init_time, time.time(), True)}-`"
873804
f"{Fore.LIGHTWHITE_EX}{Fore.YELLOW}{find_range(self.__start_time, self.__end_time)}s]`"
874-
# f"\n╰─>"
805+
f"\n╰─>"
875806
)
876807
whitelist = ["[", "]", "~", "-", "(", ")"]
877808
for character in whitelist:
@@ -884,70 +815,8 @@ def find_range(start, end, hms: bool = False):
884815
f"~[🕒{current_time}"
885816
f"-💻{find_range(self.__init_time, time.time(), True)}"
886817
f"-⚡{find_range(self.__start_time, self.__end_time)}s]"
887-
#"\n╰─>"
818+
"\n╰─>"
888819
)
889-
def cmdloop(self, intro=None):
890-
"""Repeatedly issue a prompt, accept input, parse an initial prefix
891-
off the received input, and dispatch to action methods, passing them
892-
the remainder of the line as argument.
893-
894-
"""
895-
896-
self.preloop()
897-
if self.use_rawinput and self.completekey:
898-
try:
899-
import readline
900-
901-
self.old_completer = readline.get_completer()
902-
readline.set_completer(self.complete)
903-
if hasattr(readline, "backend") and readline.backend == "editline":
904-
if self.completekey == "tab":
905-
# libedit uses "^I" instead of "tab"
906-
command_string = "bind ^I rl_complete"
907-
else:
908-
command_string = f"bind {self.completekey} rl_complete"
909-
else:
910-
command_string = f"{self.completekey}: complete"
911-
readline.parse_and_bind(command_string)
912-
except ImportError:
913-
pass
914-
try:
915-
if intro is not None:
916-
self.intro = intro
917-
if self.intro:
918-
self.stdout.write(str(self.intro) + "\n")
919-
stop = None
920-
while not stop:
921-
if self.cmdqueue:
922-
line = self.cmdqueue.pop(0)
923-
else:
924-
if self.use_rawinput:
925-
try:
926-
print(self.prompt, end="")
927-
line = self.completer_session.prompt("\n╰─>")
928-
except EOFError:
929-
line = "EOF"
930-
else:
931-
self.stdout.write(self.prompt)
932-
self.stdout.flush()
933-
line = self.stdin.readline()
934-
if not len(line):
935-
line = "EOF"
936-
else:
937-
line = line.rstrip("\r\n")
938-
line = self.precmd(line)
939-
stop = self.onecmd(line)
940-
stop = self.postcmd(stop, line)
941-
self.postloop()
942-
finally:
943-
if self.use_rawinput and self.completekey:
944-
try:
945-
import readline
946-
947-
readline.set_completer(self.old_completer)
948-
except ImportError:
949-
pass
950-
951820

952821
def output_bond(
953822
self,
@@ -1375,7 +1244,7 @@ def do_sys(self, line):
13751244
def do_exit(self, line):
13761245
"""Quit this program"""
13771246
if click.confirm("Are you sure to exit"):
1378-
click.secho("^-^ Okay Goodbye!", fg="yellow")
1247+
click.secho("Okay Goodbye!", fg="yellow")
13791248
return True
13801249

13811250

@@ -1553,13 +1422,6 @@ class ChatInteractive:
15531422
"for advanced g4f providers test"
15541423
),
15551424
)
1556-
@click.option(
1557-
'-sl',
1558-
"--suggestions-limit",
1559-
type=click.INT,
1560-
help="Prompt suggestions limit - 0 to disable suggestion",
1561-
default=15,
1562-
)
15631425
@click.option(
15641426
"-vo",
15651427
"--vertical-overflow",
@@ -1668,7 +1530,6 @@ def interactive(
16681530
awesome_prompt,
16691531
proxy_path,
16701532
provider,
1671-
suggestions_limit,
16721533
vertical_overflow,
16731534
whole,
16741535
quiet,
@@ -1709,7 +1570,6 @@ def interactive(
17091570
internal_exec=internal_exec,
17101571
confirm_script=confirm_script,
17111572
interpreter=interpreter,
1712-
suggestions_limit=suggestions_limit
17131573
)
17141574
busy_bar.spin_index = busy_bar_index
17151575
bot.code_theme = code_theme
@@ -2009,7 +1869,6 @@ def generate(
20091869
internal_exec=internal_exec,
20101870
confirm_script=confirm_script,
20111871
interpreter=interpreter,
2012-
non_interactive=True
20131872
)
20141873
prompt = prompt if prompt else ""
20151874
copied_placeholder = "{{copied}}"

0 commit comments

Comments
 (0)