|
--- |
|
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. |
|
|
|
- 🔗 **Interfaccia Gradio**: [Apri l'interfaccia](https://huggingface.co/spaces/<username>/Mistral-7B-API/gradio) |
|
- 🧠 **Endpoint API**: `POST /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 |
|
|
|
## Esempio di utilizzo con `requests` |
|
```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)) |
|
``` |
|
|
|
## Esempio `cURL` |
|
```bash |
|
curl -X POST https://huggingface.co/spaces/<username>/Mistral-7B-API/v1/chat/completions \ |
|
-H "Content-Type: application/json" \ |
|
-d '{ |
|
"model": "mistral-7b-instruct", |
|
"messages": [{"role": "user", "content": "Spiegami la fotosintesi clorofilliana."}], |
|
"temperature": 0.7, |
|
"max_tokens": 1024 |
|
}' |
|
``` |
|
|
|
## Note |
|
- L'interfaccia Gradio è montata su `/gradio` per evitare conflitti con le risorse statiche dell'app. |
|
- L'API è compatibile con strumenti come Postman, cURL e client Python. |
|
|