ariel79 commited on
Commit
84c29fc
·
verified ·
1 Parent(s): 39ba8e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -6,12 +6,12 @@ import os
6
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
7
 
8
  # Initialize paths and model identifiers for easy configuration and maintenance
9
- filename = "output_topic_details.txt" # Path to the file storing chess-specific details
10
  retrieval_model_name = 'output/sentence-transformer-finetuned/'
11
 
12
  openai.api_key = os.environ["OPENAI_API_KEY"]
13
 
14
- system_message = "You are a chess chatbot specialized in providing information on chess rules, strategies, and terminology."
15
  # Initial system message to set the behavior of the assistant
16
  messages = [{"role": "system", "content": system_message}]
17
 
@@ -64,10 +64,10 @@ def find_relevant_segment(user_query, segments):
64
 
65
  def generate_response(user_query, relevant_segment):
66
  """
67
- Generate a response emphasizing the bot's capability in providing chess information.
68
  """
69
  try:
70
- user_message = f"Here's the information on chess: {relevant_segment}"
71
 
72
  # Append user's message to messages list
73
  messages.append({"role": "user", "content": user_message})
@@ -99,7 +99,7 @@ def query_model(question):
99
  Process a question, find relevant information, and generate a response.
100
  """
101
  if question == "":
102
- return "Welcome to ChessBot! Ask me anything about chess rules, strategies, and terminology."
103
  relevant_segment = find_relevant_segment(question, segments)
104
  if not relevant_segment:
105
  return "Could not find specific information. Please refine your question."
@@ -108,20 +108,20 @@ def query_model(question):
108
 
109
  # Define the welcome message and specific topics the chatbot can provide information about
110
  welcome_message = """
111
- # ♟️ Welcome to ChessBot!
112
 
113
- ## Your AI-driven assistant for all chess-related queries. Created by SCHOLAR1, SCHOLAR2, and SCHOLAR3 of the 2024 Kode With Klossy CITY Camp.
114
  """
115
 
116
  topics = """
117
  ### Feel Free to ask me anything from the topics below!
118
- - Chess piece movements
119
- - Special moves
120
- - Game phases
121
- - Common strategies
122
- - Chess terminology
123
- - Famous games
124
- - Chess tactics
125
  """
126
 
127
  # Setup the Gradio Blocks interface with custom layout components
@@ -133,7 +133,7 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
133
  with gr.Row():
134
  with gr.Column():
135
  question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
136
- answer = gr.Textbox(label="ChessBot Response", placeholder="ChessBot will respond here...", interactive=False, lines=10)
137
  submit_button = gr.Button("Submit")
138
  submit_button.click(fn=query_model, inputs=question, outputs=answer)
139
 
 
6
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
7
 
8
  # Initialize paths and model identifiers for easy configuration and maintenance
9
+ filename = "output_topic_details.txt" # Path to the file storing AI-specific details
10
  retrieval_model_name = 'output/sentence-transformer-finetuned/'
11
 
12
  openai.api_key = os.environ["OPENAI_API_KEY"]
13
 
14
+ system_message = "You are an AI chatbot specialized in providing information on AI usage, helpful tools, and teaching users about AI."
15
  # Initial system message to set the behavior of the assistant
16
  messages = [{"role": "system", "content": system_message}]
17
 
 
64
 
65
  def generate_response(user_query, relevant_segment):
66
  """
67
+ Generate a response emphasizing the bot's capability in providing AI information.
68
  """
69
  try:
70
+ user_message = f"Here's the information on AI: {relevant_segment}"
71
 
72
  # Append user's message to messages list
73
  messages.append({"role": "user", "content": user_message})
 
99
  Process a question, find relevant information, and generate a response.
100
  """
101
  if question == "":
102
+ return "Welcome to AI-nstein! Ask me anything about AI ML, and helpful tools you may want to use!"
103
  relevant_segment = find_relevant_segment(question, segments)
104
  if not relevant_segment:
105
  return "Could not find specific information. Please refine your question."
 
108
 
109
  # Define the welcome message and specific topics the chatbot can provide information about
110
  welcome_message = """
111
+ # ♟️ Welcome to AI-nstein!
112
 
113
+ ## Your AI-driven assistant for all artificial intelligence-related queries. Created by Sophie Cheng, Ariel Datikash, and K Barnes of the 2024 Kode With Klossy CITY Camp.
114
  """
115
 
116
  topics = """
117
  ### Feel Free to ask me anything from the topics below!
118
+ - AI Usage
119
+ - AI Safety
120
+ - AI Helpers
121
+ - How AI Works
122
+ - Basics of AI
123
+ - Fun Facts about AI
124
+ - Examples of AI
125
  """
126
 
127
  # Setup the Gradio Blocks interface with custom layout components
 
133
  with gr.Row():
134
  with gr.Column():
135
  question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
136
+ answer = gr.Textbox(label="AI-nstein Response", placeholder="AI-nstein will respond here...", interactive=False, lines=10)
137
  submit_button = gr.Button("Submit")
138
  submit_button.click(fn=query_model, inputs=question, outputs=answer)
139