diff --git a/.env.example b/.env.example index 1681f46..787355b 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ -OPENAI_API_VERSION = "2023-09-01-preview" -OPENAI_EMBEDDING_API_VERSION = "2023-05-15" +OPENAI_API_VERSION = "2024-07-01-preview" +OPENAI_EMBEDDING_API_VERSION = "2024-07-01-preview" AZURE_OPENAI_API_KEY = "" AZURE_OPENAI_ENDPOINT = "" diff --git a/.gitignore b/.gitignore index cfe4d4e..2671f76 100644 --- a/.gitignore +++ b/.gitignore @@ -414,4 +414,4 @@ solutions/AzureOpenAIUtil/ # Qdrant .lock -labs/03-orchestration/03-Qdrant/qdrantstorage/** +labs/03-orchestration/03-VectorStore/qdrantstorage/** diff --git a/labs/02-integrating-ai/00-PythonModules/pythonmodules.ipynb b/labs/02-integrating-ai/00-PythonModules/pythonmodules.ipynb index 1ad9791..727ca63 100644 --- a/labs/02-integrating-ai/00-PythonModules/pythonmodules.ipynb +++ b/labs/02-integrating-ai/00-PythonModules/pythonmodules.ipynb @@ -55,7 +55,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/02-integrating-ai/01-AzureOpenAIAPI/azureopenaiapi.ipynb b/labs/02-integrating-ai/01-AzureOpenAIAPI/azureopenaiapi.ipynb index 0fdb663..ef7f739 100644 --- a/labs/02-integrating-ai/01-AzureOpenAIAPI/azureopenaiapi.ipynb +++ b/labs/02-integrating-ai/01-AzureOpenAIAPI/azureopenaiapi.ipynb @@ -7,11 +7,7 @@ "source": [ "# 01 - Working with the Azure OpenAI API directly\n", "\n", - "In this lab, we will perform a couple of simple calls to the Azure OpenAI API.\n", - "- The first call will allow us to find out which Model Deployments are available for the Azure OpenAI API.\n", - "- The second call will send a prompt to the Azure OpenAI API.\n", - "\n", - "This will also prove that everything is setup correctly and working for the rest of the labs.\n", + "In this lab, we will perform a simple call to the Azure OpenAI API. This will prove that everything is setup correctly and working for the rest of the labs.\n", "\n", "## Setup\n", "\n", @@ -194,7 +190,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.5" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/02-integrating-ai/02-OpenAIPackages/openai.ipynb b/labs/02-integrating-ai/02-OpenAIPackages/openai.ipynb index a49fd25..00ea328 100644 --- a/labs/02-integrating-ai/02-OpenAIPackages/openai.ipynb +++ b/labs/02-integrating-ai/02-OpenAIPackages/openai.ipynb @@ -34,7 +34,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Next, we'll start to bring in the values from our `.env` file." + "Next, we'll bring in the values from our `.env` file." ] }, { @@ -57,7 +57,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We'll create a new `AzureOpenAI` object and pass in the API key and version and the endpoint URL to be used." + "We'll create a new `AzureOpenAI` object and pass in the API key, API version and the endpoint URL to be used." ] }, { @@ -168,7 +168,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/02-integrating-ai/03-Langchain/langchain.ipynb b/labs/02-integrating-ai/03-Langchain/langchain.ipynb index 39e732a..2e4801c 100644 --- a/labs/02-integrating-ai/03-Langchain/langchain.ipynb +++ b/labs/02-integrating-ai/03-Langchain/langchain.ipynb @@ -272,7 +272,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/02-integrating-ai/04-SemanticKernel/semantickernel.ipynb b/labs/02-integrating-ai/04-SemanticKernel/semantickernel.ipynb index 45a162f..2cc82e1 100644 --- a/labs/02-integrating-ai/04-SemanticKernel/semantickernel.ipynb +++ b/labs/02-integrating-ai/04-SemanticKernel/semantickernel.ipynb @@ -32,7 +32,7 @@ }, "outputs": [], "source": [ - "#r \"nuget: dotenv.net, 3.1.2\"\n", + "#r \"nuget: dotenv.net, 3.2.0\"\n", "\n", "using dotenv.net;\n", "\n", @@ -76,7 +76,7 @@ }, "outputs": [], "source": [ - "#r \"nuget: Microsoft.SemanticKernel, 1.10.0\"" + "#r \"nuget: Microsoft.SemanticKernel, 1.19.0\"" ] }, { @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -125,6 +125,12 @@ "cell_type": "code", "execution_count": null, "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + }, "vscode": { "languageId": "polyglot-notebook" } @@ -144,7 +150,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -213,7 +219,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "dotnet_interactive": { "language": "csharp" @@ -286,10 +292,26 @@ } ], "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, "language_info": { "name": "python" }, - "orig_nbformat": 4 + "orig_nbformat": 4, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "name": "csharp" + } + ] + } + } }, "nbformat": 4, "nbformat_minor": 2 diff --git a/labs/03-orchestration/01-Tokens/tokens.ipynb b/labs/03-orchestration/01-Tokens/tokens.ipynb index 4588f90..5c1fbbe 100644 --- a/labs/03-orchestration/01-Tokens/tokens.ipynb +++ b/labs/03-orchestration/01-Tokens/tokens.ipynb @@ -62,9 +62,9 @@ "\n", "| Encoding name | Azure OpenAI Service models |\n", "| ------------- | -------------- |\n", - "| gpt2 (or r50k_base) | Most GPT-3 models |\n", + "| cl100k_base | gpt-4, gpt-3.5-turbo, text-embedding-ada-002, text-embedding-3-small, text-embedding-3-large |\n", "| p50k_base | Code models, text-davinci-002, text-davinci-003 |\n", - "| cl100k_base | text-embedding-ada-002 |\n", + "| r50k_base (or gpt2) | Most GPT-3 models |\n", "\n", "You can use `tiktoken` as follows to tokenize a string and see what the output looks like." ] @@ -77,7 +77,7 @@ "source": [ "import tiktoken\n", "\n", - "encoding = tiktoken.get_encoding(\"p50k_base\")\n", + "encoding = tiktoken.get_encoding(\"cl100k_base\")\n", "encoding.encode(\"Hello world, this is fun!\")" ] }, @@ -141,7 +141,7 @@ "metadata": {}, "outputs": [], "source": [ - "def get_num_tokens_from_string(string: str, encoding_name: str='p50k_base') -> int:\n", + "def get_num_tokens_from_string(string: str, encoding_name: str='cl100k_base') -> int:\n", " \"\"\"Returns the number of tokens in a text by a given encoding.\"\"\"\n", " encoding = tiktoken.get_encoding(encoding_name)\n", " return len(encoding.encode(string))\n", @@ -183,7 +183,7 @@ "content = open(movie_data, \"r\", encoding=\"utf-8\").read()\n", "\n", "# Use tiktoken to tokenize the content and get a count of tokens used.\n", - "encoding = tiktoken.get_encoding(\"p50k_base\")\n", + "encoding = tiktoken.get_encoding(\"cl100k_base\")\n", "print (f\"Token count: {len(encoding.encode(content))}\")" ] }, @@ -199,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -245,7 +245,7 @@ "source": [ "You can see we've output the first few lines of the prompt and we've printed the overall size (in characters) of the prompt. Now, let's see what happens if we submit that query to the AI.\n", "\n", - "**NOTE:** Don't be surprised to see an error message!" + "**NOTE:** This exercise is intended to fail, but it does depend on the model you're using. Some newer models have a higher token limit than others. If you're using a model with a high token limit, you might want to increase the size of the `movies.csv` file to make this fail, or you could try using a different model." ] }, { @@ -322,7 +322,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/03-orchestration/02-Embeddings/data/movies/Ant-Man and the Wasp - Quantumania.md b/labs/03-orchestration/02-Embeddings/data/movies/Ant-Man and the Wasp - Quantumania.md deleted file mode 100644 index eeeba04..0000000 --- a/labs/03-orchestration/02-Embeddings/data/movies/Ant-Man and the Wasp - Quantumania.md +++ /dev/null @@ -1,18 +0,0 @@ -# Ant-Man and the Wasp: Quantumania - -## Overview - - Super-Hero partners Scott Lang and Hope van Dyne, along with with Hope's parents Janet van Dyne and Hank Pym, and Scott's daughter Cassie Lang, find themselves exploring the Quantum Realm, interacting with strange new creatures and embarking on an adventure that will push them beyond the limits of what they thought possible. - -## Details - -**Release Date:** 2023-02-15 - -**Genres:** Action, Adventure, Science Fiction - -**Popularity:** 525.418 - -**Vote Average:** 6.5 - -**Keywords:** hero, ant, sequel, superhero, based on comic, family, superhero team, aftercreditsstinger, duringcreditsstinger - diff --git a/labs/03-orchestration/02-Embeddings/data/movies/Deadpool & Wolverine.md b/labs/03-orchestration/02-Embeddings/data/movies/Deadpool & Wolverine.md new file mode 100644 index 0000000..ef3c502 --- /dev/null +++ b/labs/03-orchestration/02-Embeddings/data/movies/Deadpool & Wolverine.md @@ -0,0 +1,210 @@ +# Deadpool & Wolverine + +## Overview + + A listless Wade Wilson toils away in civilian life with his days as the morally flexible mercenary, Deadpool, behind him. But when his homeworld faces an existential threat, Wade must reluctantly suit-up again with an even more reluctant Wolverine. + +## Details + +**Release Date:** 2024-07-24 + +**Genres:** Action, Comedy, Science Fiction + +**Popularity:** 2617.082 + +**Vote Average:** 7.728 + +**Keywords:** hero, superhero, anti hero, mutant, breaking the fourth wall, mutants, superhero teamup + +## Reviews + +**Review by** shammahrashad + +**Rating:** 6.0 + +Theres not much of a plot and the villains weren't that great. It was a good laugh though and amazing cameos and fight scenes. + +--- + +**Review by** r96sk + +**Rating:** 9.0 + +Its story may not be the strongest, but the comedy makes 'Deadpool & Wolverine' an excellent watch! + +There are some top notch gags in there, particularly to do with the recent offscreen changes for Wade Wilson's alter ego. As you'd expect with Ryan Reynolds in this role, the jokes are plentiful and there is barely any time to react to one before another appears. That can sometimes not work as well as intended, e.g. 'Deadpool 2', but here the humour is executed perfectly. + +Reynolds himself is quality, it is a quintessential Ryan Reynolds as Deadpool performance. It's real neat to see Hugh Jackman back as Wolverine, he does play second fiddle to the other titular character but still more than holds his own, as you'd expect. Emma Corrin, meanwhile, enters with a great showing. + +As noted at the top, I do think the plot couldn't been superior - but not in a negative way. What is portrayed is still entertaining to watch, it's just not necessarily on the same level as the comedic elements. A fun watch, all the same. Do I like it more than the 2016 original? I think so, would only be minorly so though. + +--- + +**Review by** Chris Sawin + +**Rating:** 8.0 + +_Deadpool & Wolverine_ is the best there has been since Guardians of the Galaxy Vol. 3. It’s two hours of comic book-driven fan service and delivers entertaining surprises, nostalgic throwbacks, memorable action sequences, and worthwhile performances. + +**Full review:** https://bit.ly/WadeLogan + +--- + +**Review by** Brent Marchant + +**Rating:** 6.0 + +In moviemaking, sadly, there can be a problem with going to the well too many times, and this latest installment in one of filmdom’s better cinematic franchises verges on proving just that. This offering’s predecessors (2016, 2018) significantly distinguished themselves from the kind of fare typically found in the superhero genre with their outrageously bawdy humor, hilarious sight gags and relentlessly maverick attitude. This time out, however, director Shawn Levy’s latest effort is a decidedly hit or miss affair, with an often-incoherent script that feels like it was cobbled together from a collection of leftover parts, some of which work and some of which don’t. I suppose that’s not entirely surprising from a screenplay that was penned by four different writers, making me wonder how much consensus was in place in compiling the finished product. Moreover, this film appears to be intended to fold the Deadpool franchise into the X-Men franchise, an intriguing idea that, regrettably, is handled rather clumsily. And, if all that weren’t bad enough, this release gives short shrift to the colorful cast of supporting players that made the Deadpool films so funny, original and enjoyable, relegating them to little more than cameos in favor of walk-ons by a host of other characters (some of them remarkably obscure, I might add) in an attempt to help cement the franchise cross-pollination going on here. It makes for awkward storytelling at times, especially for viewers who might not be familiar with these lesser-known figures, some of which are drawn from source material unrelated to its big screen offerings. To the picture’s credit, it features yet another stellar turn by Ryan Reynolds as the off-color protagonist, as well as its share of hilarious bits (without a doubt the franchise’s historically strongest suit), including a number of unabashed, razor-sharp asides referencing off-screen developments related to the studios that produced these films and the actors who have appeared in them. These strengths notwithstanding, however, this is a production that has sadly watered down the elements that best made this franchise work in favor of an overarching programming agenda that simply doesn’t serve this film or the series particularly well. The creators would have served themselves and viewers better by sticking with what works and the basics of good storytelling than trying to force an issue for the sake of future productions that may or may not work over the long term. This has been a noticeable downfall in the quality of many of the most recent releases, and I’d truly hate to see this franchise befall a similar fate. + +--- + +**Review by** Sean + +**Rating:** 10.0 + +Such a fun watch, maybe one of the best experiences I've had in a theater. I couldn't have asked for a better ending to 24 year old franchise. + +--- + +**Review by** CinemaSerf + +**Rating:** 7.0 + +Well the "Deadpool" concept is now well and truly immersed in the multi-verse and I really did fear for good old "Dead". More of the same? Well, no actually. Ryan Reynolds has reverted more to the occasionally quite vulgar humour of the first film (2016) and allowed this trequel to focus more on the personality of this irreverent, immortal, superhero as he tries to resurrect the recently departed "Wolverine/Logan" (Hugh Jackman) so he can save his timeline from erasure. To do that, and thwart the comically menacing "Paradox" (Matthew Macfadyen), he has to face down "Cassandra Nova" (Emma Corrin) - who happens to be the long estranged twin sister of "Xavier" who presides over the void. That's a "Mad Max" style desert style territory where all the undesirables have been put by "Paradox" and his organisation over the years. Initially, there's no love lost between our two heroes. The cocky man in red lycra does not impress his new, booze-soaked and guilt-ridden buddy, but quickly they manage to align their priorities and then - well yes, you can guess the rest. Indeed, there's nothing remotely unpredictable about any of this, but what it does do is shout loudly and proudly that it knows it. It's not trying to reinvent the wheel, it's succeeding in pointing out that all of these multi-verse films that simply adjust the space/time continuum to provide a new setting for the same old stories ad characters has to stop before we (the audience) bore further of their repetitive combat cycles and nondescript plot lines. Maybe Reynolds does over-egg the smuttiness a little but there are still plenty of wry comments about the industry, product placement and the plethora of films (and actors) that have preceded it delivering same old same old. It's not forgotten to entertain us too - there are loads of action scenes and there's an amiable chemistry between two actors who are clearly on the same, suitably sarcastic, page throughout a two hours that also features a some fun cameos from the likes of Messrs. Evans, Snipes, Cavill, Favreau and Tatum to keep it moving along with an effervescence of spirit. It's a big screen essential, there's a lot of effort gone into the production that won't work so well on the telly, and I enjoyed it. + +--- + +**Review by** TheSceneSnobs + +**Rating:** 8.0 + +Deadpool and Wolverine is a movie that I truly believe has been needed for a while. After years of lackluster installments, this film is a breath of fresh air. Ryan Reynolds, Hugh Jackman, and director Shawn Levy approached this project with care and a deep understanding of what fans want. The film feels like it was crafted by fans for fans, particularly those who have been frustrated by the recent phases. + +Reynolds and Levy brought on a team of writers with a strong background in comedy and storytelling. This decision pays off, as the film’s humor and narrative are both sharp and engaging. For example, the meta vibe of Deadpool, familiar from the previous two films, is ramped up significantly. The movie spares no one, making jokes about everything from Hugh Jackman’s recent divorce to Ryan Reynolds' career. However, it’s the universe that receives the most pointed and critical jokes, which will resonate with long-time fans. + +The chemistry between Reynolds and Jackman is electric, bringing new life to both characters. Their dynamic is both hilarious and heartfelt, making for a compelling narrative. For instance, scenes where Deadpool and Wolverine banter while taking down enemies are filled with wit and energy, showcasing their unique bond. This camaraderie extends to the film’s supporting cast, with well-timed cameos and clever nods to previous movies. + +The film's self-awareness and willingness to poke fun at its own franchise are refreshing. This level of meta-commentary sets the film apart from typical superhero fare. + +Despite its comedic approach, the film doesn’t skimp on emotional depth. The storyline is carried by genuine heart, particularly in how it addresses themes of redemption and friendship. The climax is especially impactful, ranking among the greats in the franchise. + +This isn't just a good sequel; it's a game-changer. The film successfully integrates Deadpool into the broader universe while maintaining his unique tone and style. It sets the stage for future installments, promising exciting developments ahead. The way the film navigates these transitions feels seamless, ensuring that Deadpool’s irreverent humor doesn’t clash with the established tone. + +Overall, Deadpool and Wolverine is a standout entry, offering a perfect blend of humor, action, and heart. Ryan Reynolds and Hugh Jackman deliver top-notch performances, supported by a smart script and deft direction from Shawn Levy. This film not only redeems past missteps in the franchise but also paves the way for a promising future. It’s a must-watch for any fan, filled with laughter, thrills, and touching moments that elevate it above many of its predecessors. + +--- + +**Review by** GenerationofSwine + +**Rating:** 10.0 + +It feels a bit rushed... but then it was rushed. It feels a bit neutered, but it's now Disney and they did muzzle it. + +The thing is though... it's not woke, which is why you have articles criticizing it for "Not Being Gay Enough" and in 2024, that very literally translates to: "They focused on a story and characters rather than a political agenda and we're mad about it." Which, in turn, translates to "Actually entertaining." + +It's amazing how articles complaining about a movie not being Gay enough can guarantee you that the movie is going to be good. + +Only.... it's meh. I mean, when you compare it to most of the movies this year it's pretty epic. When you compare it to most of the post 2016 movies this is one of the greatest things ever made... but when you compare it to the other Deadpool movies it's rushed. + +But... who cares, it literally doesn't have a point other than entertaining you, and that is really all that matters and all that I ask for. + +Is it a cash grab? Yes, and I will GLADLY give them my money for another movie that just wants to entertain. And if they make another movie that wants to entertain and not push an agenda, I will gladly give them MORE of my money... because at the end of the day, entertainment has been in a decade long drought brought to you by political lecturing and nerd domains have been intentionally attacking fans rather than making movies, like this, that make fans want to give them their money. + +So when a movie like this comes along, it is a wonderful thing. + +--- + +**Review by** JPV852 + +**Rating:** 7.0 + +Satisfying and 100% fan-service. Hugh Jackman still is awesome as Wolverine and gives it his all, along with Ryan Reynolds, both showing passion for the characters. That said, much like Deadpool 2, I'm not sure if I have much desire to revisit anytime soon. **3.5/5** + +--- + +**Review by** Pringo + +**Rating:** 10.0 + +I just watched Deadpool & Wolverine, and wow, it was an absolute blast! Ryan Reynolds and Hugh Jackman have incredible chemistry that makes the whole movie work. Deadpool's irreverent humor and Wolverine's gruff seriousness balance each other perfectly. The film is packed with hilarious jokes, epic action sequences, and so many Easter eggs that comic book fans will be thrilled. + +The opening sequence had me hooked right away, with a mix of intense fighting and Deadpool's signature humor. The constant fourth-wall breaks were spot-on and kept the laughs coming. It's a fantastic tribute to both characters and their histories, with plenty of nods to past films and comics. + +If you're a fan of either character, this movie is a must-see. It's not just a fun ride; it's a love letter to the fans. The pacing is perfect, and the two hours flew by. Whether you're a casual viewer or a hardcore fan, Deadpool & Wolverine delivers on all fronts. Don't miss it! + +--- + +**Review by** DonGable + +**Rating:** 4.0 + +For devout fans only. + +Here is a test for franchise films: Remove the IP and characters to see if the story, character development, etc. stands on its own without using the IP as a crutch. +If you remove the IP in this case, you have absolutely nothing. + +If you've seen a lot of previous films in this universe, you will be treated with an abundance of fan service. Admittedly, I have not watched a lot of these films. I have, however, watched the first two Deadpool entries. I enjoyed them at the time, especially the first one. + +In this third entry, you will find a lot of cameos which are absolutely pointless, except for people to chug memberberries, as they do absolutely nothing with these characters. It doesn't even properly show the backstory of Wolverine. +This film is an almost non-stop barrage of bickering and snarky jokes, but it's never given any time at all to breathe. The few moments where it actually tries to convey emotion, it never truly lands, as all it wants to do is tell jokes. Did I laugh here and there? Sure. But I can count it on one hand. + +The villain and plot quite forgettable, and you never truly feel that something's at stake, as the threat is mainly conveyed as a progress bar on a screen... + +Even though some people might enjoy Deadpool taking potshots, Disney knows exactly what they're doing, and they will be laughing all the way to the bank. Corporate brand maintenance is all it is. + +--- + +**Review by** aGoryLouie + +**Rating:** 8.0 + +the definition of fun + +--- + +**Review by** davidrobitaille + +**Rating:** 10.0 + +I went to see Deadpool & Wolverine last evening and boy did it feel refreshing to see Ryan Reynolds making all of these funny jokes on screen as Deadpool. There were a lot of mentions of comic books, jokes about production companies & about production crew/cast (extras, etc). As someone who's passionate about this industry and is very active in the business, this film is a big success in my opinion. I loved that we got to see Jon Favreau as Happy Hogan in the intro of the film, just sad we didn't get a little Tony Stark (RDJ) appearance, but hey, it's not his movie after all (RIP Iron Man). + +--- + +**Review by** tmdb51616167 + +**Rating:** 9.0 + +Finally, the moment I have been eagerly waiting for has arrived - the new film featuring Deadpool and Wolverine! I am thrilled to share my thoughts on this without revealing any spoilers, so brace yourself for a fairly tame review to keep the surprise intact for everyone. + +They are back in its element with this movie, as it takes a playful jab at itself. Deadpool boldly declares that the Multiverse is a mess and proposes putting an end to it - a refreshing take on the superhero genre. + +The dance sequence is a hilarious throwback to the 90s, adding a touch of nostalgia and charm to the film. And yes, there is plenty of colorful language, including an abundance of the infamous F word - but then again, what else would you expect from Deadpool? + +Prepare to be amazed by some incredible cameos that will leave you jumping out of your seat with excitement, especially if you have a soft spot for certain characters from the past. This movie is an absolute thrill ride that pays homage to the Fox universe and its beloved characters. + +Without giving too much away, there is a surprising appearance by a fan-favorite character who never made it to the superhero league, and the moment is truly jaw-dropping. The storyline may seem chaotic, but that's all part of the Deadpool charm. + +While the villain could have been utilized more effectively given their power, the relationship between Deadpool and Wolverine is beautifully portrayed. The film does a commendable job of explaining the backstory and the humor is on point, with Deadpool's witty jabs and references adding to the entertainment. + +If you're a fan of Deadpool and his legacy, this movie is a must-watch that will blow your mind. Just be warned, there is a fair amount of profanity, so consider this if you're planning to bring along younger viewers. + +Overall, this movie was a blast and one of the most enjoyable experiences in recent memory. From the creative storytelling to the hilarious antics, it's a wild ride that you won't want to miss. And don't forget to stick around for the mid-credits and end-credits scenes for an extra dose of fun and closure to the film. Enjoy the laugh-filled ride! + +--- + +**Review by** albuainain + +**Rating:** 7.0 + +Not funny as Deadpool 1 & 2, I was expecting something smashing due to the reviews I have read and people hype in social media. The fight scenes saved the movie. + +--- + +**Review by** immortal101 + +**Rating:** None + +I personally enjoyed it. It was a fresh splash of the recent flops of movies. The plot was a little disorganized, but overall great film. The nostalgia and love letter to Foxfilms was a nice touch. + +--- + diff --git a/labs/03-orchestration/02-Embeddings/embeddings.ipynb b/labs/03-orchestration/02-Embeddings/embeddings.ipynb index ac3f3c9..134234f 100644 --- a/labs/03-orchestration/02-Embeddings/embeddings.ipynb +++ b/labs/03-orchestration/02-Embeddings/embeddings.ipynb @@ -52,7 +52,7 @@ "metadata": {}, "outputs": [], "source": [ - "r = llm.invoke(\"Tell me about the latest Ant-Man movie. When was it released? What is it about?\")\n", + "r = llm.invoke(\"Tell me about the latest Deadpool movie. When was it released? What is it about?\")\n", "\n", "# Print the response\n", "print(r.content)" @@ -65,9 +65,9 @@ "source": [ "What do you notice about the response?\n", "\n", - "Depending on the model and version you are using, the AI either thinks the latest \"Ant-Man\" movie was \"Ant-Man and the Wasp\" and it was released in July 2018, or it may be aware of the movie \"Ant-Man and The Wasp: Quantumania\", but it will likely tell you this movie hasn't been released yet. So, how can we correct this information?\n", + "The latest \"Deadpool\" movie is called \"Deadpool and Wolverine\". Depending on the model and version you are using, it may tell you that one of the previous movies is the latest, or it may be aware of the new movie but think it hasn't been released yet.\n", "\n", - "OpenAI models are trained on a large set of data, but that happened at a specific point in time depending on the model. So, many of the models have no information about events that took place in recent months or years.\n", + "OpenAI models are trained on a large set of data, but that happened at a specific point in time depending on the model. So, many of the models have no information about events that took place in very recent months or years.\n", "\n", "To help the AI out, we can provide additional information. This is the same process you would follow if you want the AI to work with your own company data. The AI won't know about information that isn't publicly available, so if you want the AI to work with that information, then you'll need to get that information into the model.\n", "\n", @@ -83,7 +83,7 @@ "source": [ "## Bring Your Own Data\n", "\n", - "Langchain provides a number of useful tools, which include tools to simplify the process of working with external documents. Below, we'll use the `DirectoryLoader` which can read multiple files from a directory and the `UnstructuredMarkdownLoader` which can process files in Markdown format. We'll use these to process a bunch of markdown formatted files that contain details of movies that were released in the year 2023." + "Langchain provides a number of useful tools, which include tools to simplify the process of working with external documents. Below, we'll use the `DirectoryLoader` which can read multiple files from a directory and the `UnstructuredMarkdownLoader` which can process files in Markdown format. We'll use these to process a bunch of markdown formatted files that contain details of movies that were released more recently." ] }, { @@ -106,7 +106,7 @@ "source": [ "We now have a `documents` object which contains all of the information from our markdown documents about movies.\n", "\n", - "We can use the `question_answering` chain to provide the AI with access to our documents and then ask the same question about Ant-Man movies again." + "We can use the `question_answering` chain to provide the AI with access to our documents and then ask the same question about Deadpool movies again." ] }, { @@ -120,7 +120,7 @@ "\n", "# Prepare the chain and the query\n", "chain = load_qa_chain(llm)\n", - "query = \"Tell me about the latest Ant Man movie. When was it released? What is it about?\"\n", + "query = \"Tell me about the latest Deadpool movie. When was it released? What is it about?\"\n", "\n", "result = chain.invoke({'input_documents': documents, 'question': query})\n", "\n", @@ -132,7 +132,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Great! The model now knows the correct details for the latest Ant-Man movie.\n", + "Great! The model now knows the correct details for the latest Deadpool movie.\n", "\n", "However, there's something lurking! Let's take a look at what happened behind the scenes.\n", "\n", @@ -150,7 +150,7 @@ "\n", "# Prepare the chain and the query\n", "chain = load_qa_chain(llm, verbose=True)\n", - "query = \"Tell me about the latest Ant Man movie. When was it released? What is it about?\"\n", + "query = \"Tell me about the latest Deadpool movie. When was it released? What is it about?\"\n", "\n", "# Run the chain, using the callback to capture the number of tokens used\n", "with get_openai_callback() as callback:\n", @@ -165,7 +165,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In the output from the last code section, you should see a lot of information. At the end, you should see a count of the number of tokens used. You might be surprised to see that the query uses around 2,500 tokens. That's a lot of tokens!\n", + "In the output from the last code section, you should see a lot of information. At the end, you should see a count of the number of tokens used. You might be surprised to see that the query uses anywhere from 2,500 to 6,000 tokens, depending on the model used. That's a lot of tokens!\n", "\n", "With the verbose option enabled, the rest of the output shows the prompt that was constructed for the query. If you scroll back through the output, you'll see that the prompt included **all** of the information from our documents, so this is why the query used so many tokens.\n", "\n", @@ -189,12 +189,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Let's walk through the process of using embeddings to give the AI some details about our movies. We'll start by initiating an instance of an embeddings model. You'll notice this is similar to when we initialise one of our model deployments to run a query, but in this case we specify an embedding model. Typically the embedding model used is `text-embedding-ada-002`." + "Let's walk through the process of using embeddings to give the AI some details about our movies. We'll start by initiating an instance of an embeddings model. You'll notice this is similar to when we initialise one of our model deployments to run a query, but in this case we specify an embedding model. Typically the embedding model used has been `text-embedding-ada-002`, but there are newer alternatives available now." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -255,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -281,7 +281,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -298,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -313,9 +313,9 @@ "source": [ "Now, we'll run our query again. However, we'll make one small change.\n", "\n", - "You may be thinking that it's not surprising that the AI now knows about the latest Ant-Man movie, because we told it about the latest Ant-Man movie! So, let's try and show that the AI is actually doing some work here, after all it is a reasoning engine.\n", + "You may be thinking that it's not surprising that the AI now knows about the latest Deadpool movie, because we told it about the latest Deadpool movie! So, let's try and show that the AI is actually doing some work here, after all it is a reasoning engine.\n", "\n", - "If you're not a fan of these movies, Ant-Man originates from Marvel comic books. And the collection of movies that originate from Marvel comic books are said to be part of the Marvel Cinematic Universe, sometimes referred to as the MCU. We haven't mentioned Marvel or MCU in the data we've provided, so if we modify the query slightly and ask the AI about the MCU instead of specifically about Ant-Man, it should be able to use reasoning to figure out what we mean." + "If you're not a fan of these movies, Deadpool originates from Marvel comic books. And the collection of movies that originate from Marvel comic books are said to be part of the Marvel Cinematic Universe, sometimes referred to as the MCU. We haven't mentioned Marvel or MCU in the data we've provided, so if we modify the query slightly and ask the AI about the MCU instead of specifically about Deadpool, it should be able to use reasoning to figure out what we mean." ] }, { @@ -334,7 +334,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If all went well, the AI should have responded that the latest MCU movie is Ant-Man and the Wasp: Quantumania which was released in February 2023.\n", + "If all went well, the AI should have responded that the latest MCU movie is Deadpool & Wolverine which was released in July 2024.\n", "\n", "So, we're getting the response we expected, but let's check in on one of the reasons why we've done all of this. Has the number of tokens used been reduced? Let's use the same technique as before and employ a callback to find out." ] @@ -397,7 +397,7 @@ "metadata": {}, "outputs": [], "source": [ - "query = \"Tell me about the latest Ant Man movie. When was it released? What is it about?\"\n", + "query = \"Tell me about the latest Deadpool movie. When was it released? What is it about?\"\n", "index.query(llm=llm, question=query)" ] }, @@ -457,7 +457,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/03-orchestration/03-VectorStore/README.md b/labs/03-orchestration/03-VectorStore/README.md new file mode 100644 index 0000000..c648ad5 --- /dev/null +++ b/labs/03-orchestration/03-VectorStore/README.md @@ -0,0 +1,23 @@ +# 03 - Vector Stores + +In this folder you will find exercises showing how to work with different vector stores. We introduce concepts like Qdrant, Azure CosmosDB for MongoDB (vCore), and Azure AI Search which allow AI Orchestration to overcome the size limitation of prompts. + +Below is a list of each of the labs in this section and what each one sets out to achieve. + +## Qdrant + +[Qdrant](qdrant.ipynb) + +This lab uses a local instance of Qdrant to demonstrate how to work with a vector store. + +## Azure AI Search + +[Azure AI Search](aisearch.ipynb) + +This lab will walk you through how to use Azure AI Search as a vector store and search ranking capabilities. + +## Azure CosmosDB for MongoDB (vCore) + +[Azure CosmosDB for MongoDB (vCore)](mongo.ipynb) + +In this lab, you will see how you can use Azure CosmosDB as a vector store and as a semantic cache. diff --git a/labs/03-orchestration/03-VectorStore/aisearch.ipynb b/labs/03-orchestration/03-VectorStore/aisearch.ipynb index 975184e..3b26a13 100644 --- a/labs/03-orchestration/03-VectorStore/aisearch.ipynb +++ b/labs/03-orchestration/03-VectorStore/aisearch.ipynb @@ -122,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -146,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -185,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -220,7 +220,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -596,10 +596,14 @@ " top=5\n", "))\n", "\n", + "from langchain_core.output_parsers import StrOutputParser\n", + "\n", + "output_parser = StrOutputParser()\n", + "\n", "# Build the Prompt and Execute against the Azure OpenAI to get the completion\n", - "chain = LLMChain(llm=azure_openai, prompt=prompt, verbose=False)\n", - "response = chain.invoke({\"original_question\": query, \"search_results\": results})\n", - "print(response['text'])" + "chain = prompt | azure_openai | output_parser\n", + "response = chain.invoke(input={\"original_question\": query, \"search_results\": results})\n", + "print (response)\n" ] }, { @@ -628,7 +632,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/03-orchestration/03-VectorStore/mongo.ipynb b/labs/03-orchestration/03-VectorStore/mongo.ipynb index ea9878c..f5d74e9 100644 --- a/labs/03-orchestration/03-VectorStore/mongo.ipynb +++ b/labs/03-orchestration/03-VectorStore/mongo.ipynb @@ -1,5 +1,15 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# NOTE: Currently not working - please skip this notebook\n", + "\n", + "Last part of the notebook will fail. Issue is described here:\n", + "https://github.com/langchain-ai/langchain/issues/26097" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -18,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -50,9 +60,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found Azure OpenAI Endpoint: https://msazuredev.openai.azure.com/\n" + ] + } + ], "source": [ "import os\n", "import pymongo\n", @@ -75,9 +93,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/wl/x6qz9qm94xl_v256v8qfl1gm0000gn/T/ipykernel_78714/548968826.py:5: UserWarning: You appear to be connected to a CosmosDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/cosmosdb\n", + " cosmos_client = pymongo.MongoClient(cosmos_conn)\n" + ] + } + ], "source": [ "from langchain_openai import AzureChatOpenAI\n", "from langchain_openai import AzureOpenAIEmbeddings\n", @@ -116,7 +143,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -171,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -201,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -230,19 +257,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inserted 100 documents into collection: 'movie_data'.\n", + "Inserted 200 documents into collection: 'movie_data'.\n", + "Inserted 300 documents into collection: 'movie_data'.\n", + "Inserted 400 documents into collection: 'movie_data'.\n", + "Inserted 500 documents into collection: 'movie_data'.\n", + "Data inserted into collection: 'movie_data'.\n", + "\n" + ] + } + ], "source": [ "import urllib\n", "# open the file and stream the data to ingest\n", "stream = urllib.request.urlopen(storage_file_url)\n", "\n", "counter = 0\n", + "max_count = 500\n", "\n", "# iterate through the stream, generate vectors and insert into collection\n", "for object in ijson.items(stream, 'item', use_float=True):\n", - "\n", + " if counter >= max_count:\n", + " break\n", + " \n", " #generate embeddings\n", " vectorArray = generate_embeddings(object['overview'])\n", "\n", @@ -271,9 +315,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/mark/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_community/vectorstores/azure_cosmos_db.py:146: UserWarning: You appear to be connected to a CosmosDB cluster. For more information regarding feature compatibility and support please visit https://www.mongodb.com/supportability/cosmosdb\n", + " client: MongoClient = MongoClient(connection_string, appname=appname)\n" + ] + } + ], "source": [ "cdb = AzureCosmosDBVectorSearch(\n", " collection= cosmos_collection,\n", @@ -303,7 +356,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -339,7 +392,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -382,7 +435,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -398,9 +451,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyError", + "evalue": "'metadata'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "File \u001b[0;32m:2\u001b[0m\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain/chains/base.py:164\u001b[0m, in \u001b[0;36mChain.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 163\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_error(e)\n\u001b[0;32m--> 164\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 165\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_end(outputs)\n\u001b[1;32m 167\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m include_run_info:\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain/chains/base.py:154\u001b[0m, in \u001b[0;36mChain.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 152\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_validate_inputs(inputs)\n\u001b[1;32m 153\u001b[0m outputs \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m--> 154\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 155\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m new_arg_supported\n\u001b[1;32m 156\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_call(inputs)\n\u001b[1;32m 157\u001b[0m )\n\u001b[1;32m 159\u001b[0m final_outputs: Dict[\u001b[38;5;28mstr\u001b[39m, Any] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprep_outputs(\n\u001b[1;32m 160\u001b[0m inputs, outputs, return_only_outputs\n\u001b[1;32m 161\u001b[0m )\n\u001b[1;32m 162\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain/chains/conversational_retrieval/base.py:158\u001b[0m, in \u001b[0;36mBaseConversationalRetrievalChain._call\u001b[0;34m(self, inputs, run_manager)\u001b[0m\n\u001b[1;32m 154\u001b[0m accepts_run_manager \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 155\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mrun_manager\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m inspect\u001b[38;5;241m.\u001b[39msignature(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_docs)\u001b[38;5;241m.\u001b[39mparameters\n\u001b[1;32m 156\u001b[0m )\n\u001b[1;32m 157\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m accepts_run_manager:\n\u001b[0;32m--> 158\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_docs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnew_question\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m_run_manager\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 159\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 160\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_docs(new_question, inputs) \u001b[38;5;66;03m# type: ignore[call-arg]\u001b[39;00m\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain/chains/conversational_retrieval/base.py:395\u001b[0m, in \u001b[0;36mConversationalRetrievalChain._get_docs\u001b[0;34m(self, question, inputs, run_manager)\u001b[0m\n\u001b[1;32m 387\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_docs\u001b[39m(\n\u001b[1;32m 388\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 389\u001b[0m question: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 392\u001b[0m run_manager: CallbackManagerForChainRun,\n\u001b[1;32m 393\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[Document]:\n\u001b[1;32m 394\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Get docs.\"\"\"\u001b[39;00m\n\u001b[0;32m--> 395\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mretriever\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minvoke\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 396\u001b[0m \u001b[43m \u001b[49m\u001b[43mquestion\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconfig\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallbacks\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_child\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m}\u001b[49m\n\u001b[1;32m 397\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 398\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_reduce_tokens_below_limit(docs)\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_core/retrievers.py:253\u001b[0m, in \u001b[0;36mBaseRetriever.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 251\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 252\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_retriever_error(e)\n\u001b[0;32m--> 253\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 254\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 255\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_retriever_end(\n\u001b[1;32m 256\u001b[0m result,\n\u001b[1;32m 257\u001b[0m )\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_core/retrievers.py:246\u001b[0m, in \u001b[0;36mBaseRetriever.invoke\u001b[0;34m(self, input, config, **kwargs)\u001b[0m\n\u001b[1;32m 244\u001b[0m _kwargs \u001b[38;5;241m=\u001b[39m kwargs \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_expects_other_args \u001b[38;5;28;01melse\u001b[39;00m {}\n\u001b[1;32m 245\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_new_arg_supported:\n\u001b[0;32m--> 246\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_relevant_documents\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 247\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m_kwargs\u001b[49m\n\u001b[1;32m 248\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 249\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 250\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_relevant_documents(\u001b[38;5;28minput\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m_kwargs)\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_core/vectorstores/base.py:1042\u001b[0m, in \u001b[0;36mVectorStoreRetriever._get_relevant_documents\u001b[0;34m(self, query, run_manager)\u001b[0m\n\u001b[1;32m 1038\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_relevant_documents\u001b[39m(\n\u001b[1;32m 1039\u001b[0m \u001b[38;5;28mself\u001b[39m, query: \u001b[38;5;28mstr\u001b[39m, \u001b[38;5;241m*\u001b[39m, run_manager: CallbackManagerForRetrieverRun\n\u001b[1;32m 1040\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[Document]:\n\u001b[1;32m 1041\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msearch_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msimilarity\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m-> 1042\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvectorstore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msimilarity_search\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msearch_kwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1043\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msearch_type \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msimilarity_score_threshold\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 1044\u001b[0m docs_and_similarities \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 1045\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvectorstore\u001b[38;5;241m.\u001b[39msimilarity_search_with_relevance_scores(\n\u001b[1;32m 1046\u001b[0m query, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msearch_kwargs\n\u001b[1;32m 1047\u001b[0m )\n\u001b[1;32m 1048\u001b[0m )\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_community/vectorstores/azure_cosmos_db.py:563\u001b[0m, in \u001b[0;36mAzureCosmosDBVectorSearch.similarity_search\u001b[0;34m(self, query, k, kind, pre_filter, ef_search, score_threshold, with_embedding, **kwargs)\u001b[0m\n\u001b[1;32m 552\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msimilarity_search\u001b[39m(\n\u001b[1;32m 553\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 554\u001b[0m query: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 561\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs: Any,\n\u001b[1;32m 562\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[Document]:\n\u001b[0;32m--> 563\u001b[0m docs_and_scores \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msimilarity_search_with_score\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 564\u001b[0m \u001b[43m \u001b[49m\u001b[43mquery\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 565\u001b[0m \u001b[43m \u001b[49m\u001b[43mk\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mk\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 566\u001b[0m \u001b[43m \u001b[49m\u001b[43mkind\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkind\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 567\u001b[0m \u001b[43m \u001b[49m\u001b[43mpre_filter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpre_filter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 568\u001b[0m \u001b[43m \u001b[49m\u001b[43mef_search\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mef_search\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 569\u001b[0m \u001b[43m \u001b[49m\u001b[43mscore_threshold\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mscore_threshold\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 570\u001b[0m \u001b[43m \u001b[49m\u001b[43mwith_embedding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwith_embedding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 571\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 572\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m [doc \u001b[38;5;28;01mfor\u001b[39;00m doc, _ \u001b[38;5;129;01min\u001b[39;00m docs_and_scores]\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_community/vectorstores/azure_cosmos_db.py:541\u001b[0m, in \u001b[0;36mAzureCosmosDBVectorSearch.similarity_search_with_score\u001b[0;34m(self, query, k, kind, pre_filter, ef_search, score_threshold, with_embedding)\u001b[0m\n\u001b[1;32m 530\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msimilarity_search_with_score\u001b[39m(\n\u001b[1;32m 531\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 532\u001b[0m query: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 538\u001b[0m with_embedding: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 539\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[Tuple[Document, \u001b[38;5;28mfloat\u001b[39m]]:\n\u001b[1;32m 540\u001b[0m embeddings \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_embedding\u001b[38;5;241m.\u001b[39membed_query(query)\n\u001b[0;32m--> 541\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_similarity_search_with_score\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 542\u001b[0m \u001b[43m \u001b[49m\u001b[43membeddings\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43membeddings\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 543\u001b[0m \u001b[43m \u001b[49m\u001b[43mk\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mk\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 544\u001b[0m \u001b[43m \u001b[49m\u001b[43mkind\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mkind\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 545\u001b[0m \u001b[43m \u001b[49m\u001b[43mpre_filter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpre_filter\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 546\u001b[0m \u001b[43m \u001b[49m\u001b[43mef_search\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mef_search\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 547\u001b[0m \u001b[43m \u001b[49m\u001b[43mscore_threshold\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mscore_threshold\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 548\u001b[0m \u001b[43m \u001b[49m\u001b[43mwith_embedding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mwith_embedding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 549\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 550\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m docs\n", + "File \u001b[0;32m~/repos/intro-to-intelligent-apps/.venv/lib/python3.10/site-packages/langchain_community/vectorstores/azure_cosmos_db.py:463\u001b[0m, in \u001b[0;36mAzureCosmosDBVectorSearch._similarity_search_with_score\u001b[0;34m(self, embeddings, k, kind, pre_filter, ef_search, score_threshold, with_embedding)\u001b[0m\n\u001b[1;32m 461\u001b[0m document_object_field \u001b[38;5;241m=\u001b[39m res\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdocument\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 462\u001b[0m text \u001b[38;5;241m=\u001b[39m document_object_field\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_text_key)\n\u001b[0;32m--> 463\u001b[0m metadata \u001b[38;5;241m=\u001b[39m \u001b[43mdocument_object_field\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmetadata\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 464\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m with_embedding:\n\u001b[1;32m 465\u001b[0m metadata[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_embedding_key] \u001b[38;5;241m=\u001b[39m document_object_field\u001b[38;5;241m.\u001b[39mpop(\n\u001b[1;32m 466\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_embedding_key\n\u001b[1;32m 467\u001b[0m )\n", + "\u001b[0;31mKeyError\u001b[0m: 'metadata'" + ] + } + ], "source": [ "%%time \n", "query = \"Tell me about films with Buzz Lightyear\"\n", @@ -474,7 +549,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/labs/03-orchestration/03-VectorStore/qdrant.ipynb b/labs/03-orchestration/03-VectorStore/qdrant.ipynb index e1cfc04..5e0a43c 100644 --- a/labs/03-orchestration/03-VectorStore/qdrant.ipynb +++ b/labs/03-orchestration/03-VectorStore/qdrant.ipynb @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -129,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -191,7 +191,7 @@ "\n", "query = \"Can you suggest similar movies to The Matrix?\"\n", "\n", - "for doc in retriever.get_relevant_documents(query):\n", + "for doc in retriever.invoke(query):\n", " print(doc.metadata['source'])\n" ] }, @@ -215,14 +215,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "from langchain.indexes import VectorstoreIndexCreator\n", "from langchain.chains import RetrievalQA\n", "\n", - "index_creator = VectorstoreIndexCreator(embedding=embeddings)\n", + "index_creator = VectorstoreIndexCreator(embedding=embeddings, vectorstore_cls=Qdrant)\n", "docsearch = index_creator.from_loaders([loader])" ] }, @@ -329,7 +329,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/03-orchestration/04-Functions/function-calling.ipynb b/labs/03-orchestration/04-Functions/function-calling.ipynb index e1cd283..9ba8223 100644 --- a/labs/03-orchestration/04-Functions/function-calling.ipynb +++ b/labs/03-orchestration/04-Functions/function-calling.ipynb @@ -77,7 +77,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -215,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -255,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -287,7 +287,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -338,7 +338,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -412,7 +412,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -437,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -531,7 +531,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.10.14" }, "orig_nbformat": 4 }, diff --git a/labs/04-deploy-ai/02-frontend-ui/chainlitagent-ui/docker-compose.yml b/labs/04-deploy-ai/02-frontend-ui/chainlitagent-ui/docker-compose.yml index dfb916b..261bd49 100644 --- a/labs/04-deploy-ai/02-frontend-ui/chainlitagent-ui/docker-compose.yml +++ b/labs/04-deploy-ai/02-frontend-ui/chainlitagent-ui/docker-compose.yml @@ -26,3 +26,4 @@ services: - AZURE_AI_SEARCH_ENDPOINT=azure_ai_search_endpoint_goes_here - AZURE_AI_SEARCH_INDEX_NAME=ai-search-index-name_goes_here - AZURE_AI_SEARCH_API_KEY=azure_ai_search_api_key_goes_here + diff --git a/requirements.txt b/requirements.txt index 5b28b13..f55d186 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,18 @@ -azure-core==1.30.1 -azure-identity==1.16.0 -azure-search-documents==11.4.0 -semantic-kernel==0.9.5b1 -openai==1.17.1 -langchain==0.1.16 -langchain-openai==0.1.3 -tiktoken==0.6.0 +azure-core==1.30.2 +azure-identity==1.17.0 +azure-search-documents==11.5.1 #11.4.0 +semantic-kernel==1.8.3 #0.9.5b1 +openai==1.44.0 +langchain==0.2.16 +langchain-openai==0.1.23 +tiktoken==0.7.0 python-dotenv==1.0.1 -requests==2.31.0 -unstructured==0.13.2 -markdown==3.6 -qdrant-client==1.8.2 -chromadb==0.4.24 -yfinance==0.2.37 -langchain-community==0.0.32 -pymongo==4.6.3 \ No newline at end of file +requests==2.32.3 +unstructured==0.15.9 +markdown==3.7 +qdrant-client==1.11.1 +chromadb==0.5.5 +yfinance==0.2.43 +langchain-community==0.2.16 +pymongo==4.8.0 +ijson==3.3.0 \ No newline at end of file