3636
3737
3838# collection name will be used multiple times in the code so we store it in a variable
39- database_name = os .getenv ("AZURE_COSMOS_DATABASE_NAME" )
40- collection_name = os .getenv ("AZURE_COSMOS_COLLECTION_NAME" )
39+ database_name = os .getenv ("AZURE_COSMOS_DATABASE_NAME" , "semanticKernel" )
40+ collection_name = os .getenv ("AZURE_COSMOS_COLLECTION_NAME" , "textMemory" )
4141
4242# Vector search index parameters
4343index_name = os .getenv ("AZURE_COSMOS_INDEX_NAME" , "VectorSearchIndex" )
5252
5353def get_mongo_connection_string () -> str :
5454 mongo_connection_string = os .getenv ("AZURE_COSMOS_CONNECTION_STRING" , "<YOUR-COSMOS-DB-CONNECTION-STRING>" )
55- mongo_username = quote_plus (os .getenv ("AZURE_COSMOS_USERNAME" ))
56- mongo_password = quote_plus (os .getenv ("AZURE_COSMOS_PASSWORD" ))
55+ mongo_username = quote_plus (os .getenv ("AZURE_COSMOS_USERNAME" , "admin" ))
56+ mongo_password = quote_plus (os .getenv ("AZURE_COSMOS_PASSWORD" , "password" ))
5757 return mongo_connection_string .replace ("<user>" , mongo_username ).replace ("<password>" , mongo_password )
5858
5959
@@ -76,9 +76,9 @@ async def prompt_with_rag_or_vector(query_term: str, option: str) -> str:
7676def initialize_sk_chat_embedding () -> Kernel :
7777 kernel = Kernel ()
7878 # adding azure openai chat service
79- chat_model_deployment_name = os .environ . get ("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME" ) or "chat-deployment"
80- endpoint = os .environ . get ("AZURE_OPENAI_ENDPOINT" ) or "https://test-endpoint.openai.com/"
81- api_key = os .environ . get ("AZURE_OPENAI_API_KEY" ) or "VerySecretApiKey"
79+ chat_model_deployment_name = os .getenv ("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME" , "chat-deployment" )
80+ endpoint = os .getenv ("AZURE_OPENAI_ENDPOINT" , "https://test-endpoint.openai.com/" )
81+ api_key = os .getenv ("AZURE_OPENAI_API_KEY" , "VerySecretApiKey" )
8282
8383 kernel .add_service (
8484 AzureChatCompletion (
@@ -91,9 +91,7 @@ def initialize_sk_chat_embedding() -> Kernel:
9191 logging .info ("Added Azure OpenAI Chat Service..." )
9292
9393 # adding azure openai text embedding service
94- embedding_model_deployment_name = (
95- os .environ .get ("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME" ) or "embedding-deployment"
96- )
94+ embedding_model_deployment_name = os .getenv ("AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME" , "embedding-deployment" )
9795
9896 kernel .add_service (
9997 AzureTextEmbedding (
@@ -117,11 +115,11 @@ async def initialize_sk_memory_store(
117115 try :
118116 logging .info ("Creating or updating Azure Cosmos DB Memory Store..." )
119117 store = await AzureCosmosDBMemoryStore .create (
120- cosmos_connstr = get_mongo_connection_string () or "mongodb://localhost:27017" ,
118+ cosmos_connstr = get_mongo_connection_string (),
121119 cosmos_api = "mongo-vcore" ,
122- database_name = database_name or "semanticKernel" ,
123- collection_name = collection_name or "textMemory" ,
124- index_name = index_name or "VectorSearchIndex" ,
120+ database_name = database_name ,
121+ collection_name = collection_name ,
122+ index_name = index_name ,
125123 vector_dimensions = vector_dimensions ,
126124 num_lists = num_lists ,
127125 similarity = similarity ,
@@ -160,7 +158,7 @@ async def grounded_response(kernel: Kernel) -> KernelFunction:
160158 User: {{$query_term}}
161159 Chatbot:"""
162160
163- chat_model_deployment_name = os .environ . get ("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME" )
161+ chat_model_deployment_name = os .getenv ("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME" , "chat-deployment " )
164162
165163 execution_settings = OpenAITextPromptExecutionSettings (
166164 service_id = "chat_completion" ,
0 commit comments