Find answers from the community

s
F
Y
a
P
Updated last year

hey guys struggling to get the

hey guys, struggling to get the MongoDocument/IndexStores working as expected. Here's some code if anyone has any tips?: 🧵
H
L
6 comments
Plain Text
    doc_store = MongoDocumentStore.from_uri(uri="mongodb://root:password@localhost:27017", db_name="documents",
                                           namespace="123")
    index_store = MongoIndexStore.from_uri(uri="mongodb://root:password@localhost:27017", db_name="indices",
                                           namespace="123")
    storage_context = StorageContext.from_defaults(docstore=doc_store, index_store=index_store)
    
    index = load_index_from_storage(storage_context=storage_context, index_id="c03a154f-7757-4cbd-853a-99e0410f8b0b")
    response = index.as_query_engine().query(query_text)
    return str(response), 200
Plain Text
Loading indices with ids: ['c03a154f-7757-4cbd-853a-99e0410f8b0b']
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/embeddings
message='Request to OpenAI API' method=post path=https://api.openai.com/v1/embeddings
DEBUG:openai:api_version=None data='{"input": ["what did we get billed this month"], "model": "text-embedding-ada-002", "encoding_format": "base64"}' message='Post details'
api_version=None data='{"input": ["what did we get billed this month"], "model": "text-embedding-ada-002", "encoding_format": "base64"}' message='Post details'
DEBUG:urllib3.util.retry:Converted retries value: 2 -> Retry(total=2, connect=None, read=None, redirect=None, status=None)
Converted retries value: 2 -> Retry(total=2, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.openai.com:443
Starting new HTTPS connection (1): api.openai.com:443
DEBUG:urllib3.connectionpool:https://api.openai.com:443 "POST /v1/embeddings HTTP/1.1" 200 None
https://api.openai.com:443 "POST /v1/embeddings HTTP/1.1" 200 None
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=182 request_id=85199d391c20430c262aa1fa87aae470 response_code=200
message='OpenAI API response' path=https://api.openai.com/v1/embeddings processing_ms=182 request_id=85199d391c20430c262aa1fa87aae470 response_code=200
DEBUG:llama_index.indices.utils:> Top 0 nodes:

> Top 0 nodes:

INFO:llama_index.token_counter.token_counter:> [retrieve] Total LLM token usage: 0 tokens
> [retrieve] Total LLM token usage: 0 tokens
INFO:llama_index.token_counter.token_counter:> [retrieve] Total embedding token usage: 7 tokens
> [retrieve] Total embedding token usage: 7 tokens
INFO:llama_index.token_counter.token_counter:> [get_response] Total LLM token usage: 0 tokens
> [get_response] Total LLM token usage: 0 tokens
INFO:llama_index.token_counter.token_counter:> [get_response] Total embedding token usage: 0 tokens
> [get_response] Total embedding token usage: 0 tokens
INFO:werkzeug:127.0.0.1 - - [31/May/2023 16:03:58] "GET /query?text=what%20did%20we%20get%20billed%20this%20month HTTP/1.1" 200 -
127.0.0.1 - - [31/May/2023 16:03:58] "GET /query?text=what%20did%20we%20get%20billed%20this%20month HTTP/1.1" 200 -
Response: None
Was the docstore/index struct initially created on mongodb using llama index?

tbh I still need to try the mongo docstore stuff lol but it looks like it's failing to find nodes. Maybe the index struct has no nodes listed for some reason?
Hey @Logan M thanks for getting back to me - the docstore is created as such from s3 documents:

Plain Text
    documents = loader.load_data()

    # parse the documents into nodes and store them in mongodb
    parser = SimpleNodeParser()
    nodes = parser.get_nodes_from_documents(documents)

    docstore = MongoDocumentStore.from_uri(uri="mongodb://root:password@localhost:27017", db_name="documents",
                                           namespace="123")
interestingly - I'm getting results when I index using the GPTListIndex, just not from vector or keyword?
Add a reply
Sign up and join the conversation on Discord