Skip to content

Commit

Permalink
Avoid TGI error logit_bias: invalid type (#1557)
Browse files Browse the repository at this point in the history
TGI's OpenAI interface implementation does not
seem to handle the logit_bias property correctly,
so dstack-gateway will now avoid sending any
properties that were not explicitly set in the
user's request.
  • Loading branch information
jvstme authored Aug 15, 2024
1 parent 64c80ca commit 3802f3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*.egg-info

dist/
/venv/
venv/
/.cache/
.pytest_cache/
.coverage
Expand Down
8 changes: 6 additions & 2 deletions gateway/src/dstack/gateway/openai/clients/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ def __init__(self, base_url: str, host: Optional[str] = None):
)

async def generate(self, request: ChatCompletionsRequest) -> ChatCompletionsResponse:
resp = await self.client.post("/chat/completions", json=request.model_dump())
resp = await self.client.post(
"/chat/completions", json=request.model_dump(exclude_unset=True)
)
if resp.status_code != 200:
raise GatewayError(resp.text)
return ChatCompletionsResponse.model_validate(resp.json())

async def stream(self, request: ChatCompletionsRequest) -> AsyncIterator[ChatCompletionsChunk]:
async for data in self.client.stream_sse("/chat/completions", json=request.model_dump()):
async for data in self.client.stream_sse(
"/chat/completions", json=request.model_dump(exclude_unset=True)
):
yield ChatCompletionsChunk.model_validate(data)
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build~=1.2 # For building dstack-gateway wheels
pre-commit
httpx>=0.23
pytest~=7.2
Expand Down

0 comments on commit 3802f3c

Please sign in to comment.