diff --git a/core/src/transformers/ollama.rs b/core/src/transformers/ollama.rs index a69b819..67cfe48 100644 --- a/core/src/transformers/ollama.rs +++ b/core/src/transformers/ollama.rs @@ -1,14 +1,7 @@ use anyhow::Result; -use ollama_rs::{ - generation::{completion::request::GenerationRequest, options::GenerationOptions}, - Ollama, -}; +use ollama_rs::{generation::completion::request::GenerationRequest, Ollama}; use url::Url; -use crate::transformers::openai::trim_inputs; -use crate::transformers::types::{EmbeddingPayload, EmbeddingRequest, Inputs}; -use crate::types; - pub struct OllamaInstance { pub model_name: String, pub instance: Ollama, @@ -16,12 +9,13 @@ pub struct OllamaInstance { pub trait LLMFunctions { fn new(model_name: String, url: String) -> Self; + #[allow(async_fn_in_trait)] async fn generate_reponse(&self, prompt_text: String) -> Result; } impl LLMFunctions for OllamaInstance { fn new(model_name: String, url: String) -> Self { - let parsed_url = Url::parse(&url).expect(format!("invalid url: {}", url).as_str()); + let parsed_url = Url::parse(&url).unwrap_or_else(|_| panic!("invalid url: {}", url)); let instance = Ollama::new( format!( "{}://{}", @@ -46,27 +40,6 @@ impl LLMFunctions for OllamaInstance { } } -pub fn prepare_ollama_embedding_request( - vect_meta: types::VectorizeMeta, - inputs: &[Inputs], - model_url: String, -) -> Result { - let text_inputs = trim_inputs(inputs); - let payload = EmbeddingPayload { - input: text_inputs, - model: vect_meta.transformer.to_string(), - }; - - // TBD - let _job_params: types::JobParams = serde_json::from_value(vect_meta.params)?; - - Ok(EmbeddingRequest { - url: model_url, - payload, - api_key: None, - }) -} - pub fn ollama_embedding_dim(model_name: &str) -> i32 { match model_name { "llama2" => 5192, diff --git a/core/src/worker/base.rs b/core/src/worker/base.rs index 16f5e49..e300809 100644 --- a/core/src/worker/base.rs +++ b/core/src/worker/base.rs @@ -1,4 +1,4 @@ -use crate::transformers::{generic, http_handler, ollama, openai}; +use crate::transformers::{generic, http_handler, openai}; use crate::types::{JobMessage, JobParams, ModelSource}; use crate::worker::ops; use anyhow::Result; diff --git a/extension/src/chat/ops.rs b/extension/src/chat/ops.rs index 798b6cb..216b3d4 100644 --- a/extension/src/chat/ops.rs +++ b/extension/src/chat/ops.rs @@ -31,7 +31,7 @@ pub fn call_chat( let job_params = serde_json::from_value::(project_meta.params.clone()) .unwrap_or_else(|e| error!("failed to deserialize job params: {}", e)); - // for various token count estimations + // for various token count estimations let bpe = match chat_model.source { ModelSource::Ollama => { // Using gpt-3.5-turbo tokenizer for Ollama since the library does not support llama2