mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
fix deps for fastapi
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
"""FastAPI application for basic-memory knowledge graph API."""
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from loguru import logger
|
||||
|
||||
from .routers import knowledge
|
||||
from ..config import ProjectConfig
|
||||
|
||||
|
||||
# Initialize FastAPI app
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
"""FastAPI dependency functions."""
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Depends
|
||||
|
||||
from basic_memory.config import project_path
|
||||
from basic_memory.deps import get_project_services
|
||||
from basic_memory.services import MemoryService
|
||||
|
||||
MemoryServiceDep = Annotated[MemoryService, Depends(get_project_services(project_path))]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"""Router for knowledge graph operations."""
|
||||
from fastapi import APIRouter
|
||||
from typing import Annotated
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
|
||||
from basic_memory.api.deps import MemoryServiceDep
|
||||
from basic_memory.deps import MemoryServiceDep
|
||||
from basic_memory.schemas import (
|
||||
CreateEntitiesInput, CreateEntitiesResponse,
|
||||
SearchNodesInput, SearchNodesResponse,
|
||||
@@ -12,7 +13,6 @@ from basic_memory.schemas import (
|
||||
|
||||
router = APIRouter(prefix="/knowledge", tags=["knowledge"])
|
||||
|
||||
|
||||
@router.post("/entities", response_model=CreateEntitiesResponse)
|
||||
async def create_entities(
|
||||
data: CreateEntitiesInput,
|
||||
@@ -22,6 +22,7 @@ async def create_entities(
|
||||
entities = await memory_service.create_entities(data.entities)
|
||||
return CreateEntitiesResponse(entities=[EntityOut.model_validate(entity) for entity in entities])
|
||||
|
||||
|
||||
@router.get("/entities/{entity_id}", response_model=EntityOut)
|
||||
async def get_entity(
|
||||
entity_id: str,
|
||||
@@ -31,6 +32,7 @@ async def get_entity(
|
||||
entity = await memory_service.get_entity(entity_id)
|
||||
return EntityOut.model_validate(entity)
|
||||
|
||||
|
||||
@router.post("/relations", response_model=CreateRelationsResponse)
|
||||
async def create_relations(
|
||||
data: CreateRelationsInput,
|
||||
@@ -40,6 +42,7 @@ async def create_relations(
|
||||
relations = await memory_service.create_relations(data.relations)
|
||||
return CreateRelationsResponse(relations=[RelationOut.model_validate(relation) for relation in relations])
|
||||
|
||||
|
||||
@router.post("/observations", response_model=ObservationsOut)
|
||||
async def add_observations(
|
||||
data: ObservationsIn,
|
||||
|
||||
Reference in New Issue
Block a user