Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add timeout parameter to achat() #243

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions duckduckgo_search/duckduckgo_search_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ async def __aexit__(
) -> None:
pass

async def achat(self, keywords: str, model: str = "gpt-4o-mini") -> str:
async def achat(self, keywords: str, model: str = "gpt-4o-mini", timeout: int = 30) -> str:
"""Initiates async chat session with DuckDuckGo AI.

Args:
keywords (str): The initial message or question to send to the AI.
model (str): The model to use: "gpt-4o-mini", "claude-3-haiku", "llama-3-70b", "mixtral-8x7b".
Defaults to "gpt-4o-mini".
timeout (int): Timeout value for the HTTP client. Defaults to 30.

Returns:
str: The response from the AI.
"""
result = await self._loop.run_in_executor(self._executor, super().chat, keywords, model)
result = await self._loop.run_in_executor(self._executor, super().chat, keywords, model, timeout)
return result

async def atext(
Expand Down
Loading