This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::editors::context_editor::ProjectContext;
|
||||
|
||||
pub fn continue_content(
|
||||
context: &str,
|
||||
previous_content: &str,
|
||||
instruction: &str,
|
||||
_max_tokens: usize,
|
||||
max_tokens: usize,
|
||||
project: &ProjectContext,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let client = reqwest::blocking::Client::new();
|
||||
|
||||
@@ -35,10 +38,12 @@ pub fn continue_content(
|
||||
let request = ChatRequest {
|
||||
messages,
|
||||
temperature: 0.7,
|
||||
max_tokens,
|
||||
stream: false,
|
||||
};
|
||||
|
||||
let response = client
|
||||
.post("http://localhost:1234/v1/chat/completions")
|
||||
.post(project.llm_api_uri.clone() + "/v1/chat/completions")
|
||||
.json(&request)
|
||||
.send()?;
|
||||
|
||||
@@ -54,11 +59,14 @@ pub fn continue_content(
|
||||
Err("No response from model".into())
|
||||
}
|
||||
}
|
||||
|
||||
// Simple request structure
|
||||
#[derive(Serialize)]
|
||||
struct ChatRequest {
|
||||
messages: Vec<Message>,
|
||||
temperature: f32,
|
||||
max_tokens: usize,
|
||||
stream: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user