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

fix: use AIOHTTP_CLIENT_TIMEOUT timeout setting for openai streaming response #3568

Merged
merged 1 commit into from
Jul 1, 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
fix: use AIOHTTP_CLIENT_TIMEOUT timeout setting for openai streaming …
…response
  • Loading branch information
fishhf committed Jul 1, 2024
commit f89fa061e87d83058c96fbc548a0eff982af5e64
5 changes: 4 additions & 1 deletion backend/apps/openai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 25,7 @@
from config import (
SRC_LOG_LEVELS,
ENABLE_OPENAI_API,
AIOHTTP_CLIENT_TIMEOUT,
OPENAI_API_BASE_URLS,
OPENAI_API_KEYS,
CACHE_DIR,
Expand Down Expand Up @@ -463,7 464,9 @@ async def generate_chat_completion(
streaming = False

try:
session = aiohttp.ClientSession(trust_env=True)
session = aiohttp.ClientSession(
trust_env=True, timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
)
r = await session.request(
method="POST",
url=f"{url}/chat/completions",
Expand Down