Add dedicated API usage section (curl + Python) to BEDIENUNGSANLEITUNG.md
Consolidates and extends the curl patterns already scattered across other sections into one reference point, notes the API requires no auth (loopback- only), and points to the interactive /docs Swagger UI as the best starting point for exploring endpoints not yet covered here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
83fd13fb98
commit
e2fb113213
1 changed files with 64 additions and 2 deletions
|
|
@ -16,7 +16,8 @@ siehe [`CLAUDE.md`](CLAUDE.md).
|
|||
6. [Modelle und Provider verwalten](#6-modelle-und-provider-verwalten)
|
||||
7. [Dienste starten/stoppen](#7-dienste-startenstoppen)
|
||||
8. [Suche über Chunks (Search/Ask)](#8-suche-über-chunks-searchask)
|
||||
9. [Troubleshooting](#9-troubleshooting)
|
||||
9. [Die API in eigenen Programmen nutzen](#9-die-api-in-eigenen-programmen-nutzen)
|
||||
10. [Troubleshooting](#10-troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -265,7 +266,68 @@ weil nur die relevanten Chunks statt des ganzen Dokuments verarbeitet werden.
|
|||
|
||||
---
|
||||
|
||||
## 9. Troubleshooting
|
||||
## 9. Die API in eigenen Programmen nutzen
|
||||
|
||||
Die REST-API ist eine ganz normale JSON-über-HTTP-API **ohne Authentifizierung** — kein API-Key
|
||||
nötig, da nur `127.0.0.1` gebunden (jeder lokale Prozess auf diesem Rechner hat Zugriff, aber
|
||||
niemand aus dem Netzwerk). Funktioniert mit jeder Sprache, die HTTP kann.
|
||||
|
||||
**Bester Startpunkt:** `http://127.0.0.1:5055/docs` — interaktive Swagger-UI mit allen
|
||||
Endpunkten, Schemas und einer „Try it out"-Funktion zum direkten Ausprobieren im Browser.
|
||||
Rohes OpenAPI-Schema: `http://127.0.0.1:5055/openapi.json`.
|
||||
|
||||
### Mit curl
|
||||
|
||||
```bash
|
||||
# Notebooks auflisten
|
||||
curl -s http://127.0.0.1:5055/api/notebooks | python3 -m json.tool
|
||||
|
||||
# Neues Notebook anlegen
|
||||
curl -s -X POST http://127.0.0.1:5055/api/notebooks \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "Mein Notebook", "description": "..."}'
|
||||
|
||||
# Text-Quelle hinzufügen (multipart, nicht JSON)
|
||||
curl -s -X POST http://127.0.0.1:5055/api/sources \
|
||||
-F "type=text" -F "notebook_id=notebook:xxx" -F "title=..." \
|
||||
-F "content=..." -F "embed=true"
|
||||
|
||||
# Chat-Session erstellen + Nachricht senden
|
||||
curl -s -X POST http://127.0.0.1:5055/api/chat/sessions \
|
||||
-H "Content-Type: application/json" -d '{"notebook_id": "notebook:xxx"}'
|
||||
curl -s -X POST http://127.0.0.1:5055/api/chat/execute \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"session_id": "chat_session:xxx", "message": "...", "context": {}}'
|
||||
```
|
||||
|
||||
Weitere Beispiele (Quellen-Insights, Podcast-Generierung, Modell-/Provider-Verwaltung,
|
||||
Chunk-Suche) stehen bereits in den jeweiligen Abschnitten dieser Anleitung.
|
||||
|
||||
### Aus Python
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
BASE = "http://127.0.0.1:5055/api"
|
||||
|
||||
notebooks = requests.get(f"{BASE}/notebooks").json()
|
||||
|
||||
session = requests.post(f"{BASE}/chat/sessions",
|
||||
json={"notebook_id": notebooks[0]["id"]}).json()
|
||||
answer = requests.post(f"{BASE}/chat/execute", json={
|
||||
"session_id": session["id"],
|
||||
"message": "Wovon handelt das Buch?",
|
||||
"context": {},
|
||||
}).json()
|
||||
print(answer["messages"][-1]["content"])
|
||||
```
|
||||
|
||||
Genauso mit JavaScript (`fetch`), Go, oder jeder anderen Sprache — nichts Open-Notebook-
|
||||
Spezifisches nötig, kein SDK erforderlich.
|
||||
|
||||
---
|
||||
|
||||
## 10. Troubleshooting
|
||||
|
||||
### „Chat gibt keine Antwort" (leere Antwort, kein Fehler)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue