An-Egoistic-Developer-Full-Of-Knowledge commited on
Commit
0451733
·
verified ·
1 Parent(s): 3be0df1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load an open model that runs well on CPU
5
+ model_name = "google/flan-t5-base"
6
+ pipe = pipeline("text2text-generation", model=model_name)
7
+
8
+ def chat_with_jarvis(message, history):
9
+ prompt = f"You are Jarvis, a helpful AI assistant. Answer politely.\n\nUser: {message}\nJarvis:"
10
+ result = pipe(prompt, max_new_tokens=200, do_sample=True)[0]["generated_text"]
11
+ history.append((message, result))
12
+ return history, history
13
+
14
+ # Build Gradio Chat Interface
15
+ demo = gr.ChatInterface(
16
+ fn=chat_with_jarvis,
17
+ title="Jarvis AI (Free CPU Edition)",
18
+ description="A lightweight Jarvis that runs 24/7 for free on Hugging Face CPU.",
19
+ theme="soft",
20
+ )
21
+
22
+ demo.launch()