topoteretes--cognee
c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
103 行
2.4 KiB
Python
103 行
2.4 KiB
Python
import time
|
|
import uuid
|
|
from typing import Any, Dict, List, Optional, Union
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from enum import Enum
|
|
|
|
from cognee.api.DTO import InDTO, OutDTO
|
|
|
|
|
|
class CogneeModel(str, Enum):
|
|
"""Enum for supported model types"""
|
|
|
|
COGNEEV1 = "cognee-v1"
|
|
|
|
|
|
class FunctionParameters(BaseModel):
|
|
"""JSON Schema for function parameters"""
|
|
|
|
type: str = "object"
|
|
properties: Dict[str, Dict[str, Any]]
|
|
required: Optional[List[str]] = None
|
|
|
|
|
|
class Function(BaseModel):
|
|
"""Function definition compatible with OpenAI's format"""
|
|
|
|
name: str
|
|
description: str
|
|
parameters: FunctionParameters
|
|
|
|
|
|
class ToolFunction(BaseModel):
|
|
"""Tool function wrapper (for OpenAI compatibility)"""
|
|
|
|
type: str = "function"
|
|
function: Function
|
|
|
|
|
|
class FunctionCall(BaseModel):
|
|
"""Function call made by the assistant"""
|
|
|
|
name: str
|
|
arguments: str
|
|
|
|
|
|
class ToolCall(BaseModel):
|
|
"""Tool call made by the assistant"""
|
|
|
|
id: str = Field(default_factory=lambda: f"call_{uuid.uuid4().hex}")
|
|
type: str = "function"
|
|
function: FunctionCall
|
|
|
|
|
|
class ChatUsage(BaseModel):
|
|
"""Token usage information"""
|
|
|
|
prompt_tokens: int = 0
|
|
completion_tokens: int = 0
|
|
total_tokens: int = 0
|
|
|
|
|
|
class ResponseRequest(InDTO):
|
|
"""Request body for the new responses endpoint (OpenAI Responses API format)"""
|
|
|
|
model: CogneeModel = CogneeModel.COGNEEV1
|
|
input: str
|
|
tools: Optional[List[ToolFunction]] = None
|
|
tool_choice: Optional[Union[str, Dict[str, Any]]] = "auto"
|
|
user: Optional[str] = None
|
|
temperature: Optional[float] = 1.0
|
|
max_completion_tokens: Optional[int] = None
|
|
|
|
|
|
class ToolCallOutput(BaseModel):
|
|
"""Output of a tool call in the responses API"""
|
|
|
|
status: str = "success" # success/error
|
|
data: Optional[Dict[str, Any]] = None
|
|
|
|
|
|
class ResponseToolCall(BaseModel):
|
|
"""Tool call in a response"""
|
|
|
|
id: str = Field(default_factory=lambda: f"call_{uuid.uuid4().hex}")
|
|
type: str = "function"
|
|
function: FunctionCall
|
|
output: Optional[ToolCallOutput] = None
|
|
|
|
|
|
class ResponseBody(OutDTO):
|
|
"""Response body for the new responses endpoint"""
|
|
|
|
id: str = Field(default_factory=lambda: f"resp_{uuid.uuid4().hex}")
|
|
created: int = Field(default_factory=lambda: int(time.time()))
|
|
model: str
|
|
object: str = "response"
|
|
status: str = "completed"
|
|
tool_calls: List[ResponseToolCall]
|
|
usage: Optional[ChatUsage] = None
|
|
metadata: Dict[str, Any] = None
|