[1bdb11]: / main.py

Download this file

43 lines (33 with data), 1.1 kB

 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
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Main script for demo.
"""
from aitrika.engine.online_aitrika import OnlineAItrika
from aitrika.llm.openai import OpenAILLM
from aitrika.utils.text_parser import generate_documents
from dotenv import load_dotenv
import os
if __name__ == "__main__":
load_dotenv()
pubmed_id = 23747889
engine = OnlineAItrika(pubmed_id=pubmed_id)
# Extract the content
abstract = engine.extract_abstract()
# Prepare the documents (you can use full-text if available)
documents = generate_documents(content=abstract)
# Set the LLM (default for OpenAI is gpt-4o-mini)
llm = OpenAILLM(
documents=documents,
api_key=os.getenv("OPENAI_API_KEY"),
)
# Query your document
query = "Is BRCA1 associated with breast cancer?"
print(llm.query(query=query))
# Extract paper results
results = engine.extract_results(llm=llm)
print(results)
# Extract number of participants
number_of_participants = engine.extract_number_of_participants(llm=llm)
print(number_of_participants)
# Extract outcomes
outcomes = engine.extract_outcomes(llm=llm)
print(outcomes)