lpetrov commited on
Commit
9e0e783
1 Parent(s): 13a59a2

Improve with LLM model

Browse files
Files changed (2) hide show
  1. .gitignore +2 -0
  2. app.py +24 -4
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .ipynb_checkpoints/
2
+ __pycache__
app.py CHANGED
@@ -1,7 +1,27 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
  import gradio as gr
3
 
4
+ model = pipeline("text-generation")
 
5
 
6
+
7
+ def predict(prompt):
8
+ completion = model(prompt)[0]["generated_text"]
9
+ return completion
10
+
11
+ title = "Ask Rick a Question"
12
+ description = """
13
+ The bot was trained to answer questions based on Rick and Morty dialogues. Ask Rick anything!
14
+ <img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
15
+ """
16
+
17
+ article = "Check out [the original Rick and Morty Bot](https://huggingface.co/spaces/kingabzpro/Rick_and_Morty_Bot) that this demo is based off of."
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs="textbox",
22
+ outputs="text",
23
+ title=title,
24
+ description=description,
25
+ article=article,
26
+ examples=[["What are you doing?"], ["Where should we time travel to?"]],
27
+ ).launch()