Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -912,6 +912,56 @@ async def anthropic_messages(
|
|
| 912 |
)
|
| 913 |
)
|
| 914 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 915 |
# ============================================================================
|
| 916 |
# Computer Use Agent (CUA) - Pydantic Models
|
| 917 |
# ============================================================================
|
|
@@ -1438,11 +1488,17 @@ async def root():
|
|
| 1438 |
"anthropic": "Messages API (2023-06-01)",
|
| 1439 |
"computer_use": "Anthropic Computer Use API compatible"
|
| 1440 |
},
|
| 1441 |
-
"
|
| 1442 |
-
"
|
| 1443 |
-
"
|
| 1444 |
"models": "/v1/models"
|
| 1445 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1446 |
"cua": {
|
| 1447 |
"base_url": "/cua/v1",
|
| 1448 |
"messages": "/cua/v1/messages",
|
|
|
|
| 912 |
)
|
| 913 |
)
|
| 914 |
|
| 915 |
+
# ============================================================================
|
| 916 |
+
# Anthropic Separate Base Path: /anthropic/v1/
|
| 917 |
+
# ============================================================================
|
| 918 |
+
|
| 919 |
+
@app.post("/anthropic/v1/messages")
|
| 920 |
+
async def anthropic_messages_separate(
|
| 921 |
+
request: AnthropicRequest,
|
| 922 |
+
authorization: Optional[str] = Header(None),
|
| 923 |
+
x_api_key: Optional[str] = Header(None, alias="x-api-key"),
|
| 924 |
+
anthropic_version: Optional[str] = Header(None, alias="anthropic-version"),
|
| 925 |
+
):
|
| 926 |
+
"""Anthropic endpoint with separate base path: /anthropic/v1/messages"""
|
| 927 |
+
return await anthropic_messages(request, authorization, x_api_key, anthropic_version)
|
| 928 |
+
|
| 929 |
+
|
| 930 |
+
@app.get("/anthropic/v1/models")
|
| 931 |
+
async def anthropic_list_models():
|
| 932 |
+
"""List Anthropic models"""
|
| 933 |
+
return {
|
| 934 |
+
"object": "list",
|
| 935 |
+
"data": [
|
| 936 |
+
{"id": "claude-3-opus-20240229", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 937 |
+
{"id": "claude-3-sonnet-20240229", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 938 |
+
{"id": "claude-3-haiku-20240307", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 939 |
+
{"id": "claude-3-5-sonnet-20241022", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 940 |
+
{"id": "claude-3-5-haiku-20241022", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 941 |
+
{"id": "claude-3-opus", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 942 |
+
{"id": "claude-3-sonnet", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 943 |
+
{"id": "claude-3-haiku", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 944 |
+
{"id": "claude-3-5-sonnet", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 945 |
+
{"id": "claude-code", "object": "model", "created": int(time.time()), "owned_by": "anthropic"},
|
| 946 |
+
]
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
@app.get("/anthropic")
|
| 951 |
+
async def anthropic_info():
|
| 952 |
+
"""Anthropic base endpoint info"""
|
| 953 |
+
return {
|
| 954 |
+
"name": "Anthropic Compatible API",
|
| 955 |
+
"version": ANTHROPIC_VERSION,
|
| 956 |
+
"base_url": "/anthropic/v1",
|
| 957 |
+
"endpoints": {
|
| 958 |
+
"messages": "/anthropic/v1/messages",
|
| 959 |
+
"models": "/anthropic/v1/models"
|
| 960 |
+
},
|
| 961 |
+
"features": ["prefill_response", "thinking", "streaming"]
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
+
|
| 965 |
# ============================================================================
|
| 966 |
# Computer Use Agent (CUA) - Pydantic Models
|
| 967 |
# ============================================================================
|
|
|
|
| 1488 |
"anthropic": "Messages API (2023-06-01)",
|
| 1489 |
"computer_use": "Anthropic Computer Use API compatible"
|
| 1490 |
},
|
| 1491 |
+
"openai": {
|
| 1492 |
+
"base_url": "/v1",
|
| 1493 |
+
"chat": "/v1/chat/completions",
|
| 1494 |
"models": "/v1/models"
|
| 1495 |
},
|
| 1496 |
+
"anthropic": {
|
| 1497 |
+
"base_url": "/anthropic/v1",
|
| 1498 |
+
"messages": "/anthropic/v1/messages",
|
| 1499 |
+
"models": "/anthropic/v1/models",
|
| 1500 |
+
"info": "/anthropic"
|
| 1501 |
+
},
|
| 1502 |
"cua": {
|
| 1503 |
"base_url": "/cua/v1",
|
| 1504 |
"messages": "/cua/v1/messages",
|