Chatbot / app.py
grover101's picture
Update app.py
f35af7d verified
Raw
History Blame Contribute Delete
3.19 kB
import gradio as gr
from huggingface_hub import InferenceClient
"""
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
"""
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
def respond(
message,
history: list[tuple[str, str]],
system_message,
max_tokens,
temperature,
top_p,
):
messages = [{"role": "system", "content": system_message}]
for val in history:
if val[0]:
messages.append({"role": "user", "content": val[0]})
if val[1]:
messages.append({"role": "assistant", "content": val[1]})
messages.append({"role": "user", "content": message})
response = ""
for message in client.chat_completion(
messages,
max_tokens=max_tokens,
stream=True,
temperature=temperature,
top_p=top_p,
):
token = message.choices[0].delta.content
response += token
yield response
"""
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
"""
demo = gr.ChatInterface(
respond,
additional_inputs=[
gr.Textbox(value='''You are a friendly Chatbot that helps in answering the FAQs
DO NOT GIVE ANY reply or suggestion if it not related to Career center Check each question asked by user if it fitting under Career center objective
if user is asking some complex question reply with i am not allowed or not able to reply to that
here are the details for the FAQ
Here Are the refernece you can use :
Question 1: How can I make an appointment with Shevet Glaubach Center for Career Strategy & Professional Development (SGC)?
Ans:
The SGC is available on both campuses. If you are a current student, you can use our online scheduling tool on YU CareerLink. Click here to log-in and request an appointment. You can also call us at either of our campus locations:
Wilf Campus
500 West 185th Street, Suite 530 (Furst Hall)
New York, NY 10033
Phone: 646-592-4090
Beren Campus
215 Lexington Avenue, 5th floor
New York, NY 10016
Phone: (646) 592-4135
Hours of operation:
Monday-Thursday: 9:00am – 5:30pm
Friday: 9:00am – 2:30pm
Question 2: What is YU CareerLink and what is the use?
Ans:
YUCL (short for YU CareerLink) is a career management system, where you can search and apply for jobs/internships,
find out about site visits, panels, and workshops with the SGC, and post your cover letter and resume materials.
It also gives us a way to stay in touch with you to let you know about career-related opportunities and events with our office!
''', label="System message"),
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
gr.Slider(
minimum=0.1,
maximum=1.0,
value=0.95,
step=0.05,
label="Top-p (nucleus sampling)",
),
],
)
if __name__ == "__main__":
demo.launch()