This commit is contained in:
killua 2025-06-20 10:41:59 +08:00
parent 53ac11f489
commit b1c2488162
42 changed files with 114 additions and 2 deletions

0
.gitignore vendored Normal file
View File

View File

@ -1,2 +0,0 @@
# ai_chat_architecture

11
main.py Normal file
View File

@ -0,0 +1,11 @@
# 主程序入口
from src.api.v1.router import v1_router
from fastapi import FastAPI
import uvicorn
app = FastAPI()
app.include_router(v1_router)
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8000)

0
requirements.txt Normal file
View File

0
scripts/deploy.sh Normal file
View File

0
scripts/run.sh Normal file
View File

0
src/api/__init__.py Normal file
View File

0
src/api/v1/__init__.py Normal file
View File

View File

@ -0,0 +1,37 @@
from fastapi import APIRouter
from src.services.memory.implement.memory_impl_1 import MemoryImpl1
from src.services.planner.implement.planner_impl1 import PlannerImpl1
chat_router = APIRouter(prefix='/chat')
@chat_router.get("/chat1")
async def chat1(user_msg: str):
# 记忆模块
memory_service = MemoryImpl1()
memory_service.search_memory_info(user_msg)
memory_service.update_memory_info(user_msg)
# 决策模块
planner_service = PlannerImpl1()
plan_result =planner_service.plan(user_msg)
if plan_result['action'] == "answer":
"调用llm_service"
pass
elif plan_result['action'] == "content":
"调用content_service"
pass
elif plan_result['action'] == "function":
"调用function_service"
pass
elif plan_result['action'] == "game":
"调用game_service"
pass
# 进一步返回结果
return {}
@chat_router.get("/chat2")
async def chat2():
pass

View File

@ -0,0 +1,13 @@
from fastapi import APIRouter
chat_router = APIRouter(prefix='/rtc')
@chat_router.get("/rtc1")
async def rtc1():
pass
@chat_router.get("/rtc2")
async def rtc2():
pass

View File

8
src/api/v1/router.py Normal file
View File

@ -0,0 +1,8 @@
from fastapi import APIRouter
from src.api.v1.endpoints.chat import chat_router
from src.api.v1.endpoints.rtc import rtc_router
v1_router = APIRouter(prefix='/api/v1')
v1_router.include_router(chat_router, prefix='/chat')
v1_router.include_router(rtc_router, prefix='/rtc')

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -0,0 +1 @@
## llm api

View File

View File

View File

@ -0,0 +1,12 @@
from src.services.memory.memory_service import MemoryService
class MemoryImpl1(MemoryService):
def __init__(self):
super().__init__()
def search_memory_info(self, user_msg):
pass
def update_memory_info(self, user_msg):
pass

View File

@ -0,0 +1,13 @@
from abc import ABC, abstractmethod
class MemoryService1(ABC):
def __init__(self):
pass
def search_memory_info(self, user_msg):
"""抽象方法,用于根据用户消息搜索记忆信息"""
pass
def update_memory_info(self, user_msg):
"""抽象方法,用于更新记忆信息"""
pass

View File

@ -0,0 +1,9 @@
from src.services.planner.planner_service import PlannerService
class PlannerImpl1(PlannerService):
def __init__(self):
super().__init__()
def plan(self, user_msg):
"实现具体的规划逻辑"
pass

View File

@ -0,0 +1,10 @@
from abc import ABC, abstractmethod
class PlannerService(ABC):
def __init__(self):
pass
@abstractmethod
def plan(self, user_msg):
"用于规划出用户的下一步行动"
pass