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

XFEstudio/gpt4free

refactor: remove cache parameter and update conversation handling

- Removed the `cache` parameter from the `PollinationsAI` class in `PollinationsAI.py`. - Added a `parent_message_id` parameter to the `chat_completion` method call in the `DeepSeekAPI` class in `DeepSeekAPI.py`. - Updated the handling of `conversation` in `DeepSeekAPI.py` to yield the `conversation` object at the end of the method. - Set `conversation.parent_id` to `chunk['message_id']` when present in the response in `DeepSeekAPI.py`. - Adjusted the method signatures in `aiohttp.py` to remove unnecessary type hints for `ClientSession` and `None`.

67231e8c
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +8 -6
Modified g4f/Provider/PollinationsAI.py +0 -1
@@ -490,7 +490,6 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
490 490 response_format=response_format,
491 491 stream=stream,
492 492 seed=seed,
493 cache=cache,
494 493 **extra_body
495 494 )
496 495 headers = {"referer": referrer}
Modified g4f/Provider/needs_auth/DeepSeekAPI.py +6 -3
@@ -62,14 +62,14 @@ class DeepSeekAPI(AsyncAuthedProvider, ProviderModelMixin):
62 62 if conversation is None:
63 63 chat_id = api.create_chat_session()
64 64 conversation = JsonConversation(chat_id=chat_id)
65 yield conversation
66 65
67 66 is_thinking = 0
68 67 for chunk in api.chat_completion(
69 68 conversation.chat_id,
70 69 get_last_user_message(messages),
71 70 thinking_enabled=bool(model) and "deepseek-r1" in model,
72 search_enabled=web_search
71 search_enabled=web_search,
72 parent_message_id=getattr(conversation, "parent_id", None)
73 73 ):
74 74 if chunk['type'] == 'thinking':
75 75 if not is_thinking:
@@ -82,5 +82,8 @@ class DeepSeekAPI(AsyncAuthedProvider, ProviderModelMixin):
82 82 is_thinking = 0
83 83 if chunk['content']:
84 84 yield chunk['content']
85 elif 'message_id' in chunk:
86 conversation.parent_id = chunk['message_id']
85 87 if chunk['finish_reason']:
86 yield FinishReason(chunk['finish_reason'])
88 yield FinishReason(chunk['finish_reason'])
89 yield conversation
Modified g4f/requests/aiohttp.py +2 -2
@@ -62,10 +62,10 @@ class StreamSession():
62 62 headers=headers
63 63 )
64 64
65 async def __aenter__(self) -> "ClientSession":
65 async def __aenter__(self) -> ClientSession:
66 66 return self.inner
67 67
68 async def __aexit__(self, **kwargs) -> None:
68 async def __aexit__(self, *args, **kwargs) -> None:
69 69 await self.inner.close()
70 70
71 71 def get_connector(connector: BaseConnector = None, proxy: str = None, rdns: bool = False) -> Optional[BaseConnector]: