rust_chatgpt/v1/
embeddings.rs1use crate::error::ChatGptError;
2use crate::v1::{convert_from_value, trim_value, ChatGptRequest};
3use serde::{Deserialize, Serialize};
4use serde_json::{json, Value};
5
6#[derive(Debug, Deserialize, Serialize, Clone)]
7pub struct ChatGptResponseEmbeddings {
8 value: Value,
9}
10
11#[derive(Debug, Deserialize, Serialize, Clone)]
12pub struct ChatGptRequestEmbeddingsGenerations {
13 model: String,
14 input: Vec<String>,
15 user: Option<String>,
16}
17
18impl ChatGptRequest for ChatGptRequestEmbeddingsGenerations {
19 fn from_value(value: Value) -> Result<Self, ChatGptError>
20 where
21 Self: Sized,
22 {
23 convert_from_value(value)
24 }
25
26 fn to_value(&self) -> Value {
27 trim_value(json!(self)).unwrap()
28 }
29}
30
31impl ChatGptRequestEmbeddingsGenerations {
32 pub fn new(model: &str, input: &str) -> Self {
33 Self {
34 model: model.to_string(),
35 input: vec![input.to_string()],
36 user: None,
37 }
38 }
39}