All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
"""
|
||
app/routers/tools.py — Tool-Definitionen für Ollama/n8n/MCP (read-only)
|
||
|
||
Zweck:
|
||
Liefert Funktions-Schemas (OpenAI-/Ollama-kompatibles Tool-JSON) für:
|
||
- mindnet_query -> POST /query
|
||
- mindnet_subgraph-> GET /graph/{note_id}
|
||
Kompatibilität:
|
||
Python 3.12+, FastAPI 0.110+
|
||
Version:
|
||
0.1.0 (Erstanlage)
|
||
Stand:
|
||
2025-10-07
|
||
Nutzung:
|
||
app.include_router(tools.router, prefix="/tools", tags=["tools"])
|
||
Änderungsverlauf:
|
||
0.1.0 (2025-10-07) – Erstanlage.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
from fastapi import APIRouter
|
||
|
||
router = APIRouter()
|
||
|
||
TOOLS = {
|
||
"tools": [
|
||
{
|
||
"type": "function",
|
||
"function": {
|
||
"name": "mindnet_query",
|
||
"description": "Hybrid-Retrieval über mindnet (Semantik + Edges).",
|
||
"parameters": {
|
||
"type": "object",
|
||
"properties": {
|
||
"top_k": {"type":"integer","default":10,"minimum":1,"maximum":50},
|
||
"expand_depth": {"type":"integer","default":1,"minimum":0,"maximum":3},
|
||
"edge_types": {
|
||
"type":"array","items":{"type":"string"},
|
||
"default": ["references","belongs_to","prev","next"]
|
||
},
|
||
"query_vector": {
|
||
"type":"array","items":{"type":"number"},
|
||
"description":"384-dim Query-Vektor; (Text→Embedding kann später serverseitig erfolgen)."
|
||
},
|
||
"filters": {"type":"object","description":"payload-Filter (tags etc.)"}
|
||
},
|
||
"required": ["query_vector"]
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"type": "function",
|
||
"function": {
|
||
"name": "mindnet_subgraph",
|
||
"description": "Gibt die Nachbarschaft (Edges) einer Note/Seed-ID zurück.",
|
||
"parameters": {
|
||
"type":"object",
|
||
"properties": {
|
||
"note_id":{"type":"string"},
|
||
"depth":{"type":"integer","default":1,"minimum":0,"maximum":3},
|
||
"edge_types":{
|
||
"type":"array","items":{"type":"string"},
|
||
"default":["references","belongs_to","prev","next","backlink"]
|
||
}
|
||
},
|
||
"required":["note_id"]
|
||
}
|
||
}
|
||
}
|
||
]
|
||
}
|
||
|
||
@router.get("/ollama")
|
||
def get_ollama_tools():
|
||
return TOOLS
|