Add user authentication dependency to create_response endpoint

This commit is contained in:
Dmitrii Galkin 2025-05-03 13:55:04 +04:00
parent 683af24f9e
commit 76d1aee425

View file

@ -6,7 +6,7 @@ import logging
import uuid import uuid
from typing import Dict, List, Optional, Any from typing import Dict, List, Optional, Any
import openai import openai
from fastapi import APIRouter from fastapi import APIRouter, Depends
from cognee.api.v1.responses.models import ( from cognee.api.v1.responses.models import (
ResponseRequest, ResponseRequest,
ResponseResponse, ResponseResponse,
@ -18,6 +18,8 @@ from cognee.api.v1.responses.models import (
from cognee.api.v1.responses.dispatch_function import dispatch_function from cognee.api.v1.responses.dispatch_function import dispatch_function
from cognee.api.v1.responses.default_tools import DEFAULT_TOOLS from cognee.api.v1.responses.default_tools import DEFAULT_TOOLS
from cognee.infrastructure.llm.config import get_llm_config from cognee.infrastructure.llm.config import get_llm_config
from cognee.modules.users.models import User
from cognee.modules.users.methods import get_authenticated_user
def get_responses_router() -> APIRouter: def get_responses_router() -> APIRouter:
@ -69,6 +71,7 @@ def get_responses_router() -> APIRouter:
@router.post("/", response_model=ResponseResponse) @router.post("/", response_model=ResponseResponse)
async def create_response( async def create_response(
request: ResponseRequest, request: ResponseRequest,
user: User = Depends(get_authenticated_user),
) -> ResponseResponse: ) -> ResponseResponse:
""" """
OpenAI-compatible responses endpoint with function calling support OpenAI-compatible responses endpoint with function calling support