File size: 3,509 Bytes
1cc6224
 
 
 
f2e12f2
1cc6224
 
 
 
 
394bfa0
1cc6224
c97922d
ff9d83f
 
 
66295b5
1cc6224
 
c97922d
ff9d83f
 
 
1cc6224
 
 
c97922d
1cc6224
 
 
 
b21cf13
1cc6224
c97922d
1cc6224
 
 
c97922d
 
 
 
 
 
 
 
 
 
79e4ffe
 
b47f63f
1cc6224
543ad98
10d4686
c97922d
543ad98
 
 
 
 
 
c97922d
1cc6224
 
 
c97922d
394bfa0
 
a79e9ce
9ad94c7
394bfa0
 
 
 
 
 
1cc6224
 
 
c97922d
1cc6224
 
 
 
 
 
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
import gradio as gr
from sentence_transformers import SentenceTransformer, util
import openai
import os

os.environ["TOKENIZERS_PARALLELISM"] = "false"

# Initialize paths and model identifiers for easy configuration and maintenance
filename = "output_topic_details.txt"  # Path to the file storing chess-specific details
retrieval_model_name = 'output/sentence-transformer-finetuned/'
openai.api_key = os.environ["OPENAI_API_KEY"]

system_message = "You are a chatbot specialized in providing information the Young Yale Global Scholars program. You will be giving information to be applicants and scholars."
# Initial system message to set the behavior of the assistant
messages = [{"role": "system", "content": system_message}]

    Generate a response emphasizing the bot's capability in providing exercise information.
    """
    try:
        user_message = f"Here's the information on YYGS: {relevant_segment}"

        # Append user's message to messages list
        messages.append({"role": "user", "content": user_message})
    Process a question, find relevant information, and generate a response.
    """
    if question == "":
        return "Welcome to Ask YYGS! Ask any question related to the YYGS program and this chatbot should be able to help!"
    relevant_segment = find_relevant_segment(question, segments)
    if not relevant_segment:
        return "Could not find specific information. Please refine your question."
welcome_message = """
#

## AskYYGS is an AI-driven assistant for all Young Yale Global Scholar related queries. Created by Alexandra, Loli, Abigail, and Lisa at the 2025 YYGS Hack-A-Thon. 
"""

topics = """
### Here are some ideas of things you can ask about!
- Class Locations
- Where to get help
- Laundry
- Roomate Question Ideas
- Things To Do
- What the programs mean
- Example Lectures
- Dining Shifts and the Menu
- How to Beat the Heat
"""


# Setup the Gradio Blocks interface with custom layout components
theme = gr.themes.Monochrome(
    primary_hue="blue",
    secondary_hue="gray",
).set(
    background_fill_primary='*primary_200',
    background_fill_primary_dark='*primary_200',
# Setup the Gradio Blocks interface with custom layout components
with gr.Blocks(theme=theme) as demo:
    theme='gstaff/xkcd' 
    #gr.Image("Screenshot 2024-08-01 at 11.03.58 AM.png", show_label = False, show_share_button = False, show_download_button = False, width = 1800, height = 470)
    gr.Markdown(welcome_message)  # Display the formatted welcome message
    with gr.Row():
        with gr.Column():
            gr.Markdown(topics)  


    
            
    with gr.Row():
        with gr.Column():
            question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
            answer = gr.Textbox(label="Ask YYGS's Response:", placeholder="askYYGS will respond here...", interactive=False, lines=10)
            submit_button = gr.Button("Submit")
            submit_button.click(fn=query_model, inputs=question, outputs=answer)
    with gr.Row():
        with gr.Column():
            question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
            answer = gr.Textbox(label="Ask YYGS's Response:", placeholder="askYYGS will respond here...", interactive=False, lines=10)
            submit_button = gr.Button("Submit")
            submit_button.click(fn=query_model, inputs=question, outputs=answer)
    

# Launch the Gradio app to allow user interaction
demo.launch(share=True)