From 4d0e0c90a7ba9048ec8b1595713854260a605694 Mon Sep 17 00:00:00 2001 From: zxq5 Date: Sun, 27 Jul 2025 23:23:47 +0100 Subject: [PATCH] minor changes --- project/context.json | 2 +- .../83592caa-f97d-427e-9d6a-50a586c30e6e.json | 10 ++++++---- .../deeaee92-bdec-4eb3-bb3b-ee760fc83d45.json | 17 +++++++++-------- .../69cf7e1d-96a1-4d2a-9f08-bd3386d4bc69.json | 10 +++++----- src/editors/content_editor.rs | 16 +++++++++------- src/editors/context_editor.rs | 4 ++-- src/llm_integration/content_llm.rs | 12 ++++++++++-- src/main.rs | 2 -- 8 files changed, 42 insertions(+), 31 deletions(-) diff --git a/project/context.json b/project/context.json index a5300ed..a4118fd 100644 --- a/project/context.json +++ b/project/context.json @@ -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": "" } \ No newline at end of file diff --git a/project/documents/83592caa-f97d-427e-9d6a-50a586c30e6e.json b/project/documents/83592caa-f97d-427e-9d6a-50a586c30e6e.json index 4c42bd2..627354d 100644 --- a/project/documents/83592caa-f97d-427e-9d6a-50a586c30e6e.json +++ b/project/documents/83592caa-f97d-427e-9d6a-50a586c30e6e.json @@ -1,8 +1,10 @@ { - "title": "test", + "title": "Example Chapter", "id": "83592caa-f97d-427e-9d6a-50a586c30e6e", - "description": "ee", - "tags": [], - "content": "# Test project\n\n- this project is a test to ensure that this tool can be integrated with AI models correctly\n- I’m testing various prompts and parameters to evaluate its capabilities. The initial focus is on simple tasks like list generation, text summarization, and question answering. More complex scenarios involving code generation and creative writing will follow in subsequent phases. A key aspect of this test project involves documenting all interactions – both the prompts used and the AI’s responses – for later analysis. This allows us to identify patterns, biases, and areas where the tool can be improved. \n\n- \nAs a large language model, I'm essentially the engine powering these tests. My role here is to receive the prompts generated by the tool and produce responses based on my training data and the instructions provided within those prompts. The beauty of this setup lies in my flexibility; I can adapt to different tasks – from condensing lengthy articles into concise summaries to generating lists based on specific criteria, or even answering questions drawn from a given text. My ability to understand nuances in language allows for more sophisticated interactions as the project progresses beyond these initial simple tasks. The detailed documentation you're creating is particularly valuable because it provides feedback that can potentially be used to refine my responses and improve overall performance – essentially closing a loop between testing, analysis, and future model iterations.", + "description": "idk", + "tags": [ + "b1d62e59-cc18-4ecb-921b-0a1ad89f7bea" + ], + "content": "# Chapter 1\n\nThe holographic projection shimmered above the polished mahogany table, displaying a complex network of troop movements and resource allocations across the Eurasian continent. Chancellor Marcus Beltaine steepled his fingers, the faint hum of his suit’s internal climate control system barely audible over the briefing. It was 2045, and the world had long since settled into its uneasy new order.\n\n“The Europa situation remains…stable,” General Petrov reported, his voice crisp and devoid of inflection. “Their agricultural output is down again this quarter due to ongoing soil degradation. They’re attempting a desperate pivot towards synthetic protein production, but initial reports are discouraging.” \n\nBeltaine nodded slowly, his gaze fixed on the swirling data streams representing Europa's failing infrastructure. \"And Asia?\" he prompted, without looking up. He knew the answer already; intelligence on the Eastern Empire was always grim, filtered through layers of encrypted channels and carefully vetted analysts. \n\n\"Their expansionist policies continue unabated,\" replied Director Chen, head of the Federation’s Intelligence Agency. “They've solidified control over the remnants of Siberia and are now focusing their attention on Central Asia. Their cyber warfare capabilities remain a significant threat, Chancellor.” She paused briefly, her expression unreadable beneath the cool lighting of the war room. \"We believe they are developing a new generation of autonomous drones.\" \n\nBeltaine finally raised his head, his eyes—a startling shade of glacial blue—locking onto Chen’s. “Autonomous drones,” he repeated, tasting the words. \"A predictable escalation.” He adjusted the American flag pin on his lapel, a subtle gesture that conveyed both authority and unwavering resolve. “Prepare a full analysis for my review by tomorrow morning. I want to understand their deployment strategy, their potential range, and any vulnerabilities we can exploit.\"“General,” Beltaine addressed his naval chief next, “what’s the status of Project Leviathan?”\n\nAdmiral Ito bowed slightly. \"The *USS Vigilance* and her sister ships are nearing completion, Chancellor. We're pushing the shipyards to their absolute limit. The new kinetic railgun technology is proving… challenging, but promising.” He projected a schematic of the massive warship onto the holographic display – a behemoth dwarfing any vessel built before the war. \"With these vessels, we maintain our dominance at sea and project power where necessary.\"\n\n“Necessary being defined as preventing Beijing from simply seizing Europa,” Chen added dryly. \n\nBeltaine nodded grimly. “Precisely. Europa's weakness is becoming a strategic liability for us all. We cannot allow them to collapse entirely. The fallout… the chaos…” He trailed off, needing no one to finish his sentence. \"What about resource allocation? Can we divert more materials toward bolstering their food production initiatives?”\n\n“It’s proving difficult,” Petrov responded. “Every ship built, every patrol deployed, draws resources away from internal reconstruction and humanitarian aid. Europa requires a sustained commitment; it's not something we can simply patch up with sporadic shipments.”\n\n\"We need to fundamentally rethink our approach,\" Beltaine stated, his voice low but firm. \"Europa is the only check on Beijing’s ambition. But pouring resources into their agricultural sector alone isn’t enough. They need long-term stability, and that requires rebuilding their technological base.\" He looked directly at Chen. “Director, I want a proposal for an internal program dedicated to digital infrastructure reconstruction – focusing specifically on secure communication networks and rudimentary data processing capabilities. We also need to prioritize the revival of semiconductor manufacturing, however primitive.”\n\nA murmur rippled through the room. The sheer audacity of his request was palpable. \n\nChen hesitated. \"Chancellor, with all due respect, our current capacity is…limited. The loss of TSMC was a catastrophic blow. We lack access to advanced lithography equipment. Replicating that capability within the Federation alone will take decades, even under ideal circumstances.”\n\n“I am aware of the limitations, Director,\" Beltaine said patiently. \"We start with what we have. Salvage anything usable from pre-war facilities. Encourage private initiative – offer incentives for anyone who can contribute to the effort. It won't be TSMC quality, but a functional chip is better than no chip at all. We need basic processors, memory modules... even if they’re built on outdated architectures.\" He paused, his gaze sweeping across the assembled faces. “This isn't just about Europa; it's about our own survival. A technologically stagnant Federation is a vulnerable Federation. We cannot afford to remain trapped in this post-war Dark Age.”", "parent": null } \ No newline at end of file diff --git a/project/objects/deeaee92-bdec-4eb3-bb3b-ee760fc83d45.json b/project/objects/deeaee92-bdec-4eb3-bb3b-ee760fc83d45.json index 66d86f7..4f5331c 100644 --- a/project/objects/deeaee92-bdec-4eb3-bb3b-ee760fc83d45.json +++ b/project/objects/deeaee92-bdec-4eb3-bb3b-ee760fc83d45.json @@ -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" ] } \ No newline at end of file diff --git a/project/templates/69cf7e1d-96a1-4d2a-9f08-bd3386d4bc69.json b/project/templates/69cf7e1d-96a1-4d2a-9f08-bd3386d4bc69.json index 18f8aaf..6b1a21d 100644 --- a/project/templates/69cf7e1d-96a1-4d2a-9f08-bd3386d4bc69.json +++ b/project/templates/69cf7e1d-96a1-4d2a-9f08-bd3386d4bc69.json @@ -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" } ] } \ No newline at end of file diff --git a/src/editors/content_editor.rs b/src/editors/content_editor.rs index cd333b3..958a7bf 100644 --- a/src/editors/content_editor.rs +++ b/src/editors/content_editor.rs @@ -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> { crate::llm_integration::content_llm::continue_content( if context_override.is_empty() { @@ -187,6 +188,7 @@ impl ContentAI { content, instruction, max_tokens, + project, ) } } diff --git a/src/editors/context_editor.rs b/src/editors/context_editor.rs index 7681066..a3cfc89 100644 --- a/src/editors/context_editor.rs +++ b/src/editors/context_editor.rs @@ -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)] diff --git a/src/llm_integration/content_llm.rs b/src/llm_integration/content_llm.rs index 80e1fe7..a16ff1d 100644 --- a/src/llm_integration/content_llm.rs +++ b/src/llm_integration/content_llm.rs @@ -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> { 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, temperature: f32, + max_tokens: usize, + stream: bool, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index 0142c8f..7a0cdf3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; } }); }