Small changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# D&D Helpers Configuration
|
# D&D Helpers Configuration
|
||||||
OPENAI_API_KEY=no-key-required
|
OPENAI_API_KEY=no-key-required
|
||||||
OPENAI_BASE_URL=https://vllm.tipsy.codes/v1
|
OPENAI_BASE_URL=https://vllm.tipsy.codes/v1
|
||||||
LLM_MODEL=Intel/gemma-4-31B-it-int4-AutoRound
|
LLM_MODEL=google/gemma-4-26b-a4b-it
|
||||||
#LLM_BACKEND=ollama
|
#LLM_BACKEND=ollama
|
||||||
#LLM_MODEL=gemma:2b
|
#LLM_MODEL=gemma:2b
|
||||||
WHISPER_MODEL=base
|
WHISPER_MODEL=base
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class PipelineOrchestrator:
|
|||||||
self.clean_to_llm_queue = asyncio.Queue()
|
self.clean_to_llm_queue = asyncio.Queue()
|
||||||
self.llm_to_ui_queue = asyncio.Queue()
|
self.llm_to_ui_queue = asyncio.Queue()
|
||||||
self.log_queue = asyncio.Queue()
|
self.log_queue = asyncio.Queue()
|
||||||
|
self.persistence_queue = asyncio.Queue()
|
||||||
|
|
||||||
self.is_running = False
|
self.is_running = False
|
||||||
|
|
||||||
@@ -186,8 +187,11 @@ class PipelineOrchestrator:
|
|||||||
async def feed_ui():
|
async def feed_ui():
|
||||||
while self.is_running:
|
while self.is_running:
|
||||||
try:
|
try:
|
||||||
text = await self.ui_to_llm_queue.get()
|
item = await self.ui_to_llm_queue.get()
|
||||||
await internal_queue.put(("UI", text))
|
if isinstance(item, (LoreUpdate, CharacterStateUpdate)):
|
||||||
|
await self.persistence_queue.put(item)
|
||||||
|
else:
|
||||||
|
await internal_queue.put(("UI", item))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"LLM Feeder (UI) error: {e}")
|
logger.error(f"LLM Feeder (UI) error: {e}")
|
||||||
|
|
||||||
@@ -215,20 +219,8 @@ class PipelineOrchestrator:
|
|||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Persistence: Lore Updates
|
# Send the entire result to UI for confirmation
|
||||||
for lore_update in extraction_result.lore_updates:
|
await self.llm_to_ui_queue.put(extraction_result)
|
||||||
file_path = await asyncio.to_thread(update_lore, lore_update)
|
|
||||||
await asyncio.to_thread(self.rag_manager.ingest_file, file_path)
|
|
||||||
logger.info(
|
|
||||||
f"LLM Worker: Lore updated and ingested into RAG: {lore_update.entity_name}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Persistence: Character State Updates
|
|
||||||
for char_update in extraction_result.character_updates:
|
|
||||||
await asyncio.to_thread(update_character_state, char_update)
|
|
||||||
logger.info(
|
|
||||||
f"LLM Worker: Character {char_update.character_name} state updated."
|
|
||||||
)
|
|
||||||
|
|
||||||
# UI Notification: Context Updates
|
# UI Notification: Context Updates
|
||||||
for context_update in extraction_result.context_updates:
|
for context_update in extraction_result.context_updates:
|
||||||
@@ -245,29 +237,32 @@ class PipelineOrchestrator:
|
|||||||
for f in feeders:
|
for f in feeders:
|
||||||
f.cancel()
|
f.cancel()
|
||||||
|
|
||||||
def _get_wiki_context(self) -> str:
|
async def persistence_worker(self):
|
||||||
"""
|
"""
|
||||||
Reads all files in the lore directory and returns them as a 저희 context string.
|
Worker that handles persistence: Confirmed updates -> Disk & RAG.
|
||||||
"""
|
"""
|
||||||
from src.persistence.lore import DATA_LORE_DIR
|
logger.info("Persistence Worker started.")
|
||||||
|
while self.is_running:
|
||||||
wiki_contents = []
|
|
||||||
# Recursively find all .md files in the lore directory
|
|
||||||
for path in DATA_LORE_DIR.rglob("*.md"):
|
|
||||||
try:
|
try:
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
update = await self.persistence_queue.get()
|
||||||
content = f.read()
|
if isinstance(update, LoreUpdate):
|
||||||
wiki_contents.append(
|
file_path = await asyncio.to_thread(update_lore, update)
|
||||||
f"File: {path.relative_to(DATA_LORE_DIR)}\nContent:\n{content}"
|
await asyncio.to_thread(self.rag_manager.ingest_file, file_path)
|
||||||
|
logger.info(
|
||||||
|
f"Persistence Worker: Lore updated and ingested into RAG: {update.entity_name}"
|
||||||
|
)
|
||||||
|
elif isinstance(update, CharacterStateUpdate):
|
||||||
|
await asyncio.to_thread(update_character_state, update)
|
||||||
|
logger.info(
|
||||||
|
f"Persistence Worker: Character {update.character_name} state updated."
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error reading wiki file {path}: {e}")
|
|
||||||
|
|
||||||
return (
|
if hasattr(self.persistence_queue, "task_done"):
|
||||||
"\n\n".join(wiki_contents)
|
self.persistence_queue.task_done()
|
||||||
if wiki_contents
|
except Exception as e:
|
||||||
else "No wiki knowledge available."
|
logger.error(f"Persistence Worker error: {e}")
|
||||||
)
|
|
||||||
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
async def tui_worker(self):
|
async def tui_worker(self):
|
||||||
"""
|
"""
|
||||||
@@ -308,6 +303,7 @@ class PipelineOrchestrator:
|
|||||||
asyncio.create_task(self.stt_worker()),
|
asyncio.create_task(self.stt_worker()),
|
||||||
asyncio.create_task(self.clean_worker()),
|
asyncio.create_task(self.clean_worker()),
|
||||||
asyncio.create_task(self.llm_worker()),
|
asyncio.create_task(self.llm_worker()),
|
||||||
|
asyncio.create_task(self.persistence_worker()),
|
||||||
asyncio.create_task(self.tui_worker()),
|
asyncio.create_task(self.tui_worker()),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
+11
-10
@@ -213,12 +213,15 @@ class ConfirmationApp(App):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
update = await self.llm_to_ui_queue.get()
|
update = await self.llm_to_ui_queue.get()
|
||||||
display_text = f"Query: {update.query}\nSource: {update.source}\n\n{update.snippet}"
|
if isinstance(update, ExtractionResult):
|
||||||
context_list = self.query_one("#context-pane", ListView)
|
self.handle_proposal_result(update)
|
||||||
# ListView.insert takes an *iterable* of ListItems; passing a
|
elif isinstance(update, ContextUpdate):
|
||||||
# bare ListItem raises TypeError because ListItem is not iterable.
|
display_text = f"Query: {update.query}\nSource: {update.source}\n\n{update.snippet}"
|
||||||
# Insert at the top to show most recent first.
|
context_list = self.query_one("#context-pane", ListView)
|
||||||
await context_list.insert(0, [ListItem(Static(display_text))])
|
# ListView.insert takes an *iterable* of ListItems; passing a
|
||||||
|
# bare ListItem raises TypeError because ListItem is not iterable.
|
||||||
|
# Insert at the top to show most recent first.
|
||||||
|
await context_list.insert(0, [ListItem(Static(display_text))])
|
||||||
if hasattr(self.llm_to_ui_queue, "task_done"):
|
if hasattr(self.llm_to_ui_queue, "task_done"):
|
||||||
self.llm_to_ui_queue.task_done()
|
self.llm_to_ui_queue.task_done()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -270,10 +273,8 @@ class ConfirmationApp(App):
|
|||||||
return
|
return
|
||||||
|
|
||||||
update = self.pending_updates[row_index]
|
update = self.pending_updates[row_index]
|
||||||
if isinstance(update, LoreUpdate):
|
if self.ui_to_llm_queue:
|
||||||
await asyncio.to_thread(update_lore, update)
|
self.ui_to_llm_queue.put_nowait(update)
|
||||||
elif isinstance(update, CharacterStateUpdate):
|
|
||||||
await asyncio.to_thread(update_character_state, update)
|
|
||||||
|
|
||||||
self.remove_update(row_index)
|
self.remove_update(row_index)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user