mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-05 00:01:00 +00:00
Merge pull request #443 from TheTrueShell/main
🔨 update(theb/__init__.py): add get_response method to Completion class
This commit is contained in:
commit
7cd8a58c37
@ -46,7 +46,6 @@ class Completion:
|
||||
Completion.stream_completed = True
|
||||
|
||||
@staticmethod
|
||||
|
||||
def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]:
|
||||
Completion.stream_completed = False
|
||||
|
||||
@ -65,4 +64,13 @@ class Completion:
|
||||
|
||||
@staticmethod
|
||||
def handle_stream_response(response):
|
||||
Completion.message_queue.put(response.decode())
|
||||
|
||||
@staticmethod
|
||||
def get_response(prompt: str, proxy: Optional[str] = None) -> str:
|
||||
response_list = []
|
||||
for message in Completion.create(prompt, proxy):
|
||||
response_list.append(message)
|
||||
return ''.join(response_list)
|
||||
|
||||
Completion.message_queue.put(response.decode(errors='replace'))
|
||||
|
Loading…
Reference in New Issue
Block a user