This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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\]$ " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo chmod 666 /var/run/docker.sock |
NewerOlder