Skip to content

Commit 30b0e39

Browse files
committed
patch: Minor fix - webchatgpt
1 parent 8b10293 commit 30b0e39

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Alternatively, you can install non-binaries. *(Recommended)*
250250
2. Commandline:
251251

252252
```sh
253-
pip install ---upgrade "python-tgpt[cli]"
253+
pip install --upgrade "python-tgpt[cli]"
254254
```
255255

256256
3. Full installation:

src/pytgpt/console.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ def __init__(
553553
filepath=filepath,
554554
update_file=update_file,
555555
history_offset=history_offset,
556+
act=awesome_prompt,
556557
)
557558

558559
elif provider == "webchatgpt":
@@ -570,7 +571,19 @@ def __init__(
570571
timeout=timeout,
571572
filepath=filepath,
572573
update_file=update_file,
574+
intro=intro,
575+
act=awesome_prompt,
573576
)
577+
intro_response = self.bot.chat(self.bot.conversation.intro, stream=True)
578+
if not quiet:
579+
this.stream_output(
580+
intro_response,
581+
title="Intro Response",
582+
is_markdown=True,
583+
style=Style(
584+
color="cyan",
585+
),
586+
)
574587

575588
elif provider in pytgpt.gpt4free_providers:
576589
from pytgpt.gpt4free import GPT4FREE

src/pytgpt/webchatgpt/main.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pytgpt.base import Provider
44
from pytgpt.utils import Conversation
55
from pytgpt.utils import Optimizers
6+
from pytgpt.utils import AwesomePrompts
67

78
default_model = "text-davinci-002-render-sha"
89

@@ -16,6 +17,8 @@ def __init__(
1617
timeout: int = 30,
1718
filepath: str = None,
1819
update_file: str = True,
20+
intro: str = None,
21+
act: str = None,
1922
):
2023
"""Initializes WEBCHATGPT
2124
@@ -26,10 +29,9 @@ def __init__(
2629
timeout (int, optional): Http request timeout. Defaults to 30.
2730
filepath (str, optional): Path to save the chat history. Defaults to None.
2831
update_file (str, optional): Flag for controlling chat history updates. Defaults to True.
32+
intro (str, optional): Conversation introductory prompt. Defaults to None.
33+
act (str|int, optional): Awesome prompt key or index. (Used as intro). Defaults to None.
2934
"""
30-
self.conversation = Conversation(
31-
status=False, filepath=filepath, update_file=update_file
32-
)
3335
self.session = ChatGPT(cookie_path=cookie_file, model=model, timeout=timeout)
3436
self.session.session.proxies = proxy
3537
self.last_response = {}
@@ -38,6 +40,16 @@ def __init__(
3840
for method in dir(Optimizers)
3941
if callable(getattr(Optimizers, method)) and not method.startswith("__")
4042
)
43+
Conversation.intro = (
44+
AwesomePrompts().get_act(
45+
act, raise_not_found=True, default=None, case_insensitive=True
46+
)
47+
if act
48+
else intro or Conversation.intro
49+
)
50+
self.conversation = Conversation(
51+
status=False, filepath=filepath, update_file=update_file
52+
)
4153

4254
def ask(
4355
self,

0 commit comments

Comments
 (0)