Spaces:
Runtime error
Runtime error
fix
Browse files- main.py +2 -0
- service/api.py +2 -0
- service/vector_store.py +0 -2
main.py
CHANGED
|
@@ -33,10 +33,12 @@ def search(request: Request, inputs: str):
|
|
| 33 |
print(f"client_host: {client_host}")
|
| 34 |
return vector_store.search(inputs)
|
| 35 |
|
|
|
|
| 36 |
@app.get("/api/suggestion")
|
| 37 |
def get_suggestion(inputs: str):
|
| 38 |
return api.get_suggestion(inputs)
|
| 39 |
|
|
|
|
| 40 |
@app.get("/api/answer")
|
| 41 |
async def get_answer(inputs: str):
|
| 42 |
return StreamingResponse(api.get_answer(inputs))
|
|
|
|
| 33 |
print(f"client_host: {client_host}")
|
| 34 |
return vector_store.search(inputs)
|
| 35 |
|
| 36 |
+
## FILECOIN WEB COMPLETE API
|
| 37 |
@app.get("/api/suggestion")
|
| 38 |
def get_suggestion(inputs: str):
|
| 39 |
return api.get_suggestion(inputs)
|
| 40 |
|
| 41 |
+
## FILECOIN WEB ASNWER API
|
| 42 |
@app.get("/api/answer")
|
| 43 |
async def get_answer(inputs: str):
|
| 44 |
return StreamingResponse(api.get_answer(inputs))
|
service/api.py
CHANGED
|
@@ -80,6 +80,8 @@ class API():
|
|
| 80 |
"description":doc.metadata.get('description_llm','')
|
| 81 |
})
|
| 82 |
description = doc.metadata.get('description','')
|
|
|
|
|
|
|
| 83 |
links = doc.metadata.get('source','')
|
| 84 |
context.append(f"<context>Description: {description}\nLinks: {links}\n<context/>")
|
| 85 |
# yield json.dumps(source)
|
|
|
|
| 80 |
"description":doc.metadata.get('description_llm','')
|
| 81 |
})
|
| 82 |
description = doc.metadata.get('description','')
|
| 83 |
+
if description == '':
|
| 84 |
+
description = doc.metadata.get('description_llm','')
|
| 85 |
links = doc.metadata.get('source','')
|
| 86 |
context.append(f"<context>Description: {description}\nLinks: {links}\n<context/>")
|
| 87 |
# yield json.dumps(source)
|
service/vector_store.py
CHANGED
|
@@ -35,8 +35,6 @@ class VectorStore(Pinecone):
|
|
| 35 |
super().__init__(index, OpenAIEmbeddings(),"text")
|
| 36 |
|
| 37 |
def add_docs(self,docs):
|
| 38 |
-
if self.INDEX_NAME not in pinecone.list_indexes():
|
| 39 |
-
pinecone.create_index(name=self.INDEX_NAME, metric="cosine", dimension=self.dims)
|
| 40 |
Pinecone.from_documents(docs, self.embeddings, index_name=self.INDEX_NAME)
|
| 41 |
|
| 42 |
def search(self,
|
|
|
|
| 35 |
super().__init__(index, OpenAIEmbeddings(),"text")
|
| 36 |
|
| 37 |
def add_docs(self,docs):
|
|
|
|
|
|
|
| 38 |
Pinecone.from_documents(docs, self.embeddings, index_name=self.INDEX_NAME)
|
| 39 |
|
| 40 |
def search(self,
|