Coder Social home page Coder Social logo

buildgenaiprodandbiz's Introduction

T. Evgeniou, Professor INSEAD GitHub | LinkedIn

The material for session 1 was developed by Olivier Mertens, Developer Audience, Azure Open AI Service, @Microsoft GitHub | LinkedIn

In the first session, we will learn about some Gen AI tools that we will use for product prototyping during the class.

We'll use OpenAI Service and keys to access/use models with the use of apis and Google Collab (browser based) for some python coding.

[NOTE] You can also use all notebooks in a local/your computer: with Visual studio code or using Conda to launch Jupyter notebook You have to install this sofware to use in in local

Summary of the session:

First steps

OpenAI Account

  1. Go to the OpenAI website: https://www.openai.com/

  2. Create an account: Click on the 'Sign Up' button on the top right corner of the website. Fill in your details and follow the steps to create your account.

  3. Verify your email: Check your email for a verification link from OpenAI. Click on the link to verify your account.

  4. Log in to your account: After verifying your email, log in to your account using your credentials.

Discover Sandbox GPTs

To experiment with the key concepts of prompt engineering, models and RAG - retrieval Augmented Generation you could visit and test the sandbox GPTs (just announced by OpenAI in November 2023) to play with a chatbot interface without the need to code ("No Code" environment). To do so, you can go to https://platform.openai.com/playground

Alt Text Select your model (e.g., we can select gpt-4 or earlier - and less costly - ones like gpt-3.5-turbo) Alt Text

If you want to know about differences between the available LLM models, you can deep dive at this link

This interface will be shown after you have correctly created your chatbot Alt text

You can also read this for some more background on basic prompt engineering

Other resources:

Create a user login on OpenAI and prepare your organization and keys

  1. Access the API dashboard: Once logged in, navigate to the API dashboard named Api Keys.

  2. Create a new API key: If you don't already have an API key, you can create a new one by clicking on the 'Create new API key' button.

Alt text You can select the name you want

You will have this kind of view after creating a key (or several keys) Alt text

IMPORTANT Don't forget every usage of a model with OpenAI will cost something! ( and the price depends of your chosen model) check this link to understand the difference in pricing / models)[https://openai.com/pricing]

  1. Copy your API key: After creating your API key, make sure to copy it and store it somewhere safe. This key is used to authenticate your requests to the OpenAI API. Whoever has access to it will be charging your account when using it!

  2. Set up your organization: In the API dashboard, you can also set up your organization if needed. This involves adding other users to your organization and managing their access levels.

Alt text

Remember, keep your Open AI API key secure and do not share it with anyone. It's also a good practice to regularly rotate your API keys, or create a new one for each application or usage.

Google account & Collab Notebook

In order to simplify potential issues with different python versions or different operating systems and problematic install on your personal computer.

We will use notebook Collab for this course. You can of course also work on your computer if you choose to, using for example Anaconda (beyond the course).

Exploring genAI: Three Examples

We will use these three colab notebooks as starting examples. Go to https://colab.research.google.com/ and follow these links to have the latest notebooks for course session 1:

We will be adding more over time (as you will notice).

You may encounter warning pop-up windows - click ok or execute to continue.

Alt text

When a notebook is correctly imported in your personal collab, you have to first import your secrets credentials.

  • Add your secrets (Key and organization imported form OpenAI sk-XXX and org-xxxxxx) in the left panel in Google Collab

Alt text Create a variable secret one at a time:

  • Copy/paste this name: OPENAI_API_KEY
  • Copy paste your sk-key inside the right input named value
  • Click on the left blue button to render the secret available in your notebook

Next, if needed (you do not need to do this for the course), you can also add a secret key and value for an organization:

  • Copy/paste this name: OPENAI_ORGANIZATION
  • Copy paste your org-key inside the right input input named value
  • Click on left blue button to render the secret available in your notebook

To use/run a notebook you have to click on every small "play button" inside the notebook on the left of the code chunk.

Alt text

[Note] The three example notebooks the very first "code chunk" (that installs packages) may take a few seconds to run and will be generating some messages. Simply wait till it completes running.


For the third (audio analysis) Notebook, you can import you own mp4 file video or audio to analyse. To do so:

  • Click on the folder button on the left
  • Import your file inside the current path - click yes to the pop up warning. Note that you have to respect the file naming ("interview.mp4") or else you will have to change the name in the notebook itself in the line inputFile = "/content/interview.mp4"

Alt Text


You are now ready to explore! Have Fun!

Don't be afraid of python you will also get help!

🥰

Gpts / RAG / functions

So you have now seen some examples of what you can do with Gen AI. You can now try to explore the OpenAI API GPTS actions to see what else is possible.

What is it about ? Gpt's custom can give a chabot with some capabilities to interact with users and you can open it to the world, customize the user experience, add some files for custom the grounded experience

  • Has custom instructions which determine the way the GPT interacts with users
  • Includes tools like browsing, DALL·E, and Code Interpreter
  • Comes with preset starter prompts for new and returning users
  • Has custom actions which allow you to connect the GPT to APIs

RAG ( AKA retrieval augmented generation)

a possibility to grounded with verified data ( from pdf files , csv, html, etc) to give a more accurate answer to the user ask or with a database vector ( contains embeddings of the data) to give a more accurate answer to the user ask

Functions

Functions it's first step to give model a tool / possibility to determine if a function is relevant to the user ask. If you want to use the GPTs functions, you can go to the Cookbook for functions to see what else is possible. Or take a look to this post in forum open AI who explain clearly how it works But the function called an api or a business process to resolve the user ask

Reference links

Agents / Assistants

It's the next step with new concepts as thread / messages with the addin of tools ( AKA Functions) available ( 128 tools if you want it). You could still add RAG ( retrieval ) or code interpreter ( to permit launch of code) to allow a "agent / assistant" ( with prompt system or persona ) to have the autonomy/choice (Programmatic choice :)) to launch/call by "himself" the function/tools to resolve the user ask/

Take a look on this documentation repository about this Azure Assistants)

Gpts capture with RAG and functions

An example of a Gpt's with setup to be able to retrieve informations from documents and some functions Sandbox assistants Open

Gen AI Products in Real World (Optional)

Now you have an idea of what one can do with Gen AI - one can use it for many different applications. However, going from a Python Notebook "demo" to an actual product requires some engineering. The tools needed are in some ways like lego blocks: one can combine them to create their own solution.

Let's now see how to build actual gen AI products! Let's start with a really simple use case. The idea of the example here is to insert some python code inside a file of an existing web application to be able to use it as part of that application.

We use python for simplicity, but one can explore other languages like dotnet, java or others.

Note: Some software architecture decisions could be critical in your launch of a product. Understanding the choices and trade offs is very important, but not the purpose of this course.

We will use the lastet developement (in beta version, as of February 2024) from OpenAI: the "Assistants". You can follow these video guides to create a simple chatbot with OpenAI and Azure

You can also follow these steps ("for a beginner, not a developper") to implement your code inside an already existing app

Some example assistants can be found here

Reference links App starter

Reference links

More information on Azure Open AI services can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.