Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +5 -2
- src/opencode_api/core/__pycache__/config.cpython-312.pyc +0 -0
- src/opencode_api/routes/__init__.py +2 -1
- src/opencode_api/routes/__pycache__/__init__.cpython-312.pyc +0 -0
- src/opencode_api/routes/__pycache__/docs.cpython-312.pyc +0 -0
- src/opencode_api/routes/__pycache__/provider.cpython-312.pyc +0 -0
- src/opencode_api/routes/docs.py +90 -0
__pycache__/app.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
|
|
|
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from fastapi.responses import JSONResponse
|
|
| 4 |
from contextlib import asynccontextmanager
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
from src.opencode_api.routes import session_router, provider_router, event_router, question_router, agent_router
|
| 8 |
from src.opencode_api.provider import (
|
| 9 |
register_provider,
|
| 10 |
AnthropicProvider,
|
|
@@ -73,6 +73,7 @@ app.include_router(provider_router)
|
|
| 73 |
app.include_router(event_router)
|
| 74 |
app.include_router(question_router)
|
| 75 |
app.include_router(agent_router)
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
@app.get("/")
|
|
@@ -81,7 +82,9 @@ async def root():
|
|
| 81 |
"name": "OpenCode API",
|
| 82 |
"version": "0.1.0",
|
| 83 |
"status": "running",
|
| 84 |
-
"docs": "/docs",
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
|
|
|
|
| 4 |
from contextlib import asynccontextmanager
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
from src.opencode_api.routes import session_router, provider_router, event_router, question_router, agent_router, docs_router
|
| 8 |
from src.opencode_api.provider import (
|
| 9 |
register_provider,
|
| 10 |
AnthropicProvider,
|
|
|
|
| 73 |
app.include_router(event_router)
|
| 74 |
app.include_router(question_router)
|
| 75 |
app.include_router(agent_router)
|
| 76 |
+
app.include_router(docs_router)
|
| 77 |
|
| 78 |
|
| 79 |
@app.get("/")
|
|
|
|
| 82 |
"name": "OpenCode API",
|
| 83 |
"version": "0.1.0",
|
| 84 |
"status": "running",
|
| 85 |
+
"docs": "/api-docs",
|
| 86 |
+
"swagger": "/docs",
|
| 87 |
+
"redoc": "/redoc"
|
| 88 |
}
|
| 89 |
|
| 90 |
|
src/opencode_api/core/__pycache__/config.cpython-312.pyc
CHANGED
|
Binary files a/src/opencode_api/core/__pycache__/config.cpython-312.pyc and b/src/opencode_api/core/__pycache__/config.cpython-312.pyc differ
|
|
|
src/opencode_api/routes/__init__.py
CHANGED
|
@@ -3,5 +3,6 @@ from .provider import router as provider_router
|
|
| 3 |
from .event import router as event_router
|
| 4 |
from .question import router as question_router
|
| 5 |
from .agent import router as agent_router
|
|
|
|
| 6 |
|
| 7 |
-
__all__ = ["session_router", "provider_router", "event_router", "question_router", "agent_router"]
|
|
|
|
| 3 |
from .event import router as event_router
|
| 4 |
from .question import router as question_router
|
| 5 |
from .agent import router as agent_router
|
| 6 |
+
from .docs import router as docs_router
|
| 7 |
|
| 8 |
+
__all__ = ["session_router", "provider_router", "event_router", "question_router", "agent_router", "docs_router"]
|
src/opencode_api/routes/__pycache__/__init__.cpython-312.pyc
CHANGED
|
Binary files a/src/opencode_api/routes/__pycache__/__init__.cpython-312.pyc and b/src/opencode_api/routes/__pycache__/__init__.cpython-312.pyc differ
|
|
|
src/opencode_api/routes/__pycache__/docs.cpython-312.pyc
ADDED
|
Binary file (3.51 kB). View file
|
|
|
src/opencode_api/routes/__pycache__/provider.cpython-312.pyc
CHANGED
|
Binary files a/src/opencode_api/routes/__pycache__/provider.cpython-312.pyc and b/src/opencode_api/routes/__pycache__/provider.cpython-312.pyc differ
|
|
|
src/opencode_api/routes/docs.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter
|
| 2 |
+
from typing import List, Dict, Any
|
| 3 |
+
|
| 4 |
+
router = APIRouter(prefix="/api-docs", tags=["Documentation"])
|
| 5 |
+
|
| 6 |
+
API_INFO = {
|
| 7 |
+
"title": "OpenCode API Documentation",
|
| 8 |
+
"description": "Human-readable summary of available endpoints, their jobs, and how to interact with them.",
|
| 9 |
+
"auth": {
|
| 10 |
+
"type": "Bearer Token",
|
| 11 |
+
"header": "Authorization: Bearer ACCESS2026",
|
| 12 |
+
"description": "Most endpoints require this token for access."
|
| 13 |
+
},
|
| 14 |
+
"endpoints": [
|
| 15 |
+
{
|
| 16 |
+
"path": "/health",
|
| 17 |
+
"method": "GET",
|
| 18 |
+
"job": "Check system health and status.",
|
| 19 |
+
"interaction": "Send a GET request. No auth required.",
|
| 20 |
+
"example": "curl https://auxteam-opencode-api.hf.space/health"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"path": "/provider",
|
| 24 |
+
"method": "GET",
|
| 25 |
+
"job": "List available LLM providers (e.g., blablador, openai, anthropic).",
|
| 26 |
+
"interaction": "Send GET request with Bearer token.",
|
| 27 |
+
"example": "curl -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/provider"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "/session",
|
| 31 |
+
"method": "POST",
|
| 32 |
+
"job": "Create a new chat session.",
|
| 33 |
+
"interaction": "Send POST request. Optional JSON body: {'title': 'My Session', 'model_id': 'alias-large'}.",
|
| 34 |
+
"example": "curl -X POST -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/session"
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"path": "/session",
|
| 38 |
+
"method": "GET",
|
| 39 |
+
"job": "List all active chat sessions.",
|
| 40 |
+
"interaction": "Send GET request with Bearer token.",
|
| 41 |
+
"example": "curl -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/session"
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"path": "/session/{session_id}/message",
|
| 45 |
+
"method": "POST",
|
| 46 |
+
"job": "Send a message to the agent and receive a streaming response.",
|
| 47 |
+
"interaction": "Send POST request with JSON body. Returns Server-Sent Events (SSE).",
|
| 48 |
+
"payload": {
|
| 49 |
+
"content": "Message string (required)",
|
| 50 |
+
"model_id": "Optional model ID (defaults to alias-large)",
|
| 51 |
+
"system": "Optional system prompt override"
|
| 52 |
+
},
|
| 53 |
+
"example": "curl -X POST -H 'Authorization: Bearer ACCESS2026' -H 'Content-Type: application/json' -d '{\"content\": \"Hi\"}' https://auxteam-opencode-api.hf.space/session/{id}/message"
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"path": "/session/{session_id}/abort",
|
| 57 |
+
"method": "POST",
|
| 58 |
+
"job": "Cancel an ongoing message generation.",
|
| 59 |
+
"interaction": "Send POST request with Bearer token.",
|
| 60 |
+
"example": "curl -X POST -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/session/{id}/abort"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"path": "/question",
|
| 64 |
+
"method": "GET",
|
| 65 |
+
"job": "List questions waiting for user input (used by QuestionTool).",
|
| 66 |
+
"interaction": "Send GET request. Returns list of pending question requests.",
|
| 67 |
+
"example": "curl -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/question"
|
| 68 |
+
},
|
| 69 |
+
{
|
| 70 |
+
"path": "/question/{request_id}/reply",
|
| 71 |
+
"method": "POST",
|
| 72 |
+
"job": "Answer a pending question from the agent.",
|
| 73 |
+
"interaction": "Send POST request with JSON body: {'answers': [['Label1'], ['Label2']]}.",
|
| 74 |
+
"example": "curl -X POST -H 'Authorization: Bearer ACCESS2026' -H 'Content-Type: application/json' -d '{\"answers\": [[\"Yes\"]]}' https://auxteam-opencode-api.hf.space/question/{id}/reply"
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"path": "/agent",
|
| 78 |
+
"method": "GET",
|
| 79 |
+
"job": "List available agent configurations.",
|
| 80 |
+
"interaction": "Send GET request.",
|
| 81 |
+
"example": "curl -H 'Authorization: Bearer ACCESS2026' https://auxteam-opencode-api.hf.space/agent"
|
| 82 |
+
}
|
| 83 |
+
]
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
@router.get("")
|
| 87 |
+
@router.get("/")
|
| 88 |
+
async def get_api_docs():
|
| 89 |
+
"""Return a human-readable summary of the API."""
|
| 90 |
+
return API_INFO
|