Spaces:
Running
Running
Download app/models.py from 2Btainment/Fuugi-API: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/spaces/2Btainment/Fuugi-API/resolve/main/app/models.py
- Command line
-
hf download hf://spaces/2Btainment/Fuugi-API/app/models.py
-
curl -L -o models.py https://huggingface.co/spaces/2Btainment/Fuugi-API/resolve/main/app/models.py
1.94 kB
| from __future__ import annotations | |
| from typing import Literal | |
| from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator | |
| class ChatMessage(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| role: Literal["user", "assistant"] | |
| content: str = Field(min_length=1, max_length=8_000) | |
| def clean_content(cls, value: str) -> str: | |
| cleaned = value.strip() | |
| if not cleaned: | |
| raise ValueError("Message content cannot be blank.") | |
| return cleaned | |
| class FuugiRequest(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| companion: str = Field(default="fuugi", min_length=1, max_length=64) | |
| message: str = Field(default="", max_length=8_000) | |
| messages: list[ChatMessage] = Field(default_factory=list, max_length=50) | |
| site: str = Field(default="", max_length=512) | |
| locale: str = Field(default="de", max_length=32) | |
| def clean_string(cls, value: str) -> str: | |
| return value.strip() | |
| def require_user_message(self) -> FuugiRequest: | |
| if self.message: | |
| return self | |
| if self.messages and self.messages[-1].role == "user": | |
| return self | |
| raise ValueError("A user message is required.") | |
| class MemoryEvent(BaseModel): | |
| status: Literal["saved", "consent_required", "rejected", "unavailable"] | |
| id: str | None = None | |
| class FuugiResponse(BaseModel): | |
| content: str | |
| source: str | |
| model: str | |
| memory_event: MemoryEvent | None = None | |
| class MemoryConsentRequest(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| enabled: bool | |
| class MemoryItem(BaseModel): | |
| id: str | |
| content: str | |
| created_at: int | |
| expires_at: int | |
| class MemoryListResponse(BaseModel): | |
| enabled: bool | |
| memories: list[MemoryItem] | |