Fixed openai api endpoint
This commit is contained in:
Generated
-1
@@ -1191,7 +1191,6 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tower 0.4.13",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"urlencoding",
|
||||
|
||||
@@ -131,6 +131,14 @@ struct ChatMessage {
|
||||
struct ChatResponseFormat {
|
||||
#[serde(rename = "type")]
|
||||
kind: String,
|
||||
json_schema: JsonSchemaWrapper,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct JsonSchemaWrapper {
|
||||
name: String,
|
||||
strict: bool,
|
||||
schema: serde_json::Value,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -171,7 +179,30 @@ pub async fn call_ollama(
|
||||
content: user_message.to_owned(),
|
||||
},
|
||||
],
|
||||
response_format: ChatResponseFormat { kind: "json_object".to_owned() },
|
||||
response_format: ChatResponseFormat {
|
||||
kind: "json_schema".to_owned(),
|
||||
json_schema: JsonSchemaWrapper {
|
||||
name: "normalized_metadata".to_owned(),
|
||||
strict: true,
|
||||
schema: serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"artist": { "type": ["string", "null"] },
|
||||
"album": { "type": ["string", "null"] },
|
||||
"title": { "type": ["string", "null"] },
|
||||
"year": { "type": ["integer", "null"] },
|
||||
"track_number": { "type": ["integer", "null"] },
|
||||
"genre": { "type": ["string", "null"] },
|
||||
"featured_artists": { "type": "array", "items": { "type": "string" } },
|
||||
"release_type": { "type": ["string", "null"] },
|
||||
"confidence": { "type": ["number", "null"] },
|
||||
"notes": { "type": ["string", "null"] }
|
||||
},
|
||||
"required": ["artist", "album", "title", "year", "track_number", "genre", "featured_artists", "release_type", "confidence", "notes"],
|
||||
"additionalProperties": false
|
||||
}),
|
||||
},
|
||||
},
|
||||
stream: false,
|
||||
temperature: 0.1,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user