seperate api endpoints configuration

This commit is contained in:
lux 2024-06-11 11:56:46 +08:00
parent f354834e9f
commit 3a351ff4a0
2 changed files with 6 additions and 4 deletions

View File

@ -94,8 +94,10 @@ const fn n_ctx_default() -> u32 {
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Ollama {
// api endpoint
pub api_endpoint: Option<String>,
// The completions endpoint, default: 'http://localhost:11434'
pub completions_endpoint: Option<String>,
// The chat endpoint, default: 'http://localhost:11434'
pub chat_endpoint: Option<String>,
// The model name
pub model: String,
// The maximum requests per second

View File

@ -66,7 +66,7 @@ impl Ollama {
params: OllamaRunParams,
) -> anyhow::Result<String> {
let client = reqwest::Client::new();
let api: &String = self.configuration.api_endpoint.as_ref().expect("http://localhost:11434");
let api: &String = self.configuration.completions_endpoint.as_ref().expect("http://localhost:11434");
let res: OllamaCompletionsResponse = client
.post(format!("{}/api/generate",api))
.header("Content-Type", "application/json")
@ -101,7 +101,7 @@ impl Ollama {
params: OllamaRunParams,
) -> anyhow::Result<String> {
let client = reqwest::Client::new();
let api: &String = self.configuration.api_endpoint.as_ref().expect("http://localhost:11434");
let api: &String = self.configuration.chat_endpoint.as_ref().expect("http://localhost:11434");
let res: OllamaChatResponse = client
.post(format!("{}/api/chat",api))
.header("Content-Type", "application/json")