pragyarama commited on
Commit
5eafd0c
·
verified ·
1 Parent(s): ae54023

transitionaing to gen ai model

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -1,26 +1,23 @@
1
- import random
2
  import gradio as gr
 
3
 
4
- def echo(message, history):
5
- print(message)
6
- print(history)
7
- return message
8
 
9
- def eight_ball(message, history):
10
- affirmative_messages=["it is certain", "it is decidedly so", "without a doubt", "yes definitely", "you may rely on it", "as I see it, yes", "most likely", "outlook good", "yes", "signs point to yes"]
11
- neutral_messages=["reply hazy", "try again", "ask again later", "better not tell you now", "cannot predict now", "concentrate and ask again"]
12
- negative_messages=["don't count on it", "my reply is no", "my sources say no", "outlook not so good", "very doubtful"]
13
 
14
- all_messages=affirmative_messages+neutral_messages+negative_messages
15
- return random.choice(all_messages)
16
 
17
- def eight_ball_but_its_just_me(message, history):
18
- affirmative_messages=["ofc girl", "yesss omg", "defnitly ehhe"]
19
- neutral_messages=["uhhh lowk idk", "idek", "manifesting", "ur asking too much of me"]
20
- negative_messages=["bru nah", "stay delulu cuz its not gonna happen", "nuh uh"]
21
 
22
- all_messages=affirmative_messages+neutral_messages+negative_messages
23
- return random.choice(all_messages)
 
 
 
24
 
25
- chatbot = gr.ChatInterface(eight_ball_but_its_just_me, type="messages", title="magic 8ball but jst me heh", description="uhhh i gotchu i guess", theme="mgetz/Celeb_glitzy")
 
 
26
  chatbot.launch()
 
 
1
  import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
 
 
5
 
6
+ def respond(message, history):
7
+ messages = [{"role": "system", "content": "Your 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(eight_ball_but_its_just_me, type="messages")
23
  chatbot.launch()