Littendekitten commited on
Commit
7e1c7fd
·
verified ·
1 Parent(s): 51685d8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ from fastapi import FastAPI
4
+ from fastapi.middleware.cors import CORSMiddleware
5
+ from pydantic import BaseModel
6
+ from transformers import pipeline
7
+
8
+ app = FastAPI()
9
+
10
+ # Zorgt ervoor dat je Netlify website veilig met deze cloud kan praten
11
+ app.add_middleware(
12
+ CORSMiddleware,
13
+ allow_origins=["*"],
14
+ allow_credentials=True,
15
+ allow_methods=["*"],
16
+ allow_headers=["*"],
17
+ )
18
+
19
+ print("Loading SpaceStar 0.01 core engine into cloud memory...")
20
+ # We gebruiken het supersnelle Qwen model als de motor achter SpaceStar 0.01
21
+ chat_engine = pipeline(
22
+ "text-generation",
23
+ model="Qwen/Qwen2.5-0.5B-Instruct"
24
+ )
25
+
26
+ class ChatRequest(BaseModel):
27
+ message: str
28
+
29
+ @app.post("/chat")
30
+ def chat_endpoint(request: ChatRequest):
31
+ messages = [
32
+ {
33
+ "role": "system",
34
+ "content": "You are Orbit, a brilliant, friendly, and helpful AI assistant powered by the SpaceStar 0.01 model, created by Littendekitten Studios. You love themes involving space, galaxies, stars, and cats. Keep your answers engaging and occasionally use cat or space emojis! Speak in the language the user speaks to you."
35
+ },
36
+ {"role": "user", "content": request.message}
37
+ ]
38
+ outputs = chat_engine(messages, max_new_tokens=150, temperature=0.7)
39
+ return {"reply": outputs[0]['generated_text'][-1]['content']}
40
+
41
+ @app.get("/")
42
+ def home():
43
+ return {"status": "Orbit (SpaceStar 0.01) Core Online 🪐"}