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

increase httpx timeout #30

Merged
merged 1 commit into from
Oct 18, 2023
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
11 changes: 8 additions & 3 deletions src/fastapi_poe/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async def _load_json_dict(


def _default_error_handler(e: Exception, msg: str) -> None:
print("Error in Poe bot:", msg, e)
print("Error in Poe bot:", msg, "\n", repr(e))


async def stream_request(
Expand All @@ -296,7 +296,7 @@ async def stream_request(

async with contextlib.AsyncExitStack() as stack:
if session is None:
session = await stack.enter_async_context(httpx.AsyncClient())
session = await stack.enter_async_context(httpx.AsyncClient(timeout=120))
url = f"{base_url}{bot_name}"
ctx = _BotContext(
endpoint=url, api_key=api_key, session=session, on_error=on_error
Expand Down Expand Up @@ -333,6 +333,7 @@ def get_bot_response(
logit_bias: Optional[Dict[str, float]] = None,
stop_sequences: Optional[List[str]] = None,
base_url: str = "https://api.poe.com/bot/",
session: Optional[httpx.AsyncClient] = None,
) -> AsyncGenerator[BotMessage, None]:
additional_params = {}
# This is so that we don't have to redefine the default values for these params.
Expand All @@ -355,7 +356,11 @@ def get_bot_response(
**additional_params,
)
return stream_request(
request=query, bot_name=bot_name, api_key=api_key, base_url=base_url
request=query,
bot_name=bot_name,
api_key=api_key,
base_url=base_url,
session=session,
)


Expand Down