Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -30,12 +30,12 @@ POST /v1/messages
|
|
| 30 |
|
| 31 |
### Example Request
|
| 32 |
```bash
|
| 33 |
-
curl -X POST "https://YOUR_SPACE.hf.space/v1/messages" \
|
| 34 |
-H "Content-Type: application/json" \
|
| 35 |
-H "x-api-key: your-api-key" \
|
| 36 |
-H "anthropic-version: 2023-06-01" \
|
| 37 |
-d '{
|
| 38 |
-
"model": "
|
| 39 |
"max_tokens": 256,
|
| 40 |
"messages": [
|
| 41 |
{"role": "user", "content": "Hello, how are you?"}
|
|
@@ -45,10 +45,10 @@ curl -X POST "https://YOUR_SPACE.hf.space/v1/messages" \
|
|
| 45 |
|
| 46 |
### Streaming Example
|
| 47 |
```bash
|
| 48 |
-
curl -X POST "https://YOUR_SPACE.hf.space/v1/messages" \
|
| 49 |
-H "Content-Type: application/json" \
|
| 50 |
-d '{
|
| 51 |
-
"model": "
|
| 52 |
"max_tokens": 256,
|
| 53 |
"stream": true,
|
| 54 |
"messages": [
|
|
@@ -65,11 +65,11 @@ import anthropic
|
|
| 65 |
|
| 66 |
client = anthropic.Anthropic(
|
| 67 |
api_key="any-key",
|
| 68 |
-
base_url="https://YOUR_SPACE.hf.space"
|
| 69 |
)
|
| 70 |
|
| 71 |
message = client.messages.create(
|
| 72 |
-
model="
|
| 73 |
max_tokens=256,
|
| 74 |
messages=[{"role": "user", "content": "Hello!"}]
|
| 75 |
)
|
|
@@ -82,11 +82,11 @@ import Anthropic from '@anthropic-ai/sdk';
|
|
| 82 |
|
| 83 |
const client = new Anthropic({
|
| 84 |
apiKey: 'any-key',
|
| 85 |
-
baseURL: 'https://YOUR_SPACE.hf.space'
|
| 86 |
});
|
| 87 |
|
| 88 |
const message = await client.messages.create({
|
| 89 |
-
model: '
|
| 90 |
max_tokens: 256,
|
| 91 |
messages: [{ role: 'user', content: 'Hello!' }]
|
| 92 |
});
|
|
@@ -95,10 +95,10 @@ console.log(message.content[0].text);
|
|
| 95 |
|
| 96 |
## Model Info
|
| 97 |
|
| 98 |
-
- **Model**:
|
| 99 |
-
- **Parameters**:
|
| 100 |
-
- **Optimized for**:
|
| 101 |
-
- **Context Length**:
|
| 102 |
|
| 103 |
## Rate Limits
|
| 104 |
|
|
|
|
| 30 |
|
| 31 |
### Example Request
|
| 32 |
```bash
|
| 33 |
+
curl -X POST "https://YOUR_SPACE.hf.space/anthropic/v1/messages" \
|
| 34 |
-H "Content-Type: application/json" \
|
| 35 |
-H "x-api-key: your-api-key" \
|
| 36 |
-H "anthropic-version: 2023-06-01" \
|
| 37 |
-d '{
|
| 38 |
+
"model": "qwen2.5-coder-3b",
|
| 39 |
"max_tokens": 256,
|
| 40 |
"messages": [
|
| 41 |
{"role": "user", "content": "Hello, how are you?"}
|
|
|
|
| 45 |
|
| 46 |
### Streaming Example
|
| 47 |
```bash
|
| 48 |
+
curl -X POST "https://YOUR_SPACE.hf.space/anthropic/v1/messages" \
|
| 49 |
-H "Content-Type: application/json" \
|
| 50 |
-d '{
|
| 51 |
+
"model": "qwen2.5-coder-3b",
|
| 52 |
"max_tokens": 256,
|
| 53 |
"stream": true,
|
| 54 |
"messages": [
|
|
|
|
| 65 |
|
| 66 |
client = anthropic.Anthropic(
|
| 67 |
api_key="any-key",
|
| 68 |
+
base_url="https://YOUR_SPACE.hf.space/anthropic"
|
| 69 |
)
|
| 70 |
|
| 71 |
message = client.messages.create(
|
| 72 |
+
model="qwen2.5-coder-3b",
|
| 73 |
max_tokens=256,
|
| 74 |
messages=[{"role": "user", "content": "Hello!"}]
|
| 75 |
)
|
|
|
|
| 82 |
|
| 83 |
const client = new Anthropic({
|
| 84 |
apiKey: 'any-key',
|
| 85 |
+
baseURL: 'https://YOUR_SPACE.hf.space/anthropic'
|
| 86 |
});
|
| 87 |
|
| 88 |
const message = await client.messages.create({
|
| 89 |
+
model: 'qwen2.5-coder-3b',
|
| 90 |
max_tokens: 256,
|
| 91 |
messages: [{ role: 'user', content: 'Hello!' }]
|
| 92 |
});
|
|
|
|
| 95 |
|
| 96 |
## Model Info
|
| 97 |
|
| 98 |
+
- **Model**: Qwen/Qwen2.5-Coder-3B-Instruct
|
| 99 |
+
- **Parameters**: 3 Billion
|
| 100 |
+
- **Optimized for**: Code & Tool reasoning
|
| 101 |
+
- **Context Length**: 32K tokens
|
| 102 |
|
| 103 |
## Rate Limits
|
| 104 |
|
app.py
CHANGED
|
@@ -57,7 +57,7 @@ logger.info(f"Log file: {LOG_FILE}")
|
|
| 57 |
logger.info("=" * 60)
|
| 58 |
|
| 59 |
# ============== Configuration ==============
|
| 60 |
-
MODEL_ID = "
|
| 61 |
DEVICE = "cpu"
|
| 62 |
|
| 63 |
model = None
|
|
@@ -474,7 +474,7 @@ async def health():
|
|
| 474 |
async def openai_list_models():
|
| 475 |
"""List models (OpenAI format)"""
|
| 476 |
return OpenAIModelList(
|
| 477 |
-
data=[OpenAIModel(id="
|
| 478 |
)
|
| 479 |
|
| 480 |
@app.post("/v1/chat/completions")
|
|
@@ -625,11 +625,11 @@ async def anthropic_list_models():
|
|
| 625 |
return {
|
| 626 |
"object": "list",
|
| 627 |
"data": [{
|
| 628 |
-
"id": "
|
| 629 |
"object": "model",
|
| 630 |
"created": int(time.time()),
|
| 631 |
-
"owned_by": "
|
| 632 |
-
"display_name": "
|
| 633 |
"supports_thinking": True
|
| 634 |
}]
|
| 635 |
}
|
|
|
|
| 57 |
logger.info("=" * 60)
|
| 58 |
|
| 59 |
# ============== Configuration ==============
|
| 60 |
+
MODEL_ID = "Qwen/Qwen2.5-Coder-3B-Instruct"
|
| 61 |
DEVICE = "cpu"
|
| 62 |
|
| 63 |
model = None
|
|
|
|
| 474 |
async def openai_list_models():
|
| 475 |
"""List models (OpenAI format)"""
|
| 476 |
return OpenAIModelList(
|
| 477 |
+
data=[OpenAIModel(id="qwen2.5-coder-3b", created=int(time.time()), owned_by="qwen")]
|
| 478 |
)
|
| 479 |
|
| 480 |
@app.post("/v1/chat/completions")
|
|
|
|
| 625 |
return {
|
| 626 |
"object": "list",
|
| 627 |
"data": [{
|
| 628 |
+
"id": "qwen2.5-coder-3b",
|
| 629 |
"object": "model",
|
| 630 |
"created": int(time.time()),
|
| 631 |
+
"owned_by": "qwen",
|
| 632 |
+
"display_name": "Qwen2.5 Coder 3B Instruct",
|
| 633 |
"supports_thinking": True
|
| 634 |
}]
|
| 635 |
}
|