Skip to content

Instantly share code, notes, and snippets.

View prrao87's full-sized avatar

Prashanth Rao prrao87

View GitHub Profile
"""
Code to run a simple DSPy pipeline for extracting structured outputs
from text. The example shows how to extract a resume from the given text.
"""
import os
import dspy
from dotenv import load_dotenv
from pydantic import BaseModel
load_dotenv()
import os
import dspy
from dotenv import load_dotenv
from pydantic import BaseModel
load_dotenv()
# Using OpenRouter. Switch to another LLM provider as needed
lm = dspy.LM(
model="openrouter/google/gemini-2.0-flash-001",
System message:
Your input fields are:
1. `sample` (Scholar): A sample scholar record
2. `reference_records` (list[Reference]): A list of reference records from the official Nobel Prize API
Your output fields are:
1. `output` (int): Most similar reference record to the sample record
2. `confidence` (Literal['high', 'low']): The confidence level of mapping the sample record to one of the reference records
All interactions will be structured in the following way, with the appropriate values filled in.
<structure>
<rel label="workAt" from="Person" to="Organisation" />
<rel label="forumHasTag" from="Forum" to="Tag" />
<rel label="knows" from="Person" to="Person" />
<rel label="hasModerator" from="Forum" to="Person" />
<rel label="likeComment" from="Person" to="Comment" />
<rel label="studyAt" from="Person" to="Organisation" />
<rel label="isPartOf" from="Place" to="Place" />
<rel label="postHasCreator" from="Post" to="Person" />
<rel label="personIsLocatedIn" from="Person" to="Place" />
@prrao87
prrao87 / create_financial_asset_graph.cypher
Created March 26, 2025 01:34
Financial asset graph for Kuzu-MCP server
DROP TABLE ParentOf;
DROP TABLE Issues;
DROP TABLE Company;
DROP TABLE Bond;
CREATE NODE TABLE Company(cid SERIAL, name STRING, PRIMARY KEY(cid));
CREATE (a:Company {name: "CompanyA"});
CREATE (a:Company {name: "CompanyB"});
CREATE (a:Company {name: "CompanyC"});
ollama:
image: "ollama/ollama:0.6.0"
restart: unless-stopped
environment:
- OLLAMA_HOST=0.0.0.0:11434
- OLLAMA_MODELS=/data/models
- OLLAMA_FLASH_ATTENTION=1
- OLLAMA_KV_CACHE_TYPE=q8_0
- OLLAMA_CONTEXT_LENGTH=8192
networks:
@prrao87
prrao87 / update.py
Last active October 24, 2024 21:39
Bulk update workflow using `LOAD FROM` and `MERGE` with Polars DataFrames
import polars as pl
import kuzu
import shutil
shutil.rmtree("test_db", ignore_errors=True)
db = kuzu.Database("test_db")
conn = kuzu.Connection(db)
# Get a JSON object of persons and products purchased
data = [
@prrao87
prrao87 / gen_data.py
Last active January 27, 2024 00:04
gen_fake_persons.py
"""
Generate a fake dataset (csv or parquet) of persons
Two columns: name (str) and age (int)
Ensure the faker library and polars are installed:
pip install faker polars
Usage:
python gen_data.py -n 1000000 -f csv
python gen_data.py -n 1000000 -f parquet
# Git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
@prrao87
prrao87 / docker_enable_non_root_user.sh
Created March 28, 2023 17:15
Allow non root/sudo user to run docker containers on Ubuntu
sudo chmod 666 /var/run/docker.sock