Initial commit.

Basic docker deployment with Local LLM integration and simple game state.
This commit is contained in:
Aodhan Collins
2025-08-17 19:31:33 +01:00
commit 912b205699
30 changed files with 2476 additions and 0 deletions

79
conversation.py Normal file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""
Conversation history management for the LLM interaction system.
"""
class ConversationManager:
"""Manages conversation history between user and LLM."""
def __init__(self):
"""Initialize the conversation manager."""
self.history = []
def add_user_message(self, message):
"""Add a user message to the conversation history.
Args:
message (str): The user's message
"""
self.history.append({
"role": "user",
"content": message
})
def add_system_message(self, message):
"""Add a system message to the conversation history.
Args:
message (str): The system message
"""
self.history.append({
"role": "system",
"content": message
})
def add_assistant_message(self, message):
"""Add an assistant message to the conversation history.
Args:
message (str): The assistant's message
"""
self.history.append({
"role": "assistant",
"content": message
})
def get_history(self):
"""Get the complete conversation history.
Returns:
list: List of message dictionaries
"""
return self.history
def clear_history(self):
"""Clear the conversation history."""
self.history = []
def get_last_user_message(self):
"""Get the last user message from history.
Returns:
str: The last user message, or None if no user messages
"""
for message in reversed(self.history):
if message["role"] == "user":
return message["content"]
return None
def get_last_assistant_message(self):
"""Get the last assistant message from history.
Returns:
str: The last assistant message, or None if no assistant messages
"""
for message in reversed(self.history):
if message["role"] == "assistant":
return message["content"]
return None