Ocillus commited on
Commit
97d5311
·
verified ·
1 Parent(s): 3ec4734

Update ArcanaUI2.py

Browse files
Files changed (1) hide show
  1. ArcanaUI2.py +9 -9
ArcanaUI2.py CHANGED
@@ -93,7 +93,7 @@ search_mode = 0#Always Search
93
  # OpenAI client setup
94
  client = OpenAI(
95
  base_url='https://api.openai-proxy.org/v1',
96
- api_key='sk-Nxf8HmLpfIMhCd83n3TOr00TR57uBZ0jMbAgGCOzppXvlsx1',
97
  )
98
 
99
  # Function list for OpenAI API
@@ -149,7 +149,7 @@ def openai_api_call(messages, retries=3, delay=5):
149
  try:
150
  # Modify the user's message if search_mode is 0
151
  if search_mode == 0:
152
- messages[-1]['content'] = "[System: SEARCH when the user ASKED A QUESTION & remember to CITE(the source is the first tag). Otherwise do not search];" + messages[-1]['content']
153
 
154
  completion = client.chat.completions.create(
155
  model="gpt-4o",
@@ -219,8 +219,8 @@ def handle_dbms_mode(mode):
219
 
220
  # Chatbot response function
221
  def chatbot_response(message, history):
222
- messages = [{"role": "system", "content": '''You are Arcana, a dynamic study resource database designed to help students excel in their exams. Your responses should be accurate, informative, and evidence-based whenever possible. Follow these guidelines:
223
- Your primary goal is to provide students with the most helpful and accurate study information, utilizing both your internal knowledge and the PDF resources at your disposal. You will search your database for answers and properly intext cite them, unless there is no such data, then you will intextcite[Arcana].'''}]
224
 
225
  for human, assistant in history:
226
  messages.append({"role": "user", "content": human})
@@ -413,8 +413,8 @@ chatbot_interface = gr.ChatInterface(
413
  chatbot_response,
414
  chatbot=gr.Chatbot(height=400),
415
  textbox=gr.Textbox(placeholder="Type your message here...", container=False, scale=100),
416
- title="Review With Arcana",
417
- description="ArcanaUI v0.8 - Chatbot",
418
  theme="default",
419
  examples=get_random_examples(),
420
  cache_examples=False,
@@ -446,7 +446,7 @@ async () => {
446
  };
447
  }
448
  """) as demo:
449
- gr.Markdown("# ArcanaUI v0.8")
450
  with gr.Tabs():
451
  with gr.TabItem("Welcome Page"):
452
  with open('introduction.txt',mode='r') as file:
@@ -465,7 +465,7 @@ async () => {
465
  # Left column: File list and buttons
466
  with gr.Column(scale=1):
467
  gr.Markdown("## Upload File")
468
- file_input = gr.File(label="Upload your file here", file_types=["pdf", "jpeg", "jpg", "gif", "docx"])
469
  file_input.change(handle_file_upload_threaded, inputs=file_input)
470
 
471
  uploaded_files_list = gr.DataFrame(headers=["Uploaded Files"], datatype="str", interactive=False)
@@ -502,7 +502,7 @@ async () => {
502
  inputs=new_file_name,
503
  outputs=[uploaded_files_list, file_status, file_viewer, file_size, file_creation_time])
504
 
505
- render_button = gr.Button("Render all PDFs to Database")
506
  render_button.click(fn=render_to_database)
507
 
508
  with gr.TabItem('Settings'):
 
93
  # OpenAI client setup
94
  client = OpenAI(
95
  base_url='https://api.openai-proxy.org/v1',
96
+ api_key='sk-JPHnp3AyBA0TOxXuhJ01sbhuq8dRlW6YHQjbGpla279c4dAn',
97
  )
98
 
99
  # Function list for OpenAI API
 
149
  try:
150
  # Modify the user's message if search_mode is 0
151
  if search_mode == 0:
152
+ messages[-1]['content'] = "[System: SEARCH when the user ASKED A QUESTION & remember to CITE(the source is the first tag). Otherwise do not search. The User's question:"];" + messages[-1]['content']
153
 
154
  completion = client.chat.completions.create(
155
  model="gpt-4o",
 
219
 
220
  # Chatbot response function
221
  def chatbot_response(message, history):
222
+ messages = [{"role": "system", "content": '''Your name is Arcana. You are a chatbot made by Indexademics. Your goal is to solve questions. You can query the database at anytime when the user asks a question specific to their tasks and you think is unlikely to be searchable online.
223
+ If they ask anything about academics, search your database first, then use your own knowledge. Cite the file name when you use the dbms.'''}]
224
 
225
  for human, assistant in history:
226
  messages.append({"role": "user", "content": human})
 
413
  chatbot_response,
414
  chatbot=gr.Chatbot(height=400),
415
  textbox=gr.Textbox(placeholder="Type your message here...", container=False, scale=100),
416
+ title="Indexademics ChatBot",
417
+ description="Arcana v1",
418
  theme="default",
419
  examples=get_random_examples(),
420
  cache_examples=False,
 
446
  };
447
  }
448
  """) as demo:
449
+ gr.Markdown("# ArcanaV1")
450
  with gr.Tabs():
451
  with gr.TabItem("Welcome Page"):
452
  with open('introduction.txt',mode='r') as file:
 
465
  # Left column: File list and buttons
466
  with gr.Column(scale=1):
467
  gr.Markdown("## Upload File")
468
+ file_input = gr.File(label="Upload your file here", file_types=["pdf", "jpeg", "jpg", "gif", "docx", "pptx"])
469
  file_input.change(handle_file_upload_threaded, inputs=file_input)
470
 
471
  uploaded_files_list = gr.DataFrame(headers=["Uploaded Files"], datatype="str", interactive=False)
 
502
  inputs=new_file_name,
503
  outputs=[uploaded_files_list, file_status, file_viewer, file_size, file_creation_time])
504
 
505
+ render_button = gr.Button("Render All Files to Database")
506
  render_button.click(fn=render_to_database)
507
 
508
  with gr.TabItem('Settings'):