Skip to content

Commit

Permalink
Merge pull request xtekky#443 from TheTrueShell/main
Browse files Browse the repository at this point in the history
🔨 update(theb/__init__.py): add get_response method to Completion class
  • Loading branch information
xtekky authored May 4, 2023
2 parents 4a26913 + e865fcb commit 7cd8a58
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gpt4free/theb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def request(prompt: str, proxy: Optional[str] = None):
Completion.stream_completed = True

@staticmethod

def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]:
Completion.stream_completed = False

Expand All @@ -65,4 +64,13 @@ def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, Non

@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'))

0 comments on commit 7cd8a58

Please sign in to comment.