vision_service-1 | pydantic_core._pydantic_core.ValidationError: 2 validation errors for ChatMessage vision_service-1 | blocks.0 vision_service-1 | Unable to extract tag using discriminator ‘block_type’ [type=union_tag_not_found, input_value={‘type’: ‘text’, ‘text’: ‘Describe what you see’}, input_type=dict] vision_service-1 | For further information visit https://errors.pydantic.dev/2.9/v/union_tag_not_found vision_service-1 | blocks.1 vision_service-1 | Unable to extract tag using discriminator ‘block_type’ [type=union_tag_not_found, input_value={‘type’: ‘image_url’, ‘im...gg==’, ‘detail’: ‘low’}}, input_type=dict]
ImportError while importing test module '/home/runner/work/xxx/test_prompts.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: /opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/importlib/__init__.py:90: in import_module return _bootstrap._gcd_import(name[level:], package, level) test_prompts.py:10: in <module> from index import add_documents_to_index ../../index.py:22: in <module> from llama_cloud import FilterCondition /opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/llama_cloud/__init__.py:3: in <module> from .types import ( /opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/llama_cloud/types/__init__.py:21: in <module> from .base import Base E ImportError: cannot import name 'Base' from 'llama_cloud.types.base'
def initialize_index(self, namespace: str, model_name="gpt-3.5-turbo-1106"): service_context = ServiceContext.from_defaults( chunk_size=512, llm=OpenAI(temperature=0.7, model_name=model_name), callback_manager=self.callback_manager, ) pinecone_index = pinecone.Index(PINECONE_INDEX_ID) vector_store = PineconeVectorStore( pinecone_index=pinecone_index, namespace=namespace, ) storage_context = StorageContext.from_defaults( docstore=self.docstore, index_store=self.index_store, vector_store=vector_store, ) self.index = VectorStoreIndex.from_documents( [], storage_context=storage_context, service_context=service_context ) def query_stream(self, query: str, namespace: str, model: str): full_query = 'Please make sure to respond ONLY with content in the .md format as the response, here is my prompt: ' + query self.initialize_index(namespace, model) streaming_response = self.index.as_query_engine( streaming=True, similarity_top_k=20, ).query(full_query) for text in streaming_response.response_gen: yield text
# this is what i want but output_cls and similarity_top_k are not accepted as args base_query_engine = index.as_query_engine(llm=llm, filters=filters) query_engine_presentation_content = RetryQueryEngine( query_engine=base_query_engine, output_cls=PresentationContentListV1, similarity_top_k=10, ) query_engine_presentation_outline = RetryQueryEngine( query_engine=base_query_engine, output_cls=PresentationOutlineV1, similarity_top_k=10, )
AttributeError: 'BaseModel' object has no attribute 'model_dump'
which comes from pydantic.v1
.@app.post("/document/query") def query_stream( query: str = Body(...), uuid_filename: str = Body(...), email: str = Body(...), ) -> StreamingResponse: subscription = get_user_subscription(email) model = MODEL_BASIC if subscription == "FREE" else MODEL_PREMIUM with token_counter(model, query_stream.__name__): filename_without_ext = uuid_filename.split(".")[0] # Create index index = initialize_index(model) document_is_indexed = does_document_exist_in_index(filename_without_ext) if document_is_indexed is False: logging.info("Re-adding to index...") reindex_document(filename_without_ext) if is_summary_request(query): query = modify_query_for_summary(query, filename_without_ext, model) chat_engine = initialize_chat_engine(index, filename_without_ext) streaming_response = chat_engine.stream_chat(query) # takes 10 seconds!! def generate() -> Generator[str, any, None]: yield from streaming_response.response_gen return StreamingResponse(generate(), media_type="text/plain")
document_store = MongoDocumentStore.from_uri(uri=MONGO_DB_URL) index_store = MongoIndexStore.from_uri(uri=MONGO_DB_URL) vector_store = PGVectorStore.from_params( async_connection_string=f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{database}", connection_string=f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}?sslmode=require", table_name=PG_VECTOR_DATABASE_DOC_TABLE_NAME, embed_dim=1536, hybrid_search=True, use_jsonb=True, ) storage_context = StorageContext.from_defaults( docstore=document_store, index_store=index_store, vector_store=vector_store, )
vector_store = PGVectorStore.from_params( async_connection_string=f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{database}", connection_string=f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}?sslmode=require", table_name=PG_VECTOR_DATABASE_DOC_TABLE_NAME, embed_dim=1536, hybrid_search=True, use_jsonb=True, ) storage_context = StorageContext.from_defaults( vector_store=vector_store, )
num_workers
do in the keyword extractor? Is this the amount of CPU threads used?KeywordExtractor(llm, keywords=5, num_workers=24),
web-1 | [2024-02-01 10:55:21 +0000] [8] [ERROR] Exception in worker process web-1 | Traceback (most recent call last): web-1 | File "/usr/local/lib/python3.11/site-packages/llama_index/storage/kvstore/mongodb_kvstore.py", line 69, in from_uri web-1 | from motor.motor_asyncio import AsyncIOMotorClient web-1 | ModuleNotFoundError: No module named 'motor' web-1 | web-1 | During handling of the above exception, another exception occurred:
filename_without_ext = "bla": index = initialize_index(model) filters = MetadataFilters(filters=[ExactMatchFilter(key="doc_id", value=filename_without_ext)]) document_is_not_indexed = len( index.as_retriever(filters=filters, similarity_top_k=1).retrieve("some text"), ) == 0