File size: 913 Bytes
e6d0a93
05989da
 
 
 
 
 
 
e6d0a93
9eba892
 
 
 
 
 
 
 
05989da
 
6d13a02
05989da
 
 
 
 
 
 
 
 
 
 
 
 
e6d0a93
05989da
aa1fc59
e6d0a93
2714d4c
09f8e23
c4b0c2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
#import random
from huggingface_hub import InferenceClient

client = InferenceClient("microsoft/phi-4")




#def echo(message,history):
 #   numberval = random.randint(0,1)
  #  if numberval == 0:
   #     message = "yes"
    #else:
     #   message = "no"
    #return message

def respond(message, history):

    messages = [{"role": "system", "content": "You are a polite chatbot helps users understand technical terms in technology."}]

    if history:
        messages.extend(history)

    messages.append({"role": "user", "content": message})
    #responses = ["yes", "no"]
    response = client.chat_completion(
        messages,
        max_tokens=100
    )
    return response['choices'][0]['message']['content'].strip()
    #return random.choice(responses)


    
print("'hello world!'")

chatbot = gr.ChatInterface(respond, type="messages", title="Yes-No Chatbot")

chatbot.launch()