Mastering OpenAI: From Function Calls to Vector Stores

This module teaches you how to leverage OpenAI's function calling, embeddings, and GPT-powered SQL generation for building advanced applications.

You'll learn to create and execute SQL queries, compare text similarity, fetch and rank scientific papers using the arXiv API, and build user interfaces with Streamlit and Pandas.

Lesson 1

Exploring Function Calling with OpenAI

In this video, you'll dive into how function calling works in OpenAI's chat completions, starting with basic examples and gradually adding more complexity. You'll learn how to implement your own functions, including a joke-telling function and a weather update tool, while comparing this approach to Autogen's function execution process.

You'll explore how to:

  • Set up a virtual environment and configure OpenAI for function calling
  • Create basic functions, such as joke-telling and weather updates, using JSON-formatted arguments
  • Map function calls to actual functions within your Python code
  • Compare OpenAI's function calling with Autogen's execution process

By the end, you'll understand how to implement and call custom functions using OpenAI, with insights into Autogen's agent-like capabilities.

Full Video & Source Code
 

Lesson 2

Teaching GPT to Write and Execute SQL Queries

In this video, you'll learn how to connect GPT to any database, allowing it to write and execute SQL queries to uncover insights from real-world data. We’ll use a sample database and walk through setting up the environment, writing queries, and returning results, all using GPT’s function-calling capabilities.

You'll explore how to:

  • Connect GPT to a database and retrieve table structures
  • Write SQL queries using GPT with function calling
  • Execute GPT-generated SQL queries against the database
  • Return results like top-selling albums or sales trends

By the end, you’ll be able to harness GPT to access and analyze real business data.

Full Video & Source Code
 

Lesson 3

Building a GPT-Powered SQL Query Generator with Streamlit

In this video, you'll learn how to create a user-friendly interface for generating and executing SQL queries using GPT, Streamlit, and Pandas. We’ll walk through building a clean UI where users can input questions, generate SQL queries, and see results directly from a database.

You'll explore how to:

  • Set up a simple interface using Streamlit for SQL query generation
  • Capture user input and generate GPT-powered SQL queries
  • Execute the generated queries against a database
  • Display results using Pandas for clean, table-formatted outputs

By the end, you'll have a fully functional UI to interact with GPT and visualize SQL results seamlessly.

Full Video & Source Code
 

Lesson 4

Comparing Text Similarity with OpenAI Embeddings

In this video, you'll learn how to use OpenAI's models to generate text embeddings and compare text similarity. We will guide you through building a system to generate embeddings for different sentences and use cosine similarity to calculate how closely related two pieces of text are.

You'll explore how to:

  • Set up OpenAI's client and generate embeddings for various texts
  • Compare text similarity using the ADA2 model for embeddings
  • Calculate cosine similarity to determine how closely texts are related
  • Build a simple vector store to store and retrieve embeddings for future comparisons

By the end, you'll be able to measure the similarity between texts using OpenAI embeddings and apply this to more advanced projects, like building a vector store for text data.

 
Full Video & Source Code
 

Lesson 5

Building a Vector Store for Scientific Papers

In this video, you'll learn how to build a simple vector store to fetch and rank scientific papers based on a query using OpenAI embeddings. By storing titles, URLs, and their embedding representations in a CSV file, you'll be able to retrieve the most relevant papers for any given query.

You'll explore how to:

  • Use the AchSiv client to search and fetch scientific papers
  • Generate embeddings for paper titles and store them in a CSV file
  • Implement a method to rank paper titles by relatedness to a query using cosine similarity
  • Retrieve and display the most relevant papers based on user input

By the end, you'll have a system in place to automatically fetch, rank, and suggest relevant papers from your custom vector store, all powered by embeddings and a CSV-based approach.

 
Full Video & Source Code
 

Lesson 6

Blending Similarity Search with GPT Function Calls

In this video, you'll learn how to combine similarity search, GPT function calls, and a Streamlit UI to build a web app that retrieves and ranks relevant scientific papers based on your query. By integrating GPT-35 Turbo with ArcSiv, you'll fetch papers, generate summaries, and display the results in an interactive interface.

You'll explore how to:

  • Create a GPT chat completion with function calls to search for papers
  • Fetch and rank papers from ArcSiv based on query relevance
  • Update the vector store with each new search, including summaries
  • Display results in a user-friendly format with titles, summaries, and clickable URLs

By the end, you'll have a streamlined web app that retrieves relevant papers, offering an efficient way to browse academic research.

 
Full Video & Source Code