|
|
--- |
|
|
title: Mistral-7B-API |
|
|
emoji: 🤖 |
|
|
colorFrom: indigo |
|
|
colorTo: purple |
|
|
sdk: gradio |
|
|
sdk_version: 5.30.0 |
|
|
app_file: app.py |
|
|
pinned: false |
|
|
license: mit |
|
|
--- |
|
|
|
|
|
# Mistral-7B API Server |
|
|
|
|
|
Questo Space fornisce un'API compatibile con OpenAI per il modello Mistral-7B-Instruct-v0.2. L'API è accessibile tramite l'endpoint `/v1/chat/completions`. |
|
|
|
|
|
## Caratteristiche |
|
|
- Versione quantizzata GGUF del modello Mistral-7B-Instruct-v0.2 |
|
|
- API compatibile con OpenAI |
|
|
- Interfaccia di test Gradio per verificare il funzionamento del modello |
|
|
|
|
|
## API Usage |
|
|
```python |
|
|
import requests |
|
|
import json |
|
|
|
|
|
headers = { |
|
|
"Content-Type": "application/json" |
|
|
} |
|
|
|
|
|
data = { |
|
|
"model": "mistral-7b-instruct", |
|
|
"messages": [ |
|
|
{"role": "user", "content": "Quali sono le principali città italiane?"} |
|
|
], |
|
|
"temperature": 0.7, |
|
|
"max_tokens": 1024 |
|
|
} |
|
|
|
|
|
response = requests.post( |
|
|
"https://huggingface.co/spaces/[username]/Mistral-7B-API/v1/chat/completions", |
|
|
headers=headers, |
|
|
json=data |
|
|
) |
|
|
|
|
|
print(json.dumps(response.json(), indent=2)) |
|
|
``` |