XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

🔨 update(theb/__init__.py): add get_response method to Completion class

The get_response method was added to the Completion class to allow for easier retrieval of the response from the GPT-3 API. This method takes in a prompt and an optional proxy and returns the response as a string. The method uses the create method to generate a generator object and then iterates over it to append each message to a list. Finally, the list is joined into a single string and returned. This allows for non stream usage of theb.

82a3a039
Rory Durrant <rory@spun.ga>
提交于

代码差异

1 个文件 +7 -1
Modified gpt4free/theb/__init__.py +7 -1
@@ -46,7 +46,6 @@ class Completion:
46 46 Completion.stream_completed = True
47 47
48 48 @staticmethod
49
50 49 def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]:
51 50 Completion.stream_completed = False
52 51
@@ -66,3 +65,10 @@ class Completion:
66 65 @staticmethod
67 66 def handle_stream_response(response):
68 67 Completion.message_queue.put(response.decode())
68
69 @staticmethod
70 def get_response(prompt: str, proxy: Optional[str] = None) -> str:
71 response_list = []
72 for message in Completion.create(prompt, proxy):
73 response_list.append(message)
74 return ''.join(response_list)