I have no idea what I am doing; But I am trying to upload a file from nodejs to python fastapi, and create a qdrant index of it and place it in qdrant. And query the index and return an answer.
But it only returns -1 for the query.
I am using docker compose, and I figure I have loads of errors and it cant connect to qdrant or something like that. If anyone wants to take a glance.
import qdrant_client
client = qdrant_client.QdrantClient(
host="qdrant" # qdrant is the name of the docker container
)
@app.post("/upload")
async def upload_file(file: UploadFile = File(...)):
uniqueid = uuid.uuid4()
os.makedirs(f"files/{uniqueid}/", exist_ok=True)
file_location = f"files/{uniqueid}/{file.filename}"
with open(file_location, "wb+") as file_object:
file_object.write(file.file.read())
documents = SimpleDirectoryReader(f"files/{uniqueid}/").load_data()
print(documents)
index = GPTQdrantIndex(documents, collection_name=uniqueid, client=client)
response = index.query(
"Jeg har lyst til å dra på ferie, kan jeg bruke firmahyttene?")
shutil.rmtree(f"files/{uniqueid}/")
return {"info": f"file '{file.filename}' successully indexed in Qdrant", "data": response}
version: "3.8"
networks:
app-tier:
driver: bridge
services:
fastapi:
build: ./fastapi
expose:
- "5000"
ports:
- "5000:5000"
environment:
- QDRANT_HOST=qdrant
depends_on:
- qdrant
networks:
- app-tier
volumes:
- ./fastapi:/app:Z
sveltekit:
build: ./sveltekit
ports:
- 3000:3000
networks:
- app-tier
depends_on:
- fastapi
volumes:
- ./sveltekit:/app:Z
environment:
- VITE_BACKEND_URL=http://localhost:5000
qdrant:
image: qdrant/qdrant:v0.10.1
# mem_limit: 450m
ports:
- 6333:6333
volumes:
- ./data/qdrant_storage:/qdrant/storage
networks:
- app-tier