rmi-backend/sdks/python/rugmunch_sdk/models.py
opencode c762564d40 style(rmi-backend): complete lint cleanup — 1175→0 ruff errors
- Fix 71 invalid-syntax files (class-body newline-broken assignments)
- Add from/None chain to 307 B904 raise-without-from sites
- Add B008 ignore to ruff.toml (already in pyproject.toml)
- Noqa F401 on __init__.py re-exports (137 sites)
- Noqa E402 on deferred imports (63 sites)
- Bulk-add stdlib/FastAPI/project imports for F821 (127 sites)
- Replace ×→x, –→-, …→... in docstrings (4093 chars)
- Manual refactor of 5 SIM103/SIM116 patterns

Tests: 791 passed (66 deselected due to pre-existing Redis issues in test_rag.py)
Co-authored-by: opencode <opencode@rugmunch.io>
2026-07-06 15:43:20 +02:00

56 lines
1.3 KiB
Python

"""RMI SDK - Response models (ergonomic, not raw API shapes)."""
from __future__ import annotations
from typing import Any
from pydantic import BaseModel, Field
class TokenRisk(BaseModel):
score: int = 0
tier: str = "low"
factors: list[str] = Field(default_factory=list)
token: dict | None = None
deployer_reputation: int | None = None
class Report(BaseModel):
report_id: str
subject_type: str
subject_id: str
risk_score: int
risk_tier: str
markdown: str
sections: dict[str, str] = Field(default_factory=dict)
class RagHit(BaseModel):
"""A RAG search hit. Maps from the API's `content` field to `text`."""
doc_id: str
score: float
text: str = ""
content: str = "" # alias
metadata: dict[str, Any] = Field(default_factory=dict)
def __init__(self, **data):
# Accept both `text` and `content` from the API
if "content" in data and "text" not in data:
data["text"] = data["content"]
super().__init__(**data)
class NewsItem(BaseModel):
news_id: str
title: str
source: str
published_at: str
summary: str = ""
sentiment_score: float | None = None
score: float | None = None
class McpTool(BaseModel):
name: str
description: str
input_schema: dict[str, Any] = Field(default_factory=dict)