-
Notifications
You must be signed in to change notification settings - Fork 493
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
For the chatcompletions route, Swagger UI throws errors for missing schemas:
Errors
Errors
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.grammar.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/Grammar does not exist in document
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.messages.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/Either does not exist in document
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.response_format.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/ResponseFormat does not exist in document
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.tool_choice.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/ToolChoice does not exist in document
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.tools.items.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/Tool does not exist in document
Resolver error at paths./v1/chat/completions.post.requestBody.content.application/json.schema.properties.web_search_options.$ref
Could not resolve reference: Could not resolve pointer: /components/schemas/WebSearchOptions does not exist in document
I started going down the path of adding those to the top level utoipa definition:
Example diff
diff --git a/mistralrs-server/src/main.rs b/mistralrs-server/src/main.rs
index f275d51ae..31bd33aa0 100644
--- a/mistralrs-server/src/main.rs
+++ b/mistralrs-server/src/main.rs
@@ -15,8 +15,8 @@ use mistralrs_core::{
SchedulerConfig, TokenSource,
};
use openai::{
- ChatCompletionRequest, CompletionRequest, ImageGenerationRequest, Message, ModelObjects,
- StopTokens,
+ ChatCompletionRequest, CompletionRequest, Grammar, ImageGenerationRequest,
+ JsonSchemaResponseFormat, Message, ModelObjects, ResponseFormat, StopTokens,
};
use serde::{Deserialize, Serialize};
use std::{num::NonZeroUsize, sync::Arc};
@@ -231,7 +231,7 @@ fn get_router(state: Arc<MistralRs>) -> Router {
#[openapi(
paths(models, health, chatcompletions),
components(
- schemas(ModelObjects, ModelObject, ChatCompletionRequest, CompletionRequest, ImageGenerationRequest, StopTokens, Message)),
+ schemas(ResponseFormat, JsonSchemaResponseFormat, Grammar, ModelObjects, ModelObject, ChatCompletionRequest, CompletionRequest, ImageGenerationRequest, StopTokens, Message)),
tags(
(name = "Mistral.rs", description = "Mistral.rs API")
),and that did help, but it only works for things that implement to_schema (so not mistralrs_core::WebSearchOptions, etc.) and also it seemed like maybe that wasn't the right way to go about it anyway (these should probably get pulled in by the existing schemas, right?).
Happy to dive into this more if you have any thoughts / tips.
Latest commit or version
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
