Integrating OpenAI ChatGPT with ASP.NET Core Web API for Advanced Chatbot Functionality

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome to csubspace today in this video I gonna show you how you can you can integrate a chat GPT with sp.net core web API so let's start uh in First Step need to create a API key for for open AI website so you can log in with your email to this open AI and after login you can find your API key from here so I already get a open AI Secret Key by clicking on this button so after you getting your open AI secret key so then here I already create a asp.net core web API template project with a blank web API template so first of all here need to create a need to add a new get package for open AI so I am opening this package manager console and here I am writing like a install package and then it's open AI then press enter this will install the latest new case package or open AI after this here I will add one more controller or open a this is the default control that is created after choosing the web API template so here I am writing need to add and here I can rename this as open AI and click on it till adder controller for this and now now here I am adding one more controller like public IXL result and then get result in now I decorate this as a HTTP post and like I am the change their root like root like I'm changing this as a get result and here we'll be taking the input from the Swagger so I am writing as like a from body sub from body I am writing this in this square bracket from body and then take a string and then taking one variable as a prompt and then and then I'm waiting string and then it's API equal to then here we're writing API key our API keys this and then like I'm taking one more variable for answer ing string dot empty um then taking one more variables or open near is equal to new open AI API and then here we pass our API key and now this will be the open UI API plus I need to add a new kit you need to add a name space for this so I'm just pressing Ctrl Dot and this will add a name space for this here and after that I am writing like a completion completion uh request it's a completion request and uh like I'm writing a completion is equal to new new completion request and then we assigning these values like a prompt is equal to prompt this variable and then like completion dot models Which models need to use so for demonstration purposes here I am using this opinion Dot models dot model Dot Diamond see text this so this is the most capable gpt3 model so can you do anything tasks and the technical models so there's a difference models you can check with the different models and their respective answers so I am using this text and then completion completion dot Max tokens this how many tokens to complete to can return favor if stop sequence is hit default this if you not provide any max token then default value is for 16. but here like I am providing this I have two thousands and then we get the result where result is equal to open AI Dot completions Dot dot create completion async and then if result is equal to not null then we iterate the Forest Loop where the result completions so it's where items in result Dot result Dot completions and then answer is equal to item dot text and then we return this result like return okay and then we return this answer and the phrase result is null then this return as a bad question like not found so I am pressing uh so now we run this application so now I'm click on start and this will start the application and by default this will call the Swagger page so this is the open a controller that we have created so like here we can ask any questions like what is the SP dot that core click on execute and this will showing the error because sometimes it says so many traffics on their API so we can change this Max tokens value to number of iterations to generating the result like this showing correctly the rate limit raised to default so per minute so like something error for this so we can change this uh Max token and regenerate so like I change their Max tokens value like I decrease too less as a 100 so now we again run this application and after um just call it this Swagger index so now I again enter the prompt message like voltage esp.net core and then again click on execute with Max token to 100 so this will taking some time to generate the result so this generated the result for asp.net core uh with there some small technicians and like we change any other assists like what is the ah aqi in New Delhi so again click on execute this will again generate the result for this So currently it's like a because uh currently currently chat CPT is is updated with uh Trend with the model of year 2021 so this will produce the result for that to project 21 so you can check the result with a different answers and questions so hey this is the complete process of how you can integrate a chat GPT with asp.net core web API you can also fine tune your applications with a different Max tokens and different different models so this is the complete process and if you have any questions say any problems please write in a comment box I will try to reply you soon and if you like my videos please don't forget to click on subscribe button and for getting a latest updates also click on notification Bell so thanks thanks for watching we will meet in next video session
Info
Channel: Csharp Space
Views: 5,761
Rating: undefined out of 5
Keywords: OpenAI, Chatbot, AI, MachineLearning, NaturalLanguageProcessing, ASPNETCore, WebAPI, BackendDevelopment, ConversationalAI, ChatbotDevelopment, CSharpProgramming, VisualStudio, APIIntegration, AdvancedChatbot, CustomerExperience, IntelligentChatbot, UserEngagement, InteractiveChatbot, SmartChatbot, csharp space, chatgpt explained, chat gpt, open ai
Id: tyOhWSDQNqQ
Channel Id: undefined
Length: 11min 12sec (672 seconds)
Published: Mon Feb 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.