mirror of
https://github.com/SilasMarvin/lsp-ai.git
synced 2025-12-18 15:04:29 +01:00
suggested changes
This commit is contained in:
@@ -94,9 +94,9 @@ const fn n_ctx_default() -> u32 {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Ollama {
|
||||
// The completions endpoint
|
||||
pub completions_endpoint: Option<String>,
|
||||
// The chat endpoint
|
||||
// The generate endpoint, default: 'http://localhost:11434/api/generate'
|
||||
pub generate_endpoint: Option<String>,
|
||||
// The chat endpoint, default: 'http://localhost:11434/api/chat'
|
||||
pub chat_endpoint: Option<String>,
|
||||
// The model name
|
||||
pub model: String,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use anyhow::Context;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
@@ -68,11 +67,11 @@ impl Ollama {
|
||||
) -> anyhow::Result<String> {
|
||||
let client = reqwest::Client::new();
|
||||
let res: OllamaCompletionsResponse = client
|
||||
.post(
|
||||
self.configuration
|
||||
.completions_endpoint
|
||||
.as_ref()
|
||||
.context("specify `completions_endpoint` to use completions. Wanted to use `chat` instead? Please specify `chat_endpoint` and `messages`.")?,
|
||||
.post(self
|
||||
.configuration
|
||||
.generate_endpoint
|
||||
.as_ref()
|
||||
.unwrap_or(&"http://localhost:11434/api/generate".to_string())
|
||||
)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json")
|
||||
@@ -107,11 +106,11 @@ impl Ollama {
|
||||
) -> anyhow::Result<String> {
|
||||
let client = reqwest::Client::new();
|
||||
let res: OllamaChatResponse = client
|
||||
.post(
|
||||
self.configuration
|
||||
.chat_endpoint
|
||||
.as_ref()
|
||||
.context("must specify `chat_endpoint` to use chat")?,
|
||||
.post(self
|
||||
.configuration
|
||||
.chat_endpoint
|
||||
.as_ref()
|
||||
.unwrap_or(&"http://localhost:11434/api/chat".to_string())
|
||||
)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json")
|
||||
|
||||
Reference in New Issue
Block a user