Skip to content

Instantly share code, notes, and snippets.

View jamesc127's full-sized avatar

James Colvin jamesc127

View GitHub Profile
@jamesc127
jamesc127 / gpt-research-assistant.py
Created November 17, 2023 18:18
gpt-research-assistant.py
# pip install langserve langchain openai uvicorn fastapi bs4 duckduckgo-search sse_starlette
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
import os
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
from langchain.memory import CassandraChatMessageHistory, ConversationBufferMemory
from langchain.llms import OpenAI
from langchain import LLMChain, PromptTemplate
import json
cloud_config= {
'secure_connect_bundle': 'secure-connect-choose-your-own-adventure.zip'
}
@jamesc127
jamesc127 / hybrid-search-example.md
Created October 4, 2023 04:59
gist overview of 25-september weekly learning

Hybrid Search Example

Applications can filter users in a geographic area by filtering first on tag information, and then using an ANN query with geospatial vector embeddings

CREATE TABLE users ( 
id UUID PRIMARY KEY, 
state text, 
city int,
tags set<text>,
sem_vec vector<float, 384> 
);
@jamesc127
jamesc127 / cassandra_tombstones.md
Last active September 7, 2022 01:02
A Brief Explanation On Cassandra Tombstones

Here is an example of several different kinds of C* tombstones. For reference, they are:

  • Partition
  • Row
  • Cell
  • Range

Intro

The obvious culprit of tombstone creation is DELETE, but there are other - less obvious - sources of the tombstone. Let’s see exacly what happens on disk when a tombstone is created. It's funny to say that a tombstone is created... aren't we deleting things? Remember, everything in C* is a write! A DELETE operation writes another sstable entry with a newer timestamp than all the other entries... and the most recent timestamp wins!

I’ve created a DataStax Studio notebook that complements this gist. You should be able to download it and run it for yourself :-) nodetool and sstabledump commands need to be run from a terminal on the node(s) you're working with.