Gen AI with Open AI - amitbhilagude/userfullinks GitHub Wiki
Introduction
Create account in OpenAI
Free 5$ credit for POC
Use of Open AI, Install Open AI Python library
Prompt: Input provided to LLM
Token: Answer retrieved from Open AI converted into small segement called token. e.g Every word will be token and cost is based on number of token you pass.
Python env setup
Create virtual environment
Install all packages from requirements.txt
Create API Key.
Setup open AI API key as environment variable
There will multiple language model available so make sure find our right language model
Define prompt using OpenAI object. Prompt take input as string, model name, allowed max token, temp etc.
Conversation AI
Conversation AI is build project like chatgpt
Open AI has chat completion API it takes prompt as a role and message. Role is give the context to give better accuracy
Chat gpt LLM doesn't have realt time data. it is provides data to trainned but there is option to give input of trained data which is called prompt engineering
4.Real time data calling
Models are training for particular schedule and it will not have real time
Want to build real time data need to extend LLM capabilities with Function calling
Function calling
Define function and parameter
Pass that function parameter as dev tool.
LLM understands it doesn't have this data, it can respond you back
call that function and generate extended response
Building custom knowledge
Models are trained but it doesn't have your domain specific data for product, company.
Some time times same model will not give all information and you may end up with calling multiple models with LangChain
One model output will pass to another model.
Custom knowledge will be stored into Vector DB like chroma or vector db or elastic search
Embedding
Custom knowledge will be spitted in chunks
Convert into Embedding with Open AI method
Store into Vector DB
Create a prompt template which will have context. When search is performed, query to vector db, pass that template with context has value from vector DB to model.