john0isaac / rag-semantic-kernel-mongodb-vcore

A sample for implementing retrieval augmented generation using Azure Open AI to generate embeddings, Azure Cosmos DB for MongoDB vCore to perform vector search, and semantic kernel.
https://techcommunity.microsoft.com/t5/educator-developer-blog/build-rag-chat-application-using-azure-openai-and-cosmos-db-for/ba-p/4055852
MIT License
32 stars 52 forks source link

while Creating or Updating Azure Cosmos DB for MongoDB, im getting this error #28

Closed Vamshikrishnaredd closed 3 months ago

Vamshikrishnaredd commented 3 months ago

InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus

Vamshikrishnaredd commented 3 months ago

Cell In[201], line 13 10 print("Creating or updating Azure Cosmos DB Memory Store...") 11 # create azure cosmos db for mongo db vcore api store and collection with vector ivf 12 # currently, semantic kernel only supports the ivf vector kind ---> 13 store = await AzureCosmosDBMemoryStore.create( 14 cosmos_connstr=os.environ.get("AZCOSMOS_CONNSTR"), 15 cosmos_api="mongo-vcore", 16 database_name=os.environ.get("AZCOSMOS_DATABASE_NAME"), 17 collection_name=collection_name, 18 index_name=index_name, 19 vector_dimensions=vector_dimensions, 20 num_lists=num_lists, 21 similarity=similarity, 22 kind=kind, 23 m=m, 24 ef_construction=ef_construction, 25 ef_search=ef_search, 26 ) 27 print("Finished updating Azure Cosmos DB Memory Store...")

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\semantic_kernel\connectors\memory\azure_cosmosdb\azure_cosmos_db_memory_store.py:102, in AzureCosmosDBMemoryStore.create(database_name, collection_name, vector_dimensions, num_lists, similarity, kind, m, ef_construction, ef_search, index_name, cosmos_connstr, application_name, cosmos_api, env_file_path) 96 if cosmos_api == "mongo-vcore": 97 cosmosdb_settings = AzureCosmosDBSettings.create( ... 86 ) 88 user, _, passwd = userinfo.partition(":") 89 # No password is expected with GSSAPI authentication.

InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus

john0isaac commented 3 months ago

@Vamshikrishnaredd thank you for reporting! Seems like an issue with the semantic kernel memory connector, will look more into that and get back to you.

Vamshikrishnaredd commented 3 months ago

@john0isaac thanks for the response.

john0isaac commented 3 months ago

There is no issue with the semantic kernel connectors.

Your (Azure Cosmos DB)connection string contains special characters (i.e @, #, $) that needs to be escaped. Check this guide on escaping username and password from pymongo

Short solution: username = urllib.parse.quote_plus(YOUR_USERNAME) password = urllib.parse.quote_plus(YOUR_PASSOWORD) connection_string = 'mongodb://%s:%s@127.0.0.1' % (username, password)