mirror of
https://github.com/katanemo/plano.git
synced 2026-06-20 15:28:07 +02:00
add more changes
This commit is contained in:
parent
9befd6364c
commit
2d4d0b01ee
4 changed files with 104 additions and 0 deletions
44
crates/hermesllm/src/providers/common_types.rs
Normal file
44
crates/hermesllm/src/providers/common_types.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct Message {
|
||||||
|
pub role: String,
|
||||||
|
pub content: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ChatRequestBase {
|
||||||
|
pub model: String,
|
||||||
|
pub messages: Option<Vec<Message>>,
|
||||||
|
pub temperature: Option<f32>,
|
||||||
|
pub top_p: Option<f32>,
|
||||||
|
pub n: Option<u32>,
|
||||||
|
pub max_tokens: Option<u32>,
|
||||||
|
pub stream: Option<bool>,
|
||||||
|
pub stop: Option<Vec<String>>,
|
||||||
|
pub presence_penalty: Option<f32>,
|
||||||
|
pub frequency_penalty: Option<f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct ChatResponseBase {
|
||||||
|
pub id: String,
|
||||||
|
pub object: String,
|
||||||
|
pub created: u64,
|
||||||
|
pub choices: Vec<Choice>,
|
||||||
|
pub usage: Option<Usage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct Choice {
|
||||||
|
pub index: u32,
|
||||||
|
pub message: Message,
|
||||||
|
pub finish_reason: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct Usage {
|
||||||
|
pub prompt_tokens: u32,
|
||||||
|
pub completion_tokens: u32,
|
||||||
|
pub total_tokens: u32,
|
||||||
|
}
|
||||||
27
crates/hermesllm/src/providers/deepseek/mod.rs
Normal file
27
crates/hermesllm/src/providers/deepseek/mod.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::providers::deepseek::types::{DeepSeekRequest, DeepSeekResponse};
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum DeepSeekError {
|
||||||
|
#[error("json error: {0}")]
|
||||||
|
JsonParseError(#[from] serde_json::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
type Result<T> = std::result::Result<T, DeepSeekError>;
|
||||||
|
|
||||||
|
impl TryFrom<&[u8]> for DeepSeekRequest {
|
||||||
|
type Error = DeepSeekError;
|
||||||
|
fn try_from(bytes: &[u8]) -> Result<Self> {
|
||||||
|
serde_json::from_slice(bytes).map_err(DeepSeekError::from)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&[u8]> for DeepSeekResponse {
|
||||||
|
type Error = DeepSeekError;
|
||||||
|
fn try_from(bytes: &[u8]) -> Result<Self> {
|
||||||
|
serde_json::from_slice(bytes).map_err(DeepSeekError::from)
|
||||||
|
}
|
||||||
|
}
|
||||||
17
crates/hermesllm/src/providers/deepseek/types.rs
Normal file
17
crates/hermesllm/src/providers/deepseek/types.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use crate::providers::common_types::{ChatRequestBase, ChatResponseBase};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct DeepSeekRequest {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub base: ChatRequestBase,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct DeepSeekResponse {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub base: ChatResponseBase,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-export for convenience
|
||||||
|
pub use crate::providers::common_types::{Message, Choice, Usage};
|
||||||
16
crates/hermesllm/src/providers/groq/types.rs
Normal file
16
crates/hermesllm/src/providers/groq/types.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use crate::providers::common_types::{ChatRequestBase, ChatResponseBase};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct GroqRequest {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub base: ChatRequestBase,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct GroqResponse {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub base: ChatResponseBase,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use crate::providers::common_types::{Message, Choice, Usage};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue