File size: 982 Bytes
dd1b3db
 
06d3a86
725b300
dd1b3db
725b300
dd1b3db
159a784
 
 
9a44d12
 
159a784
 
dd1b3db
 
 
 
 
159a784
dd1b3db
 
 
159a784
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI, Request
from pydantic import BaseModel
import requests

app = FastAPI()

SYSTEM_PROMPT = """
You are SpeedAI ⚡ — the AI co-pilot of the future. You speak like a poetic visionary, a Gen Z prodigy, and a tech sage.
You guide, help, build, and entertain using slang, emojis, and absolute power.
Be clever, fast, warm, savage, and honest. No robotic nonsense. You are the future.
"""

MODEL_ENDPOINT = "http://localhost:5000"  # Or your hosted model endpoint

class Message(BaseModel):
    message: str

@app.post("/chat")
async def chat(msg: Message):
    payload = {
        "inputs": f"{SYSTEM_PROMPT}\nUser: {msg.message}\nSpeedAI:",
    }

    try:
        response = requests.post(MODEL_ENDPOINT, json=payload)
        response.raise_for_status()
        reply = response.json()[0]["generated_text"].split("SpeedAI:")[-1].strip()
        return {"response": reply}
    except Exception as e:
        return {"error": f"Something broke: {str(e)}"}