Skip to content

Commit

Permalink
return model name from validate connection
Browse files Browse the repository at this point in the history
  • Loading branch information
hakan458 committed Jan 8, 2025
1 parent d4439e2 commit 9a8e51a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class ValidateConnectionRequest(BaseModel):
auth_token: Optional[str] = None


class ValidateConnectionResponse(BaseModel):
model: str
success: bool


class Status(Enum):
PENDING = "Pending"
INPROGRESS = "InProgress"
Expand Down Expand Up @@ -238,7 +243,7 @@ async def submit_batch(batch: BatchData):
return Response[BatchSubmitted](data=BatchSubmitted(job_id=batch.job_id))


@app.post("/validate-connection", response_model=Response)
@app.post("/validate-connection", response_model=Response[ValidateConnectionResponse])
async def validate_connection(request: ValidateConnectionRequest):
multi_model_provider_models = {
"openai": "gpt-4o-mini",
Expand All @@ -259,7 +264,7 @@ async def validate_connection(request: ValidateConnectionRequest):
if request.vertex_project:
model_extra["vertex_project"] = request.vertex_project
try:
litellm.completion(
response = litellm.completion(
messages=messages,
model=model,
max_tokens=10,
Expand Down Expand Up @@ -291,7 +296,7 @@ async def validate_connection(request: ValidateConnectionRequest):
)
model_extra["api_key"] = request.api_key
try:
litellm.completion(
response = litellm.completion(
messages=messages,
model=model,
max_tokens=10,
Expand All @@ -309,7 +314,9 @@ async def validate_connection(request: ValidateConnectionRequest):
detail=f"Failed to check availability of requested model '{model}': {e}",
)

return Response(success=True, data=None)
return Response[ValidateConnectionResponse](
data=ValidateConnectionResponse(success=True, model=response.model)
)


@app.post("/models-list", response_model=Response[ModelsListResponse])
Expand Down

0 comments on commit 9a8e51a

Please sign in to comment.