client = qdrant_client.QdrantClient(path=vector_store_path) client.create_collection(collection_name=VECTOR_COLLECTION_NAME,vectors_config=models.VectorParams(size=param_size,distance=models.Distance.COSINE)) return client # other code here... transformations=[ TitleExtractor(nodes=3,llm=llm,num_workers=1), QuestionsAnsweredExtractor(questions=3,llm=llm,num_workers=1), SummaryExtractor(summaries=["prev","self","next"],llm=llm,num_workers=1), KeywordExtractor(llm=llm,num_workers=1), SentenceSplitter(chunk_size=2048,chunk_overlap=512), # TokenTextSplitter(chunk_size=1024,chunk_overlap=256), HuggingFaceEmbedding(model_name=embed_model) ], vector_store=vector_store ) nodes = pipeline.run(documents=docs,show_progress=True)
tmp lock file
async def astreamer(response,model_used): try: for i in response.response_gen: if response._is_done: print("IS DONE!") else: print("IS NOT DONE!") yield json.dumps(i) create_json_response() await asyncio.sleep(.1) except asyncio.CancelledError as e: print('cancelled')
@app.post("/chat") async def chat(request:Request): ... response = chat_engine_dict["engine"].stream_chat(query) return StreamingResponse(astreamer(response,model_used=model_used),media_type="text/event-stream")
ValueError: Metadata length (379349) is longer than chunk size (2048). Consider increasing the chunk size or decreasing the size of your metadata to avoid this.
ValueError: shapes (0,512) and (384,) not aligned: 512 (dim 1) != 384 (dim 0)
# We will be using local storage instead of a host qdrant server client = qdrant_client.QdrantClient(path="./sfa_test",) client.create_collection(collection_name="SFA",vectors_config=models.VectorParams(size=512,distance=models.Distance.COSINE)) vector_store = QdrantVectorStore(client=client,collection_name="SFA") storage_context = StorageContext.from_defaults(vector_store=vector_store,) from llama_index.core import ServiceContext,Document docs = SimpleDirectoryReader("./data/").load_data() # docs = docs [150:160] docs = [Document(text="Hello world"), Document(text="Hello there")] Settings.embed_model = resolve_embed_model("local:BAAI/bge-small-en-v1.5") Settings.llm = Ollama(model="mistral") embed = resolve_embed_model("local:BAAI/bge-small-en-v1.5") llm = Ollama(model="mistral") SERVICE_CONTEXT = ServiceContext.from_defaults(embed_model=embed,llm=llm) pipeline = IngestionPipeline( transformations=[ KeywordExtractor(llm=llm), TokenTextSplitter(chunk_size=512,chunk_overlap=256) ], vector_store=vector_store ) nodes = pipeline.run(documents=docs,num_workers=16,) index = VectorStoreIndex.from_vector_store(vector_store=vector_store,embed_model=embed) query_engine = index.as_query_engine(llm=llm) response = query_engine.query("Give me a random example") print(response)
client.create_collection(collection_name="SFA",vectors_config=models.VectorParams(size=512,distance=models.Distance.COSINE))