arohi-k commited on
Commit
f753875
·
verified ·
1 Parent(s): 16c55f3

started personality quiz

Browse files
Files changed (1) hide show
  1. app.py +56 -3
app.py CHANGED
@@ -1,7 +1,60 @@
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
  import gradio as gr
2
+ import random
3
 
4
+ def match_europe(scores):
5
+ a = scores.count("A")
6
+ b = scores.count("B")
7
+ c = scores.count("C")
8
+ if a >= 3:
9
+ return "Rome"
10
+ elif b >=3:
11
+ return "Paris"
12
+ elif c >= 3:
13
+ return "London"
14
+ else:
15
+ if a > b and a > c:
16
+ return "Rome"
17
+ elif b > a and b > c:
18
+ return "Paris"
19
+ elif c > a and c > b:
20
+ return "London"
21
+ else:
22
+ return "Rome"
23
  return "Hello " + name + "!!"
24
 
25
+
26
+
27
+
28
+
29
+
30
+ from huggingface_hub import InferenceClient
31
+
32
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
33
+ # change the LLM
34
+
35
+ def respond(message, history):
36
+
37
+ messages = [{"role": "system", "content": "You are extremely professional and smart that gives short replies."}]
38
+ # change the personality of the chatbot
39
+ if history:
40
+ messages.extend(history)
41
+
42
+ messages.append({"role" : "user", "content" : message})
43
+
44
+ response = ""
45
+ for message in client.chat_completion(
46
+ messages, max_tokens = 100, stream=True
47
+ #temperature= .1, top_p= 0.7)
48
+ # max tokens = change the length of the response
49
+ # temp = between 0-2
50
+ # top-p = between 0-1
51
+ ):
52
+ token = message.choices[0].delta.content
53
+ if token:
54
+ response += token
55
+ yield response
56
+
57
+ chatbot = gr.ChatInterface(respond, type = "messages")
58
+
59
+ chatbot.launch(debug=True)
60
+