Skip to content

Commit

Permalink
Increase openai client limit (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ying1123 authored Aug 2, 2024
1 parent e90e3a5 commit 3cadecf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/sglang/test/simple_eval_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from multiprocessing.pool import ThreadPool
from typing import Any

import httpx
import jinja2
import numpy as np
import openai
Expand Down Expand Up @@ -70,6 +71,16 @@ def __call__(self, sampler: SamplerBase) -> EvalResult:
raise NotImplementedError()


class LargerHttpxClient(httpx.Client):
def __init__(self):
timeout_config = httpx.Timeout(3600)
limits = httpx.Limits(
max_keepalive_connections=3600,
max_connections=3600,
)
super().__init__(timeout=timeout_config, limits=limits)


class ChatCompletionSampler(SamplerBase):
"""
Sample from OpenAI's chat completion API
Expand All @@ -83,7 +94,7 @@ def __init__(
temperature: float = 0.0,
max_tokens: int = 2048,
):
self.client = OpenAI(base_url=base_url)
self.client = OpenAI(base_url=base_url, http_client=LargerHttpxClient())

if model is None:
model = self.client.models.list().data[0].id
Expand Down

0 comments on commit 3cadecf

Please sign in to comment.