Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions routers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,52 +207,6 @@ async def clear_chat_history(game: str):
raise HTTPException(status_code=500, detail=str(e))


@router.get("/history/{game}/stats")
async def get_chat_stats(game: str):
"""
Get statistics about chat history for a game

Example: GET /chat/history/minecraft/stats
"""
try:
stats = chat_history_manager.get_stats(game)
return {
"game": game,
"stats": stats
}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))


@router.get("/history/games")
async def list_games_with_history():
"""
List all games that have chat history

Example: GET /chat/history/games
"""
try:
collections = chat_history_manager.client.list_collections()

games_with_history = []
for collection in collections:
if collection.name.endswith("_chat_history"):
game_name = collection.name.replace("_chat_history", "").replace("_", " ").title()
stats = chat_history_manager.get_stats(game_name)
games_with_history.append({
"game": game_name,
"collection_name": collection.name,
"total_messages": stats.get("total_messages", 0)
})

return {
"games": games_with_history,
"total_games": len(games_with_history)
}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))


@router.post("/settings/history")
async def update_history_settings(max_history: int):
"""
Expand Down
12 changes: 6 additions & 6 deletions routers/game_detection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from services.game_detection import detect_current_game, get_available_games as get_detection_games
from services.knowledge_manager import get_available_games as get_csv_games, validate_csv_structure
from services.vector_service import add_game_knowledge, search_knowledge, get_game_stats, list_available_games
from services.vector_service import vector_service
from schemas.game_detection import GameDetectionRequest
from schemas.knowledge_search import KnowledgeSearchRequest
from fastapi import APIRouter,HTTPException
Expand All @@ -26,7 +26,7 @@ def list_games():
try:
detection_games = get_detection_games()
csv_games = get_csv_games()
vector_games = list_available_games()
vector_games = vector_service.list_available_games()

return {
"status": "ok",
Expand All @@ -48,9 +48,9 @@ def process_game_knowledge(game_name: str):
raise HTTPException(status_code=400, detail=f"Invalid CSV structure: {errors}")

# Process and add to vector database
success = add_game_knowledge(game_name)
success = vector_service.add_game_knowledge(game_name)
if success:
stats = get_game_stats(game_name)
stats = vector_service.get_game_stats(game_name)
return {
"status": "ok",
"message": f"Successfully processed knowledge for {game_name}",
Expand All @@ -67,7 +67,7 @@ def process_game_knowledge(game_name: str):
def search_game_knowledge(game_name: str, request: KnowledgeSearchRequest):
"""Search knowledge base for a specific game."""
try:
results = search_knowledge(
results = vector_service.search_knowledge(
game_name=game_name,
query=request.query,
content_types=request.content_types,
Expand All @@ -88,7 +88,7 @@ def search_game_knowledge(game_name: str, request: KnowledgeSearchRequest):
def get_game_knowledge_stats(game_name: str):
"""Get statistics for a game's knowledge base."""
try:
stats = get_game_stats(game_name)
stats = vector_service.get_game_stats(game_name)
return {
"status": "ok",
"game_name": game_name,
Expand Down
4 changes: 2 additions & 2 deletions services/chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dotenv import load_dotenv
from services.screenshot import get_recent_screenshots, get_screenshot_by_id, get_screenshot_stats
from services.game_detection import detect_current_game
from services.vector_service import search_knowledge
from services import vector_service
import base64

system_prompt_file = open("PROMPTS.txt","r")
Expand Down Expand Up @@ -92,7 +92,7 @@ async def chat_with_gemini(message: str, image_data: str = None):

# Search for relevant knowledge
try:
knowledge_results = search_knowledge(detected_game, message)
knowledge_results = vector_service.search_knowledge(detected_game, message)

if knowledge_results:
knowledge_context = "\n\nRELEVANT KNOWLEDGE FROM GAME DATABASE:\n"
Expand Down
18 changes: 0 additions & 18 deletions services/vector_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,3 @@ def list_available_games(self) -> List[str]:

# Global instance
vector_service = VectorService()

def add_game_knowledge(game_name: str) -> bool:
"""Add all knowledge for a game to the vector database."""
return vector_service.add_game_knowledge(game_name)

def search_knowledge(game_name: str, query: str, content_types: List[str] = None,
limit: int = 5) -> List[Dict]:
"""Search knowledge base for relevant information."""
return vector_service.search_knowledge(game_name, query, content_types, limit)

def get_game_stats(game_name: str) -> Dict[str, int]:
"""Get statistics for a game's knowledge base."""
return vector_service.get_game_stats(game_name)

def list_available_games() -> List[str]:
"""List all games with knowledge in the vector database."""
return vector_service.list_available_games()

Loading