isayahc commited on
Commit
6e4f066
·
verified ·
1 Parent(s): fa8c523

added a simple search for existing experiemnts

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -51,6 +51,16 @@ def generate_experiment(input_text, retriever_choice):
51
  })
52
  return output_text
53
 
 
 
 
 
 
 
 
 
 
 
54
  generate_apparatus_interface = gr.Interface(
55
  fn=generate_apparatus,
56
  inputs=["text", gr.Radio(choices=list(apparatus_retriever_options.keys()), label="Select a retriever", value="Wikipedia")],
@@ -67,10 +77,19 @@ generate_experiment_interface = gr.Interface(
67
  description="I am here to generate and store science experiments for our users",
68
  )
69
 
 
 
 
 
 
 
 
 
70
  demo = gr.TabbedInterface([
71
  generate_apparatus_interface,
72
  generate_experiment_interface,
73
- ], ["Generate Apparatus", "Generate Experiment"])
 
74
 
75
  if __name__ == "__main__":
76
  demo.launch()
 
51
  })
52
  return output_text
53
 
54
+ def process_text(input_text, number):
55
+ # Example processing function
56
+ weaviate_client = init_client()
57
+ science_experiment_collection = weaviate_client.collections.get("ScienceEperiment")
58
+ response = science_experiment_collection.query.bm25(
59
+ query=input_text,
60
+ limit=3
61
+ )
62
+ return response.objects.__str__()
63
+
64
  generate_apparatus_interface = gr.Interface(
65
  fn=generate_apparatus,
66
  inputs=["text", gr.Radio(choices=list(apparatus_retriever_options.keys()), label="Select a retriever", value="Wikipedia")],
 
77
  description="I am here to generate and store science experiments for our users",
78
  )
79
 
80
+ process_text_interface = gr.Interface(
81
+ fn=process_text,
82
+ inputs=["text", gr.Slider(minimum=2, maximum=6, step=1, value=2, label="Select a number")],
83
+ outputs="text",
84
+ title="Search Existing Experiments",
85
+ description="If you would like an idea of the experiments in the vectorestore here is the place",
86
+ )
87
+
88
  demo = gr.TabbedInterface([
89
  generate_apparatus_interface,
90
  generate_experiment_interface,
91
+ process_text_interface
92
+ ], ["Generate Apparatus", "Generate Experiment", "Search Existing Experiments"])
93
 
94
  if __name__ == "__main__":
95
  demo.launch()