Skip to content

Commit 1109e9c

Browse files
committed
update
1 parent 43c40a2 commit 1109e9c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Python/CosmosDB-NoSQL_VectorSearch/CosmosDB-NoSQL-Quickstart-RAG-Chatbot.ipynb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,26 +471,23 @@
471471
" return response.model_dump()\n",
472472
"\n",
473473
"def chat_completion(cache_container, movies_container, user_input):\n",
474-
"\n",
474+
" print(\"starting completion\")\n",
475475
" # Generate embeddings from the user input\n",
476476
" user_embeddings = generate_embeddings(user_input)\n",
477477
" # Query the chat history cache first to see if this question has been asked before\n",
478-
" cache_results = vector_search(container = cache_container, vectors = user_embeddings, similarity_score=0.99, num_results=1)\n",
479-
"\n",
478+
" cache_results = get_cache(container = cache_container, vectors = user_embeddings, similarity_score=0.99, num_results=1)\n",
480479
" if len(cache_results) > 0:\n",
481-
" print(\"\\n Cached Result\\n\")\n",
482-
" return cache_results[0]['document']['completion']\n",
480+
" print(\"Cached Result\\n\")\n",
481+
" return cache_results[0]['completion'], True\n",
483482
" \n",
484483
" else:\n",
485-
" \n",
486484
" #perform vector search on the movie collection\n",
487-
" print(\"\\n New result\\n\")\n",
485+
" print(\"New result\\n\")\n",
488486
" search_results = vector_search(movies_container, user_embeddings)\n",
489487
"\n",
490488
" print(\"Getting Chat History\\n\")\n",
491489
" #chat history\n",
492490
" chat_history = get_chat_history(cache_container, 3)\n",
493-
"\n",
494491
" #generate the completion\n",
495492
" print(\"Generating completions \\n\")\n",
496493
" completions_results = generate_completion(user_input, search_results, chat_history)\n",
@@ -501,7 +498,7 @@
501498
"\n",
502499
" print(\"\\n\")\n",
503500
" # Return the generated LLM completion\n",
504-
" return completions_results['choices'][0]['message']['content'] "
501+
" return completions_results['choices'][0]['message']['content'], False"
505502
]
506503
},
507504
{

0 commit comments

Comments
 (0)