- FastAPI backend with SQLite (ai.db) - Tables: skills, snippets, conventions, cache, memory - MCP servers: homelab, gameservers, skills - Docker Compose setup - Seed data with 8 skills, 2 conventions, 2 snippets - Token savings patterns via context bundles and caching
64 lines
2.1 KiB
Python
64 lines
2.1 KiB
Python
from sqlalchemy import Column, String, Text, DateTime, Boolean, Integer, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from database import Base
|
|
|
|
|
|
class Skill(Base):
|
|
__tablename__ = "skills"
|
|
|
|
id = Column(String, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
description = Column(Text)
|
|
category = Column(String)
|
|
content = Column(Text, nullable=False)
|
|
tags = Column(String)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
usage_count = Column(Integer, default=0)
|
|
|
|
|
|
class Snippet(Base):
|
|
__tablename__ = "snippets"
|
|
|
|
id = Column(String, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
language = Column(String)
|
|
content = Column(Text, nullable=False)
|
|
category = Column(String)
|
|
tags = Column(String)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class Convention(Base):
|
|
__tablename__ = "conventions"
|
|
|
|
id = Column(String, primary_key=True)
|
|
project_path = Column(String)
|
|
name = Column(String, nullable=False)
|
|
content = Column(Text, nullable=False)
|
|
auto_inject = Column(Boolean, default=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
|
|
class Cache(Base):
|
|
__tablename__ = "cache"
|
|
|
|
hash = Column(String, primary_key=True)
|
|
response = Column(Text, nullable=False)
|
|
model = Column(String)
|
|
tokens_in = Column(Integer)
|
|
tokens_out = Column(Integer)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
expires_at = Column(DateTime(timezone=True))
|
|
|
|
|
|
class Memory(Base):
|
|
__tablename__ = "memory"
|
|
|
|
id = Column(String, primary_key=True)
|
|
project = Column(String, nullable=False)
|
|
key = Column(String, nullable=False)
|
|
content = Column(Text, nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|