-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathllm_example.py
More file actions
29 lines (23 loc) · 953 Bytes
/
llm_example.py
File metadata and controls
29 lines (23 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Example of using LLMs with FHIRy
git clone https://github.com/dermatologist/fhiry.git@develop
cd fhiry
pip install -e .[llm]
You will need to get an API key from Google AI Studio: https://aistudio.google.com/
Once you have one, you can either pass it to the model.
"""
# Import any LLMs that llama_index supports and you have access to
# Require OpenAI API key to use OpenAI LLMs
from llama_index.llms.google_genai import GoogleGenAI
from fhiry.fhirsearch import Fhirsearch
fs = Fhirsearch(fhir_base_url="https://hapi.fhir.org/baseR4")
df = fs.search(resource_type="Condition", search_parameters={})
# print(df.info())
# Create a Vertex LLM
llm = GoogleGenAI(
model="gemini-2.0-flash",
api_key="some-key", # Replace this with your key
)
query = "How many patients have a disease like rheumatoid arthritis?"
_command = fs.llm_query(query, llm)
print(_command)
print(df["resource.code.text"].str.contains("rheumatoid arthritis").sum())