File size: 3,194 Bytes
1981c8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97e576e
 
 
 
 
 
 
 
 
e7406da
 
 
c30fb03
e7406da
 
 
 
c30fb03
e7406da
 
 
 
c30fb03
e7406da
 
 
c30fb03
e7406da
 
 
 
 
c30fb03
f35af7d
 
 
 
 
 
 
9e2d4ad
1981c8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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()