|
|
|
@ -1,16 +1,31 @@
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
use crate::config::{ParamType, AI};
|
|
|
|
|
|
|
|
|
|
use anyhow::{Context, Result};
|
|
|
|
|
use flume::Sender;
|
|
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
|
use reqwest::Client;
|
|
|
|
|
use ron::Value as RonValue;
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use serde_json::Value;
|
|
|
|
|
|
|
|
|
|
static CLIENT: Lazy<Client> = Lazy::new(Client::new);
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize, Clone, PartialEq, Debug)]
|
|
|
|
|
pub struct AI {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub url: String,
|
|
|
|
|
pub params: HashMap<String, ParamType>,
|
|
|
|
|
pub retriever: Vec<RonValue>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize, Clone, PartialEq, Debug)]
|
|
|
|
|
pub enum ParamType {
|
|
|
|
|
String(String),
|
|
|
|
|
Prompt(Option<String>),
|
|
|
|
|
Temperature,
|
|
|
|
|
MaxTokens,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
|
|
|
pub struct Params {
|
|
|
|
|
pub prompt: String,
|
|
|
|
|