a b/main.py
1
"""
2
Main script for demo.
3
"""
4
5
from aitrika.engine.online_aitrika import OnlineAItrika
6
from aitrika.llm.openai import OpenAILLM
7
from aitrika.utils.text_parser import generate_documents
8
from dotenv import load_dotenv
9
import os
10
11
if __name__ == "__main__":
12
    load_dotenv()
13
    pubmed_id = 23747889
14
    engine = OnlineAItrika(pubmed_id=pubmed_id)
15
16
    # Extract the content
17
    abstract = engine.extract_abstract()
18
19
    # Prepare the documents (you can use full-text if available)
20
    documents = generate_documents(content=abstract)
21
22
    # Set the LLM (default for OpenAI is gpt-4o-mini)
23
    llm = OpenAILLM(
24
        documents=documents,
25
        api_key=os.getenv("OPENAI_API_KEY"),
26
    )
27
28
    # Query your document
29
    query = "Is BRCA1 associated with breast cancer?"
30
    print(llm.query(query=query))
31
32
    # Extract paper results
33
    results = engine.extract_results(llm=llm)
34
    print(results)
35
36
    # Extract number of participants
37
    number_of_participants = engine.extract_number_of_participants(llm=llm)
38
    print(number_of_participants)
39
40
    # Extract outcomes
41
    outcomes = engine.extract_outcomes(llm=llm)
42
    print(outcomes)