1use json::JsonValue;
2use crate::chat::Chat;
3use crate::files::Files;
4use crate::models::Models;
5
6mod chat;
8mod images;
10mod models;
12mod files;
14#[derive(Clone, Debug)]
15pub struct OpenAi {
16 token: String,
17 model: String,
21}
22
23impl OpenAi {
24 pub fn new(token: &str, _user_id: &str, model: &str) -> Self {
25 Self {
26 token: token.to_string(),
27 model: model.parse().unwrap(),
29 }
30 }
31 pub fn chat(&mut self, history: JsonValue, prompt: &str, file: &str) -> Result<JsonValue, String> {
33 Chat::new(self.clone()).request(history, prompt, file).clone()
34 }
35 pub fn models(&mut self) -> Result<JsonValue, String> {
37 Models::new(self.clone()).request()
38 }
39 pub fn files(&mut self, path: String) -> Result<JsonValue, String> {
41 Files::new(self.clone()).request(path)
42 }
43}