Leilaaaah commited on
Commit
8ced556
·
verified ·
1 Parent(s): d3972ba

aigenterativemodel/ adding huggingface model

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -1,10 +1,23 @@
1
  import gradio as gr
2
- import random
 
3
 
4
- def eightball(message,history):
5
- list=["yessir!","nah uh diva","aw heck no", "YUPPPP"]
6
- output=random.choice(list)
7
- return output
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- chatbot = gr.ChatInterface(eightball, type='messages', title= "brutal opinions", description="brutally honest opinions about you", theme='shivi/calm_seafoam')
10
  chatbot.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
4
 
5
+ def respond(message,history):
6
+ messages = [{"role":"system","content":"Your are friend chatbot"}]
7
+
8
+ if history:
9
+ messages.extend(history)
10
+
11
+ messages.append({"role":"user", "content": message})
12
+
13
+ response = client.chat_completion(
14
+ messages,
15
+ max_tokens=100
16
+ temperature=0.2
17
+ )
18
+
19
+ return response['choices'][0]['message']['content'].strip()
20
+
21
+ chatbot = gr.ChatInterface(eightball, type='messages')
22
 
 
23
  chatbot.launch()