mirror of
https://github.com/SilasMarvin/lsp-ai.git
synced 2025-12-18 06:54:28 +01:00
support api_endpoint for ollama
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1518,7 +1518,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lsp-ai"
|
||||
version = "0.1.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lsp-ai"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "LSP-AI is an open-source language server that serves as a backend for AI-powered functionality, designed to assist and empower software engineers, not replace them."
|
||||
|
||||
@@ -94,6 +94,8 @@ 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 model name
|
||||
pub model: String,
|
||||
// The maximum requests per second
|
||||
|
||||
@@ -66,8 +66,9 @@ 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 res: OllamaCompletionsResponse = client
|
||||
.post("http://localhost:11434/api/generate")
|
||||
.post(format!("{}/api/generate",api))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json")
|
||||
.json(&json!({
|
||||
@@ -100,8 +101,9 @@ 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 res: OllamaChatResponse = client
|
||||
.post("http://localhost:11434/api/chat")
|
||||
.post(format!("{}/api/chat",api))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json")
|
||||
.json(&json!({
|
||||
|
||||
Reference in New Issue
Block a user