Skip to content

Instantly share code, notes, and snippets.

View janakiramm's full-sized avatar

Janakiram MSV janakiramm

View GitHub Profile
@janakiramm
janakiramm / rag_gemini.py
Created March 8, 2024 06:14
Python code to implement RAG with Vertex AI Vector Search and Gemini Pro
# The previous part of this tutorial is at https://gist.github.com/janakiramm/55d2d8ec5d14dd45c7e9127d81cdafcd
from vertexai.language_models import TextEmbeddingModel
from google.cloud import aiplatform
import vertexai
from vertexai.preview.generative_models import GenerativeModel, Part
import json
import os
project=”YOUR_GCP_PROJECT”
@janakiramm
janakiramm / vector_search.py
Created March 8, 2024 05:39
Python Code to create Vertex AI Vector Search Index and Deploying it.
###Enable Google Cloud APIs and login with your credentials
#gcloud services enable compute.googleapis.com aiplatform.googleapis.com storage.googleapis.com
#gcloud auth application-default login
###Install required Python modules
#pip install pypdf2
#pip install google-cloud-storage
#pip install google-cloud-aiplatform
#pip install jupyter
@janakiramm
janakiramm / langchain_gemini_summarization.py
Created March 14, 2024 09:56
Python code to build a content summarization application based on Gemini and LangChain
### Install required modules and set the envvar for Gemini API Key
#pip install google.generativeai
#pip install langchain-google-genai
#pip install langchain
#pip install langchain_community
#pip install jupyter
#export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
#Import Modules
@janakiramm
janakiramm / langchain_gemini_qa.py
Created March 14, 2024 07:01
Python code to build a Q&A application based on Gemini, Chroma, and VectorDB
### Install required modules and set the envvar for Gemini API Key
#pip install pypdf2
#pip install chromadb
#pip install google.generativeai
#pip install langchain-google-genai
#pip install langchain
#pip install langchain_community
#pip install jupyter
#export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
apiVersion: v1
kind: Service
metadata:
name: myapp
labels:
app: myapp
spec:
type: ClusterIP
ports:
- port: 80
@janakiramm
janakiramm / Oscar_bot_Chroma.py
Created August 3, 2023 06:57
ChromaDB for RAG with OpenAI
import pandas as pd
import openai
import chromadb
from chromadb.utils import embedding_functions
import os
df=pd.read_csv('./data/oscars.csv')
df=df.loc[df['year_ceremony'] == 2023]
df=df.dropna(subset=['film'])
@janakiramm
janakiramm / Oscar_bot.py
Created July 20, 2023 13:34
Implementing RAG with OpenAI
import openai
import tiktoken
from scipy import spatial
import pandas as pd
df=pd.read_csv('./data/oscars.csv')
print(df.head())
df=df.loc[df['year_ceremony'] == 2023]
df=df.dropna(subset=['film'])
@janakiramm
janakiramm / chroma-vdb.py
Last active July 27, 2023 10:00
Chroma VectorDB for Word Embeddings
import chromadb
phrases=[
"Amanda baked cookies and will bring Jerry some tomorrow.",
"Olivia and Olivier are voting for liberals in this election.",
"Sam is confused, because he overheard Rick complaining about him as a roommate. Naomi thinks Sam should talk to Rick. Sam is not sure what to do.",
"John's cookies were only half-baked but he still carries them for Mary.",
]
ids=["001","002","003","004"]
# Create Triton deployment
cat <<EOF > triton-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: triton
name: triton
namespace: model-server
spec:
OWNER=YOUR_GITHUB_USERNAME
REPO=YOUR_GITHUB_REPO
GITHUB_TOKEN=YOUR_GITHUB_PERSONAL_ACCESS_TOKEN
# Bootstrap BLR1 cluster
kubectx blr1
flux bootstrap github \
--owner=$OWNER \
--repository=$REPO \
--path=fleet/blr1 \