Bhaddy392 commited on
Commit
592d703
·
verified ·
1 Parent(s): c128bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -22
app.py CHANGED
@@ -1,31 +1,13 @@
1
  import gradio as gr
2
- import subprocess
3
- import sys
4
-
5
- subprocess.check_call([sys.executable, "-m", "pip", "install", "transformers", "torch", "--quiet"])
6
-
7
  from transformers import pipeline
8
- import time
9
-
10
- time.sleep(10)
11
 
12
- pipe = pipeline("text-generation", model="microsoft/DialoGPT-small")
13
 
14
  def chat(message, history):
15
  if not message:
16
  return ""
17
 
18
- prompt = f"User: {message}\nAI Queen:"
19
- response = pipe(prompt, max_length=100, pad_token_id=50256)
20
- text = response[0]["generated_text"]
21
-
22
- if "AI Queen:" in text:
23
- text = text.split("AI Queen:")[-1].strip()
24
-
25
- return text
26
-
27
- with gr.Blocks(title="AI Queen") as demo:
28
- gr.Markdown("# AI Queen")
29
- gr.ChatInterface(fn=chat)
30
 
31
- demo.launch()
 
1
  import gradio as gr
 
 
 
 
 
2
  from transformers import pipeline
 
 
 
3
 
4
+ pipe = pipeline("text-generation", model="microsoft/DialoGPT-medium")
5
 
6
  def chat(message, history):
7
  if not message:
8
  return ""
9
 
10
+ response = pipe(message, max_length=100, pad_token_id=50256)
11
+ return response[0]["generated_text"]
 
 
 
 
 
 
 
 
 
 
12
 
13
+ gr.ChatInterface(fn=chat).launch()