Spaces:
Running
Running
File size: 2,967 Bytes
a55ea57 2f1e7ff a55ea57 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | """Typed response envelopes for the public OpenAPI contract."""
from __future__ import annotations
from typing import Literal
from pydantic import BaseModel, ConfigDict, JsonValue, RootModel
from src.constants.data import KGChanges, Observation, StructuredData, TextChunk
from src.constants.embeddings import Vector
from src.constants.kg import Node, Predicate, Triple
class IngestionAcceptedResponse(BaseModel):
message: str
task_id: str
class LoginInfoResponse(BaseModel):
is_system_pat: bool
brain_id: str | None
class BrainLifecycleResponse(BaseModel):
success: bool
brain_id: str
operation: Literal["clear", "delete"]
existed: bool
cleared_backends: list[str]
class StringListResponse(RootModel[list[str]]):
pass
class FlatHopNode(BaseModel):
uuid: str
labels: list[str]
name: str
class FlatHopPredicate(BaseModel):
uuid: str
name: str
direction: str | None = None
HopNode = Node | FlatHopNode
HopPredicate = Predicate | FlatHopPredicate
SecondDegreeHop = tuple[
HopNode,
list[tuple[HopPredicate, HopNode, list[tuple[HopPredicate, HopNode]]]],
]
class HopListResponse(RootModel[list[SecondDegreeHop]]):
pass
class RelationshipListResponse(BaseModel):
message: str
relationships: list[Triple]
total: int
class EntityListResponse(BaseModel):
message: str
entities: list[Node]
total: int
class StructuredDataItemResponse(BaseModel):
message: str
data: StructuredData
class StructuredDataListResponse(BaseModel):
message: str
data: list[StructuredData]
count: int
total: int
class TypeListResponse(BaseModel):
message: str
types: list[str]
count: int
class TextChunkListResponse(BaseModel):
message: str
data: list[TextChunk]
total: int
class ObservationItemResponse(BaseModel):
message: str
observation: Observation
class ObservationListResponse(BaseModel):
message: str
observations: list[Observation]
count: int
class LabelListResponse(BaseModel):
message: str
labels: list[str]
count: int
class ChangelogItemResponse(BaseModel):
message: str
changelog: KGChanges
class ChangelogListResponse(BaseModel):
message: str
changelogs: list[KGChanges]
count: int
class VectorStoreInfo(BaseModel):
name: str
dimension: int
class VectorStoreListResponse(BaseModel):
stores: list[VectorStoreInfo]
class VectorListResponse(BaseModel):
message: str
store: str
vectors: list[Vector]
total: int
class TaskStateResponse(BaseModel):
"""Task payload with stable state fields and pipeline-specific extensions."""
model_config = ConfigDict(extra="allow")
task_id: str | None = None
id: str | None = None
status: str
stage: str | None = None
error: str | None = None
result: JsonValue | None = None
class TaskListResponse(BaseModel):
tasks: list[TaskStateResponse]
|