use json::JsonValue;
use crate::chat::Chat;
use crate::images::Images;
mod chat;
mod images;
#[derive(Clone, Debug)]
pub struct OpenAi {
token: String,
user_id: String,
model: Model,
}
impl OpenAi {
pub fn new(token: &str, user_id: &str) -> Self {
Self {
token: token.to_string(),
user_id: user_id.to_string(),
model:Model::Gbt35Turbo,
}
}
pub fn model(&mut self, model: Model) -> &mut Self {
self.model = model;
self
}
pub fn chat(&mut self, prompt: &str) -> Result<JsonValue, String> {
Chat::new(self.clone()).request(prompt).clone()
}
}
#[derive(Clone, Debug)]
pub enum Model {
Gbt35Turbo,
Gbt4,
Gpt35Turbo0613,
Gpt35Turbo16K0613,
}
impl Model {
pub fn info(self) -> &'static str {
match self {
Model::Gbt35Turbo => "gpt-3.5-turbo",
Model::Gbt4 => "gpt-4",
Model::Gpt35Turbo0613 => "gpt-3.5-turbo-0613",
Model::Gpt35Turbo16K0613 => "gpt-3.5-turbo-16k-0613"
}
}
}