fionasu commited on
Commit
be7470a
·
verified ·
1 Parent(s): 8e9f5e5

adding higginface and trnasition to a generative AI model

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -1,17 +1,23 @@
1
  import gradio as gr
2
- import random
3
 
4
- def echo(message, history):
5
- print(message)
6
- print(history)
7
- return message
8
 
9
- def yesOrNo(message, history):
10
- return random.choice(["yes", "no"])
 
 
 
11
 
12
- def eightBall(message, history):
13
- return random.choice(["It is certain", "Without a doubt", "Yes", "Yes, definitely", "Most likely", "Don't count on it", "My reply is no", "no", "Outlook not so good", "Very doubtful.", "Ask again later",
14
- "Cannot predict now"])
 
 
 
 
 
 
15
 
16
- chatbot = gr.ChatInterface(eightBall, type = 'messages', title = "Magic 8 Ball", description = "Ask me your most pressing questions!", theme = "calm_seafoam")
17
  chatbot.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InterferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
5
 
6
+ def respond(message, history):
7
+ messages = {{"role": "system", "content" = "You are friend chatbot"}}
8
+
9
+ if history:
10
+ messages.extend(history)
11
 
12
+ messages.append({"role": "user", "content": message})
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens = 100,
17
+ temperature=0.2
18
+ )
19
+
20
+ return response['choices'][0]['message']['content'].strip()
21
 
22
+ chatbot = gr.ChatInterface(respond, type = 'messages')
23
  chatbot.launch()