Update app.py
Browse files
app.py
CHANGED
@@ -69,7 +69,6 @@ def doc_emb(doc: str):
|
|
69 |
# for f in futures:
|
70 |
# emb_list.append(f.result())
|
71 |
print('\n'.join(texts))
|
72 |
-
pine(doc)
|
73 |
gr.Textbox.update(value="")
|
74 |
return texts, emb_list, gr.Textbox.update(visible=True), gr.Button.update(visible=True), gr.Markdown.update(
|
75 |
value="""success ! Let's talk"""), gr.Chatbot.update(visible=True)
|
@@ -200,44 +199,6 @@ def up_file(fls):
|
|
200 |
value="Processing")
|
201 |
|
202 |
|
203 |
-
def pine(data):
|
204 |
-
char_text_spliter = CharacterTextSplitter(chunk_size = 1000, chunk_overlap=0)
|
205 |
-
# doc_text = char_text_spliter.split_documents(data)
|
206 |
-
doc_spilt = []
|
207 |
-
data = data.split(" ")
|
208 |
-
# print(len(data))
|
209 |
-
|
210 |
-
c = 0
|
211 |
-
check = 0
|
212 |
-
for i in data:
|
213 |
-
# print(i)
|
214 |
-
if c == 550:
|
215 |
-
text = " ".join(data[check: check + c])
|
216 |
-
print(text)
|
217 |
-
print(check)
|
218 |
-
doc_spilt.append(text)
|
219 |
-
check = check + c
|
220 |
-
c = 0
|
221 |
-
else:
|
222 |
-
c = c+1
|
223 |
-
|
224 |
-
|
225 |
-
Embedding_model = "text-embedding-ada-002"
|
226 |
-
embeddings = OpenAIEmbeddings(openai_api_key="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")
|
227 |
-
|
228 |
-
print(requests.post(url = chat_emd))
|
229 |
-
|
230 |
-
# embeddings = requests.post(url=chat_emd,
|
231 |
-
# data=json.dumps(data),
|
232 |
-
# headers=headers
|
233 |
-
# )
|
234 |
-
|
235 |
-
pinecone.init(api_key = "ffb1f594-0915-4ebf-835f-c1eaa62fdcdc",environment = "us-west4-gcp-free")
|
236 |
-
|
237 |
-
index_name = "test"
|
238 |
-
docstore = Pinecone.from_texts([d for d in doc_spilt],embeddings,index_name = index_name,namespace='a1')
|
239 |
-
|
240 |
-
return ''
|
241 |
|
242 |
def get_answer(query_live):
|
243 |
|
|
|
69 |
# for f in futures:
|
70 |
# emb_list.append(f.result())
|
71 |
print('\n'.join(texts))
|
|
|
72 |
gr.Textbox.update(value="")
|
73 |
return texts, emb_list, gr.Textbox.update(visible=True), gr.Button.update(visible=True), gr.Markdown.update(
|
74 |
value="""success ! Let's talk"""), gr.Chatbot.update(visible=True)
|
|
|
199 |
value="Processing")
|
200 |
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
def get_answer(query_live):
|
204 |
|