Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .CondaPkg/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
6 changes: 6 additions & 0 deletions .CondaPkg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pixi environments
.pixi/*
!.pixi/config.toml
# pixi environments
.pixi/*
!.pixi/config.toml
1 change: 1 addition & 0 deletions .CondaPkg/.pixi/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
detached-environments = false
Binary file added .CondaPkg/meta
Binary file not shown.
235 changes: 235 additions & 0 deletions .CondaPkg/pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .CondaPkg/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[dependencies]
openssl = ">=3, <3.6"

[dependencies.python]
channel = "conda-forge"
build = "*cp*"
version = ">=3.10,!=3.14.0,!=3.14.1,<4"

[workspace]
name = ".CondaPkg"
platforms = ["win-64"]
channels = ["conda-forge"]
channel-priority = "strict"
description = "automatically generated by CondaPkg.jl"
16 changes: 14 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,37 @@ version = "0.1.0"
authors = ["ParamThakkar123 <paramthakkar864@gmail.com> and TheCedarPrince <jacobszelko@gmail.com>"]

[deps]
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DrWatson = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1"
DuckDB = "d2f5444f-75bc-4fdf-ac35-56f514c445e1"
FunSQL = "cf6cc811-59f4-4a10-b258-a8547a8f6407"
HuggingFaceHub = "d0076355-e2c0-48e6-a044-05906e51b7fc"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PromptingTools = "670122d1-24a8-4d70-bfce-740807c42192"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
RAGTools = "16ddad29-bbe8-45a7-857d-3d9514eb0023"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Aqua = "0.4"
CondaPkg = "0.2.36"
DataFrames = "1.8.0"
DrWatson = "2.19.1"
DuckDB = "1.3.2"
FunSQL = "0.15.0"
HTTP = "1.11.0"
HuggingFaceHub = "0.1.2"
JSON3 = "1.14.3"
LibPQ = "1.18.0"
LinearAlgebra = "1.10"
PromptingTools = "0.82.1"
RAGTools = "0.7.0"
PromptingTools = "≥ 0.82.1, < 0.93"
PythonCall = "0.9.35"
RAGTools = "≥ 0.7.0, < 0.11"
Serialization = "1.10"
SparseArrays = "1.10"
Statistics = "1.10"
Expand Down
65 changes: 65 additions & 0 deletions demo/basic_rag_pipeline.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using DrWatson
@quickactivate "HealthLLM"
using HealthLLM
using PromptingTools
using RAGTools

println("=" ^ 60)
println("HealthLLM.jl — Baseline RAG Pipeline Demo (HuggingFace Native)")
println("=" ^ 60)

model_embedding = "hf:sentence-transformers/all-mpnet-base-v2"
model_name = "hf:Qwen/Qwen2.5-Coder-1.5B-Instruct"

HF_TOKEN = get(ENV, "HF_API_TOKEN", get(ENV, "HUGGING_FACE_HUB_TOKEN", ""))
if isempty(HF_TOKEN)
@warn "HF_API_TOKEN not set. Set it to use HuggingFace Inference API."
println(" See: https://huggingface.co/settings/tokens")
end
HealthLLM.configure_hf_token!(; token=isempty(HF_TOKEN) ? nothing : HF_TOKEN)

println("\n[1/4] Registering models and schemas...")
emb_schema = HealthLLM.Utils.get_schema(nothing, model_embedding)
gen_schema = HealthLLM.Utils.get_schema(nothing, model_name)
println(" Embedding schema: ", typeof(emb_schema))
println(" Generator schema: ", typeof(gen_schema))

PromptingTools.register_model!(name=model_name, schema=gen_schema)
PromptingTools.register_model!(name=model_embedding, schema=emb_schema)
PromptingTools.MODEL_CHAT = model_name
PromptingTools.MODEL_EMBEDDING = model_embedding

println("\n[2/4] Building grounding index from curated docs...")
index = HealthLLM.build_grounding_index(; embedder_model=model_embedding, verbose=true)
n_chunks = length(RAGTools.chunks(index))
println(" $n_chunks chunks indexed from grounding corpus.")

println("\n[3/4] Registering FunSQL prompt template...")
HealthLLM.register_funsql_template!()
println(" Template :FunSQLQueryGeneration registered.")

questions = [
"Count patients per care site place of service",
"List patient counts by age and gender for patients with hip fracture",
]

println("\n[4/4] Running RAG queries...")
for (i, q) in enumerate(questions)
println("\n" * "-" * 60)
println("Query $i: $q")
println("-" * 60)
try
result = HealthLLM.answer_question(q, index, model_embedding, model_name; verbose=true)
answer_text = result isa RAGTools.RAGResult ? result.final_answer : string(result)
println("\nFinal answer:\n$answer_text")
catch e
println("Error during query: $e")
if e isa MethodError
showerror(stdout, e, catch_backtrace())
end
end
end

println("\n" * "=" * 60)
println("Demo complete.")
println("=" * 60)
Loading
Loading