One site that is bookmarked by most clinical oncologists is the link to the Guidelines of the National Comprehensive Cancer Network. First published in 2002, it is a comprehensive set of disease-specific consensus treatment summaries that have been used as a means to provide practicing oncologists with clear summaries of evidence-based treatment, distilled through the many thought leaders in each disease site. The guidelines consist of flow diagrams that provide the clinician with algorithmic diagnostic and treatment recommendations based on the findings of the initial diagnostic evaluation. The guidelines also contain a discussion section summarizing the studies from which the guidelines were formulated.
When one wishes to formulate a treatment plan for a newly-diagnosed case of cancer, it is common to refer to these guidelines, not only for the reassurance that the treatment plan is reasonable, but insurance companies will sometimes decline to pre-approve treatments involving expensive agents, if they are not included in these guidelines. The guidelines themselves are detailed, and I have found that while the flow diagrams are convenient, it is frequently essential to review the rationale for these recommendation in the discussion section as well. There are a limited number of hyperlinks in the document, and it is not convenient to find immediate answers to specific clinical questions.
By now, most people are familiar with a search engine interface, and now most people have also had experience with ChatGPT. While LLMs are subject to hallucinations, searches that are based on chat models that are trained on a specific set of data, such as the NCCN guidelines, are not likely to be subject to such limitations. For this purpose, I wrote a python app that reads the NCCN guideline PDFs that one might have stored in a folder, and provides a query interface to the data. While this has been very helpful, there have been many situations where the information I desire does not reside in the guidelines, and the app resorts to a general web search. All that one needs to use the app is an API-key to OpenAI, as well as an account with the NCCN. The model uses the gpt-4o-mini model which is very, very inexpensive, costing a fraction of a penny per million tokens.
The NCCN Guidelines are updated at least annually, and for those cancers in which relevant practice-changing research become available more frequently and warrant more urgent incorporation, the guidelines are updated during interim meetings. New updates can occur as often as monthly, for common neoplasms, and many busy oncologists may not find time to keep these guidelines updated. The legal consequences of basing treatment on outdated recommendations has been not explored, to my knowledge, but I would hate to know that I did not provide up-to-date care to my patient.
Recently, I participated in a five-day intensive Generative AI course, sponsored by Google and Kaggle. I learned how to apply the techniques of Retrieval Augmented Generation (RAG), few-shot prompting, using agents to organize the coding tasks, as well as grounding an app with search. I decided to apply what I learned to updating my NCCN app, working in the Google universe.
This app requires a Google Gen AI API key. One must install the necessary libraries and store API keys, usernames and passwords in the Kaggle notebook. For this app, I used the Gemini-2.5-Pro model, as smaller models did not have the context length to handle the few shot prompts or the PDF processing. Model selection is set up in the setup_genai function.
The main module of this app is the def cancer_info_chatbot function, which is the orchestrator of several agents. Once the query has been received, it calls the setup_genai agent to make sure that the API key is available and valid. The next step is to determine what kind of cancer is implicit in the query. Sometimes it is explicitly stated, but at other times, one may use abbreviations, such as “DLBCL” for “diffuse large B-cell lymphoma”. For this reason, the query goes to detect_cancer_type which feeds the query into the agent generate_content_with_model which converts the text string into a client object and feeds that into the LLM to intelligently parse the intended tumor type, and categorize it into one of NCCN’s designated labels. Once the tumor type is identified, the label is sent to the agent get_nccn_pdf. This agent poses as a browser to interact with the NCCN website, then logs in with the supplied credentials, using the BeautifulSoup python library to parse the webpage. The category page is obtained and the link to the appropriate cancer type is taken, which leads to the page containing the PDF file. The cancer file is identified and downloaded, and sent to the extract_text_from_pdf agent to extract the textual elements, and this is sent to the LLM, along with the query, to formulate the answer. This is the RAG portion of the process.
The query was also sent to be searched on Google, using their GoogleSearch tool. This is called grounding with Google search, which improves accuracy and recency of responses. Few-shot prompting with examples was provided to help refine the format and content of the responses.
The result of this effort is an app that allows me to obtain the latest staging and treatment information from the NCCN guidelines database, with search backup if needed. No longer will I have to remember to download the latest PDF to my document folder. This illustrates the utility of using agents, RAG, few-shot prompting and grounding with Google search.