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`.
This commit is contained in:
hlohaus 2025-06-12 16:43:14 +02:00
parent 963c3a585e
commit 67231e8c40
3 changed files with 8 additions and 6 deletions

View file

@ -490,7 +490,6 @@ class PollinationsAI(AsyncGeneratorProvider, ProviderModelMixin):
response_format=response_format,
stream=stream,
seed=seed,
cache=cache,
**extra_body
)
headers = {"referer": referrer}

View file

@ -62,14 +62,14 @@ class DeepSeekAPI(AsyncAuthedProvider, ProviderModelMixin):
if conversation is None:
chat_id = api.create_chat_session()
conversation = JsonConversation(chat_id=chat_id)
yield conversation
is_thinking = 0
for chunk in api.chat_completion(
conversation.chat_id,
get_last_user_message(messages),
thinking_enabled=bool(model) and "deepseek-r1" in model,
search_enabled=web_search
search_enabled=web_search,
parent_message_id=getattr(conversation, "parent_id", None)
):
if chunk['type'] == 'thinking':
if not is_thinking:
@ -82,5 +82,8 @@ class DeepSeekAPI(AsyncAuthedProvider, ProviderModelMixin):
is_thinking = 0
if chunk['content']:
yield chunk['content']
elif 'message_id' in chunk:
conversation.parent_id = chunk['message_id']
if chunk['finish_reason']:
yield FinishReason(chunk['finish_reason'])
yield conversation

View file

@ -62,10 +62,10 @@ class StreamSession():
headers=headers
)
async def __aenter__(self) -> "ClientSession":
async def __aenter__(self) -> ClientSession:
return self.inner
async def __aexit__(self, **kwargs) -> None:
async def __aexit__(self, *args, **kwargs) -> None:
await self.inner.close()
def get_connector(connector: BaseConnector = None, proxy: str = None, rdns: bool = False) -> Optional[BaseConnector]: