ariel79 commited on
Commit
28f6562
·
verified ·
1 Parent(s): 56767d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from sentence_transformers import SentenceTransformer, util
3
  import openai
4
  import os
 
5
 
6
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
7
 
@@ -87,7 +88,9 @@ def generate_response(user_query, relevant_segment):
87
 
88
  # Append assistant's message to messages list for context
89
  messages.append({"role": "assistant", "content": output_text})
90
-
 
 
91
  return output_text
92
 
93
  except Exception as e:
@@ -133,11 +136,11 @@ 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
- submit_button = gr.Button("Submit")
137
  answer = gr.Textbox(label="AI-nstein Response", placeholder="AI-nstein will respond here...", interactive=False, lines=10)
 
138
  submit_button.click(fn=query_model, inputs=question, outputs=answer)
139
 
140
 
141
 
142
  # Launch the Gradio app to allow user interaction
143
- demo.launch(share=True)
 
2
  from sentence_transformers import SentenceTransformer, util
3
  import openai
4
  import os
5
+ import random
6
 
7
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
8
 
 
88
 
89
  # Append assistant's message to messages list for context
90
  messages.append({"role": "assistant", "content": output_text})
91
+ fun_int=random.randint(0,11)
92
+ fun_facts=["Young Einstein didn't talk until much later in his childhood.","Einstein had larger-than-average perietal lobes.","Einstein was a talented violinist","Einstein's brain was preserved after his death!","Einstein started as a teacher, but couldn't find a job.","Einstein's famous equation E=mc² was announced in 1905.","Einstein won The Nobel Prize in Physics in 1921","Einstien did not wear socks!","Einstein loved sailing.",'Einstein once said -"If you can't explain it simply, you don't understand it well enough."','Einstein once said- "Logic will get you from A to B. Imagination will get you anywhere."']
93
+ output_text=output_text+fun_facts[fun_int-1]
94
  return output_text
95
 
96
  except Exception as e:
 
136
  with gr.Row():
137
  with gr.Column():
138
  question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
 
139
  answer = gr.Textbox(label="AI-nstein Response", placeholder="AI-nstein will respond here...", interactive=False, lines=10)
140
+ submit_button = gr.Button("Submit")
141
  submit_button.click(fn=query_model, inputs=question, outputs=answer)
142
 
143
 
144
 
145
  # Launch the Gradio app to allow user interaction
146
+ demo.launch(share=True)