Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
src/opencode_api/routes/__pycache__/docs.cpython-312.pyc
CHANGED
|
Binary files a/src/opencode_api/routes/__pycache__/docs.cpython-312.pyc and b/src/opencode_api/routes/__pycache__/docs.cpython-312.pyc differ
|
|
|
src/opencode_api/routes/docs.py
CHANGED
|
@@ -1,14 +1,17 @@
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from typing import List, Dict, Any
|
|
|
|
| 3 |
|
| 4 |
router = APIRouter(prefix="/docs", tags=["Documentation"])
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 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
|
| 12 |
"description": "Most endpoints require this token for access."
|
| 13 |
},
|
| 14 |
"endpoints": [
|
|
@@ -24,21 +27,21 @@ API_INFO = {
|
|
| 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
|
| 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
|
| 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
|
| 42 |
},
|
| 43 |
{
|
| 44 |
"path": "/session/{session_id}/message",
|
|
@@ -50,35 +53,35 @@ API_INFO = {
|
|
| 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
|
| 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
|
| 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
|
| 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
|
| 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
|
| 82 |
}
|
| 83 |
]
|
| 84 |
}
|
|
@@ -87,4 +90,4 @@ API_INFO = {
|
|
| 87 |
@router.get("/")
|
| 88 |
async def get_api_docs():
|
| 89 |
"""Return a human-readable summary of the API."""
|
| 90 |
-
return
|
|
|
|
| 1 |
from fastapi import APIRouter
|
| 2 |
from typing import List, Dict, Any
|
| 3 |
+
from ..core.config import settings
|
| 4 |
|
| 5 |
router = APIRouter(prefix="/docs", tags=["Documentation"])
|
| 6 |
|
| 7 |
+
def get_api_info():
|
| 8 |
+
token = settings.token or "ACCESS2026"
|
| 9 |
+
return {
|
| 10 |
"title": "OpenCode API Documentation",
|
| 11 |
"description": "Human-readable summary of available endpoints, their jobs, and how to interact with them.",
|
| 12 |
"auth": {
|
| 13 |
"type": "Bearer Token",
|
| 14 |
+
"header": f"Authorization: Bearer {token}",
|
| 15 |
"description": "Most endpoints require this token for access."
|
| 16 |
},
|
| 17 |
"endpoints": [
|
|
|
|
| 27 |
"method": "GET",
|
| 28 |
"job": "List available LLM providers (e.g., blablador, openai, anthropic).",
|
| 29 |
"interaction": "Send GET request with Bearer token.",
|
| 30 |
+
"example": f"curl -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/provider"
|
| 31 |
},
|
| 32 |
{
|
| 33 |
"path": "/session",
|
| 34 |
"method": "POST",
|
| 35 |
"job": "Create a new chat session.",
|
| 36 |
"interaction": "Send POST request. Optional JSON body: {'title': 'My Session', 'model_id': 'alias-large'}.",
|
| 37 |
+
"example": f"curl -X POST -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/session"
|
| 38 |
},
|
| 39 |
{
|
| 40 |
"path": "/session",
|
| 41 |
"method": "GET",
|
| 42 |
"job": "List all active chat sessions.",
|
| 43 |
"interaction": "Send GET request with Bearer token.",
|
| 44 |
+
"example": f"curl -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/session"
|
| 45 |
},
|
| 46 |
{
|
| 47 |
"path": "/session/{session_id}/message",
|
|
|
|
| 53 |
"model_id": "Optional model ID (defaults to alias-large)",
|
| 54 |
"system": "Optional system prompt override"
|
| 55 |
},
|
| 56 |
+
"example": f"curl -X POST -H 'Authorization: Bearer {token}' -H 'Content-Type: application/json' -d '{{\"content\": \"Hi\"}}' https://auxteam-opencode-api.hf.space/session/{{id}}/message"
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"path": "/session/{session_id}/abort",
|
| 60 |
"method": "POST",
|
| 61 |
"job": "Cancel an ongoing message generation.",
|
| 62 |
"interaction": "Send POST request with Bearer token.",
|
| 63 |
+
"example": f"curl -X POST -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/session/{{id}}/abort"
|
| 64 |
},
|
| 65 |
{
|
| 66 |
"path": "/question",
|
| 67 |
"method": "GET",
|
| 68 |
"job": "List questions waiting for user input (used by QuestionTool).",
|
| 69 |
"interaction": "Send GET request. Returns list of pending question requests.",
|
| 70 |
+
"example": f"curl -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/question"
|
| 71 |
},
|
| 72 |
{
|
| 73 |
"path": "/question/{request_id}/reply",
|
| 74 |
"method": "POST",
|
| 75 |
"job": "Answer a pending question from the agent.",
|
| 76 |
"interaction": "Send POST request with JSON body: {'answers': [['Label1'], ['Label2']]}.",
|
| 77 |
+
"example": f"curl -X POST -H 'Authorization: Bearer {token}' -H 'Content-Type: application/json' -d '{{\"answers\": [[\"Yes\"]]}}' https://auxteam-opencode-api.hf.space/question/{{id}}/reply"
|
| 78 |
},
|
| 79 |
{
|
| 80 |
"path": "/agent",
|
| 81 |
"method": "GET",
|
| 82 |
"job": "List available agent configurations.",
|
| 83 |
"interaction": "Send GET request.",
|
| 84 |
+
"example": f"curl -H 'Authorization: Bearer {token}' https://auxteam-opencode-api.hf.space/agent"
|
| 85 |
}
|
| 86 |
]
|
| 87 |
}
|
|
|
|
| 90 |
@router.get("/")
|
| 91 |
async def get_api_docs():
|
| 92 |
"""Return a human-readable summary of the API."""
|
| 93 |
+
return get_api_info()
|