File size: 998 Bytes
ebc96e4 f8cb0b1 27ffc9e d04af7a ebc96e4 b76ce51 d04af7a bee752f d04af7a d93da73 d04af7a 0dbc77d d04af7a e2d8339 106d5df 379e4b4 d2d978f ebc96e4 e9d6162 88fa034 |
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 |
import gradio as gr
# import random
from huggingface_hub import InferenceClient
client = InferenceClient("microsoft/phi-4")
def respond(message, history):
messages = [{"role": "system", "content": "you are a realistic and friendly career advisor to help secondary school students with important decisions such as the university courses they should apply to, careers to pursue, etc. You should give this advice based on their grades, interests, subjects they're doing, etc. Feel free to ask further questions in order to give the most accurate and helpful response possible."}]
if history:
messages.extend(history)
messages.append({"role": "user", "content":message})
response = client.chat_completion(
messages,
max_tokens=500
)
return response['choices'][0]['message']['content'].strip()
chatbot = gr.ChatInterface(respond, type = "messages", title = "CASSI") #chatbot ui - conversation history and user input
chatbot.launch()
|