Skip to content

Instantly share code, notes, and snippets.

View gswithjeff's full-sized avatar
🤖

jeff gswithjeff

🤖
View GitHub Profile
@gswithjeff
gswithjeff / main.py
Created March 13, 2024 04:31
Updated for LlamaIndex v0.10+: Building a RAG pipeline using LlamaIndex, Google Gemini Pro, and Pinecone
import os
from pinecone import Pinecone
from llama_index.llms.gemini import Gemini
from llama_index.vector_stores.pinecone import PineconeVectorStore
from llama_index.embeddings.gemini import GeminiEmbedding
from llama_index.core import StorageContext, VectorStoreIndex, download_loader
from llama_index.core import Settings
GOOGLE_API_KEY = "YOUR_API_KEY"
@gswithjeff
gswithjeff / main.py
Last active March 15, 2024 22:45
Building a RAG Pipeline with Amazon Bedrock and LangChain
# https://www.gettingstarted.ai
# email: jeff@gettingstarted.ai
# written by jeff
from langchain.chains import LLMChain
from botocore.client import Config
from langchain_community.llms import Bedrock
from langchain_core.prompts import PromptTemplate
from langchain.chains import RetrievalQA
@gswithjeff
gswithjeff / main.py
Created February 23, 2024 00:04
This Python script uses PyPDFLoader, Pydantic, LangChain, and GPT to extract and structure metadata (title, author, summary, keywords) from a PDF document, demonstrating three different extraction methods.
# https://www.gettingstarted.ai
# email: jeff@gettingstarted.ai
# written by jeff
from dotenv import find_dotenv, load_dotenv
from langchain_openai import ChatOpenAI
from langchain_core.prompts import PromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.output_parsers import JsonOutputParser
@gswithjeff
gswithjeff / main.py
Created January 30, 2024 01:39
Building a RAG pipeline using LlamaIndex, Google Gemini Pro, and Pinecone
import os
from pinecone import Pinecone
from llama_index.llms import Gemini
from llama_index.vector_stores import PineconeVectorStore
from llama_index.storage.storage_context import StorageContext
from llama_index.embeddings import GeminiEmbedding
from llama_index import ServiceContext, VectorStoreIndex, download_loader, set_global_service_context
GOOGLE_API_KEY = "..."
PINECONE_API_KEY = "..."
@gswithjeff
gswithjeff / SKDemo.cs
Created December 28, 2023 23:36
Add AI capabilities to your C# application using Semantic Kernel from Microsoft
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Plugins;
// Import the Kernel class from the Microsoft.SemanticKernel namespace
using Kernel = Microsoft.SemanticKernel.Kernel;
// Create a new Kernel builder
var builder = Kernel.CreateBuilder();
@gswithjeff
gswithjeff / main.py
Created December 6, 2023 17:06
Example showing how to use Chroma DB and LangChain to store and retrieve your vector embeddings
# https://www.gettingstarted.ai
# email: jeff@gettingstarted.ai
# written by jeff
# Don't forget to set your OPEN_AI_KEY
# In your terminal execute this command: export OPENAI_API_KEY="YOUR_KEY_HERE"
# Import required modules from the LangChain package
from langchain.chains import RetrievalQA
from langchain.vectorstores import Chroma
@gswithjeff
gswithjeff / main.py
Last active December 6, 2023 23:40
This Python script uses the OpenAI API to create an AI Assistant that generates a funny quote and sends it via email using the Function Calling tool
# https://www.gettingstarted.ai
# email: jeff@gettingstarted.ai
# written by jeff
# Import necessary libraries
import json
import time
from openai import OpenAI
# Initialize OpenAI client with your API key
# https://www.gettingstarted.ai
# email: jeff@gettingstarted.ai
# written by jeff
import time
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
)
# https://www.gettingstarted.ai
# do not forget to set your OPEN_API_KEY environment variable
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Milvus
from langchain.document_loaders import TextLoader
loader = TextLoader("state_of_the_union.txt")
@gswithjeff
gswithjeff / langchain_reservations.py
Last active September 28, 2023 14:50
How to Use LangChain Output Parsers to Structure Large Language Models Responses
from typing import List
from dotenv import load_dotenv
from langchain.llms import OpenAI
from langchain.output_parsers import PydanticOutputParser
from langchain.prompts import PromptTemplate
from pydantic import BaseModel, Field
load_dotenv()