Skip to content

vector_search_words bug #9

@andresmgonzalezbizagi

Description

@andresmgonzalezbizagi

Checking the "Load Azure Cosmos DB for NoSQL" topic the last step "Execute a Vector Search with the loaded data" fails because the method "vector_search_words" from file "main_nosql.py" has two bugs. First the method doesn't set the container so the property "_ctrproxy" is never set and fail on "vector_search" method call. also the call for "vector_search" has wrong parameters and build the cosmosdb query wrong.

Here is my fix to the currently problem:

`

async def vector_search_words(natural_language):
    try:
    ai_svc = AiService()
    resp = ai_svc.generate_embeddings(natural_language)
    embedding = resp.data[0].embedding

    nosql_svc = CosmosNoSQLService()
    await nosql_svc.initialize()

    cname = "libraries"
    nosql_svc.set_container(cname)

    docs = await nosql_svc.vector_search(embedding)
    for idx, doc in enumerate(docs):
        print("doc {}: {}".format(idx, doc))

except Exception as e:
    logging.info(str(e))
    logging.info(traceback.format_exc())
await nosql_svc.close()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions