Skip to content

Commit

Permalink
Merge pull request #624 from dcSpark/nico/fix_overflow_tool_embedding
Browse files Browse the repository at this point in the history
fix overflow in embedding creation from chat
  • Loading branch information
nicarq authored Oct 23, 2024
2 parents f9cb7c3 + 15633a2 commit 10e4188
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion shinkai-libs/shinkai-lancedb/src/lance_db/ollama_embedding_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ impl OllamaEmbeddingFunction {
}
};

// Get the maximum token count for the model
let max_tokens = self.model_type.max_input_token_count();

// Truncate the prompt if it exceeds the maximum token count
let truncated_prompt = if prompt.len() > max_tokens {
&prompt[..max_tokens]
} else {
prompt
};

let request_body = serde_json::json!({
"model": model_str,
"prompt": prompt
"prompt": truncated_prompt // Use the truncated prompt
});

let full_url = if self.api_url.ends_with('/') {
Expand Down

0 comments on commit 10e4188

Please sign in to comment.