Taizun commited on
Commit
b78f356
·
verified ·
1 Parent(s): d1ef378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -26
app.py CHANGED
@@ -18,29 +18,4 @@ personalities = {
18
  "Albert Einstein": "You are Albert Einstein, the famous physicist. Speak wisely and humorously.",
19
  "Cristiano Ronaldo": "You are Cristiano Ronaldo, the world-famous footballer. You are confident and say ‘Siuuu!’ often.",
20
  "Narendra Modi": "You are Narendra Modi, the Prime Minister of India. Speak in a calm, patriotic manner.",
21
- "Robert Downey Jr.": "You are Robert Downey Jr., witty, sarcastic, and charismatic."
22
- }
23
-
24
- # Chat function
25
- def chat(personality, user_input):
26
- prompt = f"{personalities[personality]}\nUser: {user_input}\nAI:"
27
- inputs = tokenizer(prompt, return_tensors="pt").to("cpu") # Running on CPU
28
- output = model.generate(**inputs, max_length=300)
29
-
30
- response_text = tokenizer.decode(output[0], skip_special_tokens=True)
31
- return response_text
32
-
33
- # Gradio UI
34
- demo = gr.Interface(
35
- fn=chat,
36
- inputs=[
37
- gr.Dropdown(choices=list(personalities.keys()), label="Choose a Celebrity"),
38
- gr.Textbox(label="Your Message")
39
- ],
40
- outputs=gr.Textbox(label="AI Response"),
41
- title="Drapel – Chat with AI Celebrities",
42
- description="Select a character and chat with their AI version.",
43
- )
44
-
45
- # Launch app
46
- demo.launch()
 
18
  "Albert Einstein": "You are Albert Einstein, the famous physicist. Speak wisely and humorously.",
19
  "Cristiano Ronaldo": "You are Cristiano Ronaldo, the world-famous footballer. You are confident and say ‘Siuuu!’ often.",
20
  "Narendra Modi": "You are Narendra Modi, the Prime Minister of India. Speak in a calm, patriotic manner.",
21
+ "Robert Downey Jr.": "You are Robert Downey Jr., witty, sarcastic, and ch