Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,7 @@ import torch
|
|
| 4 |
import uvicorn
|
| 5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 6 |
from fastapi_poe import PoeBot, make_app
|
| 7 |
-
from fastapi_poe.types import QueryRequest
|
| 8 |
-
from sse_starlette.sse import ServerSentEvent
|
| 9 |
|
| 10 |
# --- CONFIGURATION DU MODÈLE ---
|
| 11 |
MODEL_ID = "Finisha-F-scratch/Charlotte-amity"
|
|
@@ -52,20 +51,17 @@ class CharlottePoeBot(PoeBot):
|
|
| 52 |
full_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 53 |
response_text = full_text[len(last_message):].strip()
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
yield
|
| 57 |
|
| 58 |
# --- CREATION DE L'APPLICATION ---
|
| 59 |
bot = CharlottePoeBot()
|
| 60 |
-
# Correction ici : on enlève l'argument obsolète
|
| 61 |
app = make_app(bot)
|
| 62 |
|
| 63 |
# --- LANCEMENT DU SERVEUR ---
|
| 64 |
if __name__ == "__main__":
|
| 65 |
-
# Hugging Face impose le port 7860
|
| 66 |
port_to_use = int(os.environ.get("PORT", 7860))
|
| 67 |
print(f"--> Démarrage d'Uvicorn sur le port {port_to_use}...")
|
| 68 |
|
| 69 |
-
# On lance le serveur web sur l'adresse 0.0.0.0 pour qu'il soit accessible de l'extérieur
|
| 70 |
uvicorn.run(app, host="0.0.0.0", port=port_to_use)
|
| 71 |
|
|
|
|
| 4 |
import uvicorn
|
| 5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 6 |
from fastapi_poe import PoeBot, make_app
|
| 7 |
+
from fastapi_poe.types import QueryRequest, PartialResponse
|
|
|
|
| 8 |
|
| 9 |
# --- CONFIGURATION DU MODÈLE ---
|
| 10 |
MODEL_ID = "Finisha-F-scratch/Charlotte-amity"
|
|
|
|
| 51 |
full_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 52 |
response_text = full_text[len(last_message):].strip()
|
| 53 |
|
| 54 |
+
# CORRECTION : Utilisation du format natif PartialResponse de Poe
|
| 55 |
+
yield PartialResponse(text=response_text)
|
| 56 |
|
| 57 |
# --- CREATION DE L'APPLICATION ---
|
| 58 |
bot = CharlottePoeBot()
|
|
|
|
| 59 |
app = make_app(bot)
|
| 60 |
|
| 61 |
# --- LANCEMENT DU SERVEUR ---
|
| 62 |
if __name__ == "__main__":
|
|
|
|
| 63 |
port_to_use = int(os.environ.get("PORT", 7860))
|
| 64 |
print(f"--> Démarrage d'Uvicorn sur le port {port_to_use}...")
|
| 65 |
|
|
|
|
| 66 |
uvicorn.run(app, host="0.0.0.0", port=port_to_use)
|
| 67 |
|