This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"project_author": "Your Name",
|
||||
"project_description": "Description of your project",
|
||||
"enable_ai": true,
|
||||
"llm_api_uri": "http://localhost:1234",
|
||||
"llm_api_uri": "http://192.168.1.218:1234",
|
||||
"llm_api_key": "",
|
||||
"ai_context_prompt": ""
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -4,22 +4,23 @@
|
||||
"name": "The Chancellor",
|
||||
"fields": {
|
||||
"age": {
|
||||
"Number": 37.0
|
||||
},
|
||||
"parent": {
|
||||
"Link": ""
|
||||
},
|
||||
"dob": {
|
||||
"Date": "1970-01-01"
|
||||
"Number": 50.0
|
||||
},
|
||||
"description": {
|
||||
"MultiLine": "a tall ahh american"
|
||||
"MultiLine": "Chancellor Marcus R Beltaine\n\npatriot turned authoritarian with a militaristic vision, and ambitions of global power"
|
||||
},
|
||||
"dob": {
|
||||
"Date": "1995-01-01"
|
||||
},
|
||||
"pfp": {
|
||||
"Image": "characters/the chancellor.jpg"
|
||||
},
|
||||
"parent": {
|
||||
"Link": ""
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"a9bb96a8-038b-4b2a-a325-f100fa112781",
|
||||
"bbeddabd-914c-4648-8262-bf14bfcf8fff"
|
||||
]
|
||||
}
|
||||
@@ -8,21 +8,21 @@
|
||||
"field_type": "MultiLine",
|
||||
"required": true,
|
||||
"on_preview": true,
|
||||
"description": "yes"
|
||||
"description": "description"
|
||||
},
|
||||
{
|
||||
"name": "age",
|
||||
"field_type": "Number",
|
||||
"required": true,
|
||||
"on_preview": false,
|
||||
"description": "yes"
|
||||
"description": "character's age in years"
|
||||
},
|
||||
{
|
||||
"name": "dob",
|
||||
"field_type": "Date",
|
||||
"required": true,
|
||||
"on_preview": false,
|
||||
"description": "yes"
|
||||
"description": "character's date of birth if known"
|
||||
},
|
||||
{
|
||||
"name": "parent",
|
||||
@@ -33,14 +33,14 @@
|
||||
},
|
||||
"required": true,
|
||||
"on_preview": false,
|
||||
"description": "yes"
|
||||
"description": "character's known parents"
|
||||
},
|
||||
{
|
||||
"name": "pfp",
|
||||
"field_type": "Image",
|
||||
"required": true,
|
||||
"on_preview": true,
|
||||
"description": "yes"
|
||||
"description": "portrait of the character"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -81,7 +81,7 @@ impl ContentAI {
|
||||
};
|
||||
|
||||
if is_open {
|
||||
egui::Window::new("ContentAI")
|
||||
egui::Window::new("AI Assistant")
|
||||
.open(&mut is_open)
|
||||
.show(ui.ctx(), |ui| match self {
|
||||
ContentAI::Summarise {
|
||||
@@ -92,7 +92,6 @@ impl ContentAI {
|
||||
} => {
|
||||
egui::ScrollArea::vertical()
|
||||
.auto_shrink([false, false])
|
||||
.max_height(200.0)
|
||||
.max_width(ui.available_width())
|
||||
.show(ui, |ui| {
|
||||
ui.add(
|
||||
@@ -123,21 +122,23 @@ impl ContentAI {
|
||||
ready,
|
||||
..
|
||||
} => {
|
||||
ui.label("Continue");
|
||||
ui.weak("(The model will see current file content)");
|
||||
ui.separator();
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(instruction)
|
||||
.frame(false)
|
||||
.hint_text("Instruction"),
|
||||
.hint_text("Writing Instructions"),
|
||||
);
|
||||
ui.separator();
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(context_override)
|
||||
.frame(false)
|
||||
.hint_text("Any additional context?"),
|
||||
);
|
||||
|
||||
ui.separator();
|
||||
ui.label("Max Tokens");
|
||||
ui.add(egui::Slider::new(max_tokens, 1000..=1000000));
|
||||
|
||||
ui.separator();
|
||||
if ui.button("Continue").clicked() {
|
||||
match Self::continue_content(
|
||||
instruction,
|
||||
@@ -176,7 +177,7 @@ impl ContentAI {
|
||||
max_tokens: usize,
|
||||
context_override: &str,
|
||||
project: &mut ProjectContext,
|
||||
content: &mut String,
|
||||
content: &mut str,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
crate::llm_integration::content_llm::continue_content(
|
||||
if context_override.is_empty() {
|
||||
@@ -187,6 +188,7 @@ impl ContentAI {
|
||||
content,
|
||||
instruction,
|
||||
max_tokens,
|
||||
project,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ pub struct ProjectContext {
|
||||
|
||||
// settings
|
||||
enable_ai: bool,
|
||||
llm_api_uri: String,
|
||||
llm_api_key: String,
|
||||
pub llm_api_uri: String,
|
||||
pub llm_api_key: String,
|
||||
pub ai_context_prompt: String,
|
||||
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -141,8 +141,6 @@ impl Interface {
|
||||
|
||||
if let Some(load_doc) = load_doc {
|
||||
self.editor = load_doc;
|
||||
self.editor.show_editor = true;
|
||||
self.editor.show_preview = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user