feat: prepare log chat
This commit is contained in:
Generated
+3
-2
@@ -2510,9 +2510,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.52.2"
|
||||
version = "1.52.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "110a78583f19d5cdb2c5ccf321d1290344e71313c6c37d43520d386027d18386"
|
||||
checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
@@ -2775,6 +2775,7 @@ dependencies = [
|
||||
"quote",
|
||||
"regex",
|
||||
"syn",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@ edition = "2024"
|
||||
|
||||
[dev-dependencies]
|
||||
wiremock = "0.6"
|
||||
tokio = { version = "1.52.2", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
|
||||
|
||||
[dependencies]
|
||||
axum = "0.8.9"
|
||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||
utoipa = { version = "5.5.0", features = ["axum_extras", "uuid"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod api_key;
|
||||
pub mod pool;
|
||||
pub mod user_repository;
|
||||
pub mod user;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize, ToSchema)]
|
||||
pub struct ErrorResponse {
|
||||
@@ -87,6 +88,7 @@ pub enum FinishReason {
|
||||
Length,
|
||||
ContentFilter,
|
||||
ToolCalls,
|
||||
Error,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
@@ -126,6 +128,9 @@ pub struct ChatRequest {
|
||||
pub base: BaseLLMRequest,
|
||||
|
||||
pub messages: Vec<Message>,
|
||||
|
||||
// Non standard Open AI
|
||||
pub conversation_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, ToSchema)]
|
||||
|
||||
@@ -5,9 +5,7 @@ use axum::{
|
||||
response::{IntoResponse, Response},
|
||||
};
|
||||
|
||||
use crate::databases::postgres::{
|
||||
api_key::update_last_access, user_repository::ensure_user_exists,
|
||||
};
|
||||
use crate::databases::postgres::{api_key::update_last_access, user::ensure_user_exists};
|
||||
use crate::middlewares::auth::apikey::{ApiKeyClaims, ApiKeyClaimsRoles};
|
||||
use crate::middlewares::auth::keycloak::{KeycloakClaims, get_jwks, refresh_jwks, validate_token};
|
||||
use crate::state::app_state::AppState;
|
||||
|
||||
@@ -183,6 +183,7 @@ async fn test_chat_completions_ok() {
|
||||
role: api::Role::User,
|
||||
content: "What is 2+2?".to_string(),
|
||||
}],
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let res = provider.chat_completions(&req).await.unwrap();
|
||||
@@ -217,6 +218,7 @@ async fn test_chat_completions_missing_messages() {
|
||||
..Default::default()
|
||||
},
|
||||
messages: vec![],
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let err = provider.chat_completions(&req).await.unwrap_err();
|
||||
@@ -243,6 +245,7 @@ async fn test_chat_completions_no_user_message() {
|
||||
role: api::Role::System,
|
||||
content: "be helpful".to_string(),
|
||||
}],
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let err = provider.chat_completions(&req).await.unwrap_err();
|
||||
@@ -269,6 +272,7 @@ async fn test_chat_completions_model_not_found() {
|
||||
role: api::Role::User,
|
||||
content: "hi".to_string(),
|
||||
}],
|
||||
conversation_id: None,
|
||||
};
|
||||
|
||||
let err = provider.chat_completions(&req).await.unwrap_err();
|
||||
|
||||
Reference in New Issue
Block a user