brurei commited on
Commit
d6d075e
1 Parent(s): 43ece1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -122,6 +122,33 @@ div.textBoxBot {
122
  return str(response.response)
123
  """
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  with gr.Blocks(css=css) as demo:
126
  realPath = str(os.path.dirname(os.path.realpath(__file__)))
127
  img1 = gr.Image("images/1024x150_cabeçalho.hippo.png", elem_classes=".img.svelte-ms5bsk", elem_id="img.svelte-ms5bsk").style(container=False)
 
122
  return str(response.response)
123
  """
124
 
125
+ def transcribe(audio):
126
+ text = p(audio)["text"]
127
+ return text
128
+ def construct_index(directory_path):
129
+ max_input_size = 10000
130
+ num_outputs = 10000
131
+ max_chunk_overlap = 20000
132
+ chunk_size_limit = 600000
133
+
134
+ prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
135
+
136
+ llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.0, model_name="text-davinci-003", max_tokens=num_outputs))
137
+
138
+ documents = SimpleDirectoryReader(directory_path).load_data()
139
+
140
+ index = GPTSimpleVectorIndex.from_documents(documents)
141
+ index.save_to_disk('index.json')
142
+
143
+ return index
144
+
145
+
146
+ def chatbot(input_text):
147
+
148
+ index = GPTSimpleVectorIndex.load_from_disk('index.json')
149
+ response = index.query(input_text)
150
+ return str(response.response)
151
+
152
  with gr.Blocks(css=css) as demo:
153
  realPath = str(os.path.dirname(os.path.realpath(__file__)))
154
  img1 = gr.Image("images/1024x150_cabeçalho.hippo.png", elem_classes=".img.svelte-ms5bsk", elem_id="img.svelte-ms5bsk").style(container=False)