From 168d1325bdc340937b1a5ee1f87009d9e6bec847 Mon Sep 17 00:00:00 2001 From: Drew W <20048187+dvvilkins@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:06:36 -0500 Subject: [PATCH] cleaning up code --- rag.py | 97 +++++++++++++++++------------------- tests/inference_tester.ipynb | 75 ++++++++++++++-------------- 2 files changed, 84 insertions(+), 88 deletions(-) diff --git a/rag.py b/rag.py index 333852c..2a8935e 100644 --- a/rag.py +++ b/rag.py @@ -39,9 +39,6 @@ } -# keep outside the function so it's accessible elsewhere in this notebook -llm = ChatOpenAI(model=CONFIG["generation_model"], temperature=CONFIG["temperature"]) - # Create and cache the document retriever @st.cache_resource @@ -71,61 +68,38 @@ def get_retriever(): -# Define schema for responses -class AnswerWithSources(TypedDict): - """An answer to the question, with sources.""" - answer: str - sources: Annotated[ - List[str], - ..., - "List of sources and pages used to answer the question", - ] - - # Cache data retrieval function #@st.cache_data def get_retrieval_context(file_path: str): '''Reads the worksheets Excel file into a dictionary of dictionaries.''' - xls = pd.ExcelFile(file_path) context_dict = {} - for sheet_name in xls.sheet_names: - df = pd.read_excel(xls, sheet_name=sheet_name) + for sheet_name in pd.ExcelFile(file_path).sheet_names: + df = pd.read_excel(file_path, sheet_name=sheet_name) if df.shape[1] >= 2: context_dict[sheet_name] = pd.Series( df.iloc[:, 1].values, index=df.iloc[:, 0]).to_dict() return context_dict -# Cache the prompt template -def create_prompt(): - system_prompt = ( - "Use the following pieces of context to answer the users question. " - "INCLUDES ALL OF THE DETAILS IN YOUR RESPONSE, INDLUDING REQUIREMENTS AND REGULATIONS. " - "National Workshops are required for boat crew, aviation, and telecommunications when they are offered. " - "Include Auxiliary Core Training (AUXCT) for questions on certifications or officer positions. " - "If you don't know the answer, just say I don't know. \n----------------\n{context}" - ) - return ChatPromptTemplate.from_messages([ - ("system", system_prompt), - ("human", "{enriched_question}"), - ]) # Path to prompt enrichment dictionaries -config_path = os.path.join(os.path.dirname(__file__), 'config/retrieval_context.xlsx') +enrichment_path = os.path.join(os.path.dirname(__file__), 'config/retrieval_context.xlsx') # Define and cache the enrichment function to use cached context #@st.cache_data -def enrich_question_via_code(user_question: str, filepath=config_path) -> str: - retrieval_context_dict = get_retrieval_context(filepath) - acronyms_dict = retrieval_context_dict.get("acronyms", {}) - terms_dict = retrieval_context_dict.get("terms", {}) +def enrich_question(user_question: str, filepath=enrichment_path) -> str: + enrichment_dict = get_retrieval_context(filepath) + acronyms_dict = enrichment_dict.get("acronyms", {}) + terms_dict = enrichment_dict.get("terms", {}) enriched_question = user_question + # Replace acronyms with full form for acronym, full_form in acronyms_dict.items(): if pd.notna(acronym) and pd.notna(full_form): enriched_question = re.sub( r'\b' + re.escape(str(acronym)) + r'\b', str(full_form), enriched_question) + # Add explanations for term, explanation in terms_dict.items(): if pd.notna(term) and pd.notna(explanation): if str(term) in enriched_question: @@ -133,31 +107,55 @@ def enrich_question_via_code(user_question: str, filepath=config_path) -> str: return enriched_question + +def create_prompt(): + system_prompt = ( + "Use the following pieces of context to answer the users question. " + "INCLUDES ALL OF THE DETAILS IN YOUR RESPONSE, INDLUDING REQUIREMENTS AND REGULATIONS. " + "National Workshops are required for boat crew, aviation, and telecommunications when they are offered. " + "Include Auxiliary Core Training (AUXCT) for questions on certifications or officer positions. " + "If you don't know the answer, just say I don't know. \n----------------\n{context}" + ) + return ChatPromptTemplate.from_messages([ + ("system", system_prompt), + ("human", "{enriched_question}"), + ]) + + + # Function to format documents (doesn't require caching) def format_docs(docs): return "\n\n".join(doc.page_content for doc in docs) + +# Schema for llm responses +class AnswerWithSources(TypedDict): + """An answer to the question, with sources.""" + answer: str + sources: Annotated[ + List[str], + ..., + "List of sources and pages used to answer the question", + ] + + + # Define and cache the RAG pipeline setup # @st.cache_resource def create_rag_pipeline(): prompt = create_prompt() - - # Processes multiple transformations: - # 1. + llm = ChatOpenAI(model=CONFIG["generation_model"], temperature=CONFIG["temperature"]) - - - # Step 3: Create RAG chain - # Create a dictionary by explicitly mapping a input key with the value from the input dictionary and a context key with a value applied by format_docs + # Create a dictionary by explicitly mapping values from the input dict, etc. rag_chain_from_docs = ( { - "user_question": lambda x: x["user_question"], # Original user question - "enriched_question": lambda x: x["enriched_question"], - "context": lambda x: format_docs(x["context"]), # Retrieved docs + "user_question": lambda x: x["user_question"], # explicitly map the user question value to the user question key + "enriched_question": lambda x: x["enriched_question"], # ditto for enriched question + "context": lambda x: format_docs(x["context"]), # Map the retrieved docs to the context key } # pass the dictionary through a prompt template populated with input and context values | prompt @@ -184,7 +182,7 @@ def create_rag_pipeline(): # Invoke the RAG pipeline def rag(user_question: str): chain = create_rag_pipeline() - enriched_question = enrich_question_via_code(user_question) + enriched_question = enrich_question(user_question) response = chain.invoke({"user_question": user_question, "enriched_question": enriched_question}) return response @@ -192,13 +190,11 @@ def rag(user_question: str): def rag_for_eval(input: dict) -> dict: - print("Input received by rag_for_eval:", input) user_question = input["Question"] chain = create_rag_pipeline() - enriched_question = enrich_question_via_code(user_question) + enriched_question = enrich_question(user_question) response = chain.invoke({"user_question": user_question, "enriched_question": enriched_question}) - answer = response["answer"]["answer"] - return {"answer": answer} + return {"answer": response["answer"]["answer"]} @@ -207,7 +203,6 @@ def create_short_source_list(response): markdown_list = [] for i, doc in enumerate(response['context'], start=1): - page_content = doc.page_content source = doc.metadata['source'] short_source = source.split('/')[-1].split('.')[0] page = doc.metadata['page'] diff --git a/tests/inference_tester.ipynb b/tests/inference_tester.ipynb index 2b07e16..2c164fb 100644 --- a/tests/inference_tester.ipynb +++ b/tests/inference_tester.ipynb @@ -2,13 +2,16 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "# Add the parent directory to sys.path so you can import your modules from a subdirectory\n", + "from dotenv import load_dotenv\n", "import os, sys\n", "\n", + "load_dotenv('/Users/drew_wilkins/Drews_Files/Drew/Python/VSCode/.env')\n", + "\n", + "# Add the parent directory to sys.path so you can import your modules from a subdirectory\n", "sys.path.append(os.path.abspath('..'))\n", "\n", "import rag\n", @@ -17,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -26,25 +29,25 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-11-18 13:36:39.134 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:39.147 \n", + "2024-11-18 16:05:29.649 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:29.662 \n", " \u001b[33m\u001b[1mWarning:\u001b[0m to view this Streamlit app on a browser, run it with the following\n", " command:\n", "\n", " streamlit run /Users/drew_wilkins/Drews_Files/Drew/Python/ASK/.venv-main/lib/python3.11/site-packages/ipykernel_launcher.py [ARGUMENTS]\n", - "2024-11-18 13:36:39.147 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:39.147 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:39.653 Thread 'Thread-4': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:39.654 Thread 'Thread-4': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:42.647 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", - "2024-11-18 13:36:42.647 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n" + "2024-11-18 16:05:29.663 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:29.664 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:30.169 Thread 'Thread-4': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:30.170 Thread 'Thread-4': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:30.776 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n", + "2024-11-18 16:05:30.776 Thread 'MainThread': missing ScriptRunContext! This warning can be ignored when running in bare mode.\n" ] } ], @@ -56,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -70,10 +73,9 @@ "\n", "ENRICHED QUESTION: how to become National Commodore of the Auxiliary?\n", "\n", - "ANSWER: To become the National Commodore of the Auxiliary, an Auxiliarist must be elected by the National Board. The National Board is composed of the National Executive Committee (NEXCOM), which includes the Chief Director, the Immediate Past National Commodore (IPNACO), Vice National Commodore (VNACO), and the four Deputy National Commodores (DNACOs). The National Commodore is elected from among the DNACOs. The process for electing the National Commodore is outlined in Appendix C of the Auxiliary Manual (COMDTINST M16790.1G).\n", + "ANSWER: To become the National Commodore of the Auxiliary, an Auxiliarist must be elected by the National Board. The National Board consists of the Chief Director, Immediate Past National Commodore, Vice National Commodore, Deputy National Commodores, and District Commodores. The National Commodore serves a one-year term and is responsible for providing leadership and direction to the Auxiliary's national organization. The process of becoming National Commodore involves active participation in Auxiliary leadership positions, demonstrating exemplary leadership skills, and being elected by the National Board.\n", "\n", "LLM BASED ANSWER ON:\n", - "ALAUX 18-14 - CHIEF DIRECTOR FINAL ACTION ON NATIONAL BOARD RECOMMENDATIONS\n", "COMDTINST M16790.1G\n", "\n", "RETRIEVED DOCS:\n", @@ -105,33 +107,25 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'user_question': 'how to become NACO?',\n", - " 'enriched_question': 'how to become National Commodore of the Auxiliary?',\n", - " 'context': [Document(metadata={'page': 0, 'source': 'References/ALAUXs/2014/18_14_CHIEF_DIRECTOR_FINAL_ACTION_ON_NATIONAL_BOARD_RECOMMENDATIONS_NACON_2014__14SEP2014.pdf', '_id': '38604ae6-edd4-426c-86d2-b6f064f0ce1e', '_collection_name': 'ASK_vectorstore'}, page_content='ALAUX 18 -14 - CHIEF DIRECTOR FINAL ACTION ON NATIONAL BOARD \\nRECOMMENDATIONS \\n \\n14SEP2014 \\n \\n1. At the 2014 Auxiliary National Convention (NACON) in Orlando, FL in August, the following \\nrecommendations were placed before the National Board for vote. They are summarized with the Chief \\nDirector\\'s final determinations below: \\n \\nA. Recommendation: Amend CG Auxiliary Manual (AuxMan, COMDTINST M16790.1 (series)) \\nsection 4.G.5. \"Simultaneous Offices\" to add language that prohibits holding the Finance or \\nMaterials staf f offices while concurrently holding any elected office at the same organizational \\nlevel (e.g., an Auxiliarist cannot concurrently serve as FC/VFC and FSO -FN or FSO -MA). \\nProvisions are also proposed in the event there is no effective way for the unit to c omply with this \\nprohibition. Submitted by DCOs D1 -NR, D1 -SR, D8 -CR, D8 -WR, D9 -WR, D11 -NR, and D11 -\\nSR via DNACO LANT -E. \\n \\n(1) National Board vote: For, after minor amendment. \\n \\n(2) Chief Director final action: Concur and approved. Final policy language will be \\ndeveloped with the National Executive Committee, announced by ALAUX, and \\nmemorialized in the next change to the AuxMan. Changes to AUXDATA will also have to \\nbe made. \\n \\nB. Recommendation: Establish an Auxiliary Musician Specialist (AUXMU) program co nsisting of \\ncertified musicians to be used in various public affairs events and venues of note. Certified \\nmusicians would meet prescribed qualifications and would encompass all music categories in the \\nAuxiliary Skills Bank. The leader should be a certifi ed musician and be assigned as a Branch \\nChief in the Community Relations Division of the Public Affairs Directorate. Establishment of \\nthis specialty will facilitate an excellent public affairs and recruiting tool for the Coast Guard \\nAuxiliary and the Coas t Guard. This recommendation will utilize musician skills sets obtained \\noutside the Auxiliary and not add to any training cost for the Auxiliary. Submitted by DCOs D1 -\\nSR, D8 -CR, and D11 -SR via NACO. \\n \\n(1) National Board vote: For. \\n \\n(2) Chief Director f inal action: Concur and approved. This competency will enhance \\nAuxiliary public outreach and image, and there is a clear parallel with the CG Musician\\'s \\nrating. Accordingly, there must be dialogue with the CG music program to address \\nperformance standar ds, expectations, policies, etc. Final policy language will be developed \\nwith the National Executive Committee, announced by ALAUX, and memorialized in the \\nnext change to the AuxMan. Changes to AUXDATA will also have to be made. \\n \\nC. Recommendation: Repl ace the current option for documenting eligibility for an Anniversary \\nStreamer, when the original charter cannot be located, from providing, \"...a listing of all previously \\nserving Flotilla Commanders for the 50 -year period...\" to \"...a letter from the DIR AUX \\nAuthenticating Eligibility for the Award.\" Submitted by DIR -H via NACO. \\n \\n(1) National Board vote: For. \\n '),\n", - " Document(metadata={'page': 24, 'source': 'For_injestion/IT Instructor WORKSHOP 2023 Jan 2023 Final.pdf', '_id': '99d20cfa-1ce1-4472-b2f0-c23ebba502b3', '_collection_name': 'ASK_vectorstore'}, page_content='Maxim Award\\nNational Prize Winner + \\nAuxiliary \\nCommendation Medal\\n25\\nArea Prize Winner + \\nAuxiliary Achievement \\nMedal\\nJanuary 2023\\nFlotillas\\xa0should\\xa0consider\\xa0assembling \\xa0a\\xa0team\\xa0now\\xa0to\\xa0begin\\xa0accumulating \\xa0supporting \\xa0documentation \\xa0for\\xa0\\nthe\\xa0number\\xa0of\\xa0courses\\xa0taught,\\xa0the\\xa0number\\xa0of\\xa0graduates, \\xa0the\\xa0variety\\xa0of\\xa0courses\\xa0taught,\\xa0and\\xa0all\\xa0other\\xa0\\ndata\\xa0and\\xa0testimonials \\xa0deemed\\xa0pertinent \\xa0to\\xa0preparing \\xa0the\\xa0nominee\\xa0package.\\xa0Flotilla\\xa0nomination \\xa0\\npackages \\xa0will\\xa0be\\xa0due\\xa0on\\xa0February\\xa028\\xa0to\\xa0their\\xa0DSO‐PE,\\xa0so\\xa0now\\xa0is\\xa0the\\xa0time\\xa0to\\xa0start\\xa0to\\xa0avoid\\xa0the\\xa0last‐\\nminute\\xa0rush,\\xa0as\\xa0that\\xa0date\\xa0will\\xa0be\\xa0here\\xa0before\\xa0we\\xa0know\\xa0it!\\xa0\\nThe\\xa0Public\\xa0Education \\xa0Directorate \\xa0recognizes \\xa0that\\xa02022\\xa0was\\xa0an\\xa0incredibly \\xa0challenging \\xa0year\\xa0for\\xa0most\\xa0\\nAuxiliarists \\xa0because\\xa0of\\xa0continuing \\xa0COVID‐19\\xa0precautions. \\xa0However, \\xa0many\\xa0flotillas\\xa0openly\\xa0embraced \\xa0the\\xa0\\noption\\xa0of\\xa0offering\\xa0virtual\\xa0online\\xa0classes\\xa0via\\xa0videoconferencing, \\xa0and\\xa0nomination \\xa0packages\\xa0should\\xa0\\ninclude\\xa0how\\xa0the\\xa0nominee\\xa0overcame \\xa0the\\xa0obstacles \\xa0of\\xa0using\\xa0new\\xa0technology \\xa0for\\xa0course\\xa0presentation \\xa0\\nand\\xa0what\\xa0successes \\xa0s/he\\xa0experienced.\\nGo\\xa0to\\xa0http://wow.uscgaux.info/content.php?unit=E ‐DEPT&category=maxim ‐award for\\xa0more\\xa0\\ninformation \\xa0on\\xa0the\\xa0Commodore \\xa0Daniel\\xa0Maxim\\xa0Award\\xa0for\\xa0Excellence \\xa0in\\xa0Education.\\nNOTE:\\xa0Schedule\\n•Package\\xa0from\\xa0flotillas\\xa0to\\xa0DSO‐PE:\\xa028Feb.\\n•District\\xa0selected\\xa0package\\xa0to\\xa0Dir‐E\\xa0and\\xa0Dir‐Ed:\\xa030Apr.\\nNOTE:\\xa0Eligibility\\n•All\\xa0instructors \\xa0in\\xa0the\\xa0CG\\xa0Auxiliary\\xa0are\\xa0eligible\\xa0if\\xa0nominated \\xa0for\\xa0the\\xa0Maxim\\xa0Award\\xa0except\\xa0a\\xa0prior\\xa0\\nNational\\xa0Prize\\xa0Winner\\xa0or\\xa0a\\xa0member\\xa0of\\xa0the\\xa0Public\\xa0Education \\xa0Directorate.\\n25'),\n", - " Document(metadata={'page': 18, 'source': 'References/National Directorates/National Leadership Documents/Strategic_Plan_2022-2028.pdf', '_id': '683f7d10-60dd-40ef-a516-26e3987f4910', '_collection_name': 'ASK_vectorstore'}, page_content='17 \\n Assistant National Commodore – Performance and Student Programs \\nExpand the Auxiliary Student Programs: Auxiliary University Program (AUP), Sea Scouts \\n(AuxScout) program, and the Auxiliary Academy Admissions Partner (AAAP) Program to meet mission and servi ce needs \\nGoal s: Promote the Auxiliary within Higher Education and Sea Scout programs. Increase the \\nnumber of AUP and Sea Scout members, fully integrating them into the local Auxiliary units. Enhance leadership training targeted to these programs. Strengthen and expand the AAAP program. \\nActivities: Develop future Coast Guard active duty, Reserve, and Auxiliary leaders. Grow the \\nnumber of members in support of Coast Guard human capital needs. Further develop leadership curriculum, training, and tools. Recruit, retain, and recognize highly qualified \\nAuxiliary personnel for the AAAP program to provide effective, proactive assistance to the \\nCoast Guard Academy in its efforts to attract top- flight applicants. \\nImplementing Partners:\\n The Auxiliary, includin g the Deputy National Commodore Information \\nTechnology and Planning (DNACO -ITP), Assistant National Commodore Planning and Student \\nPrograms (ANACO -PS), Assistant National Commodore for Diversity (ANACO -DV), Director \\nStudent Programs (DIR -S), Director Train ing (DIR -T), Director Computer Systems and Software \\n(DIR -C), and the District Commodores (DCOs), will partner with Flotilla Commanders (FCs), the \\nOffice of Auxiliary and Boating Safety (CG -BSX), Coast Guard Recruiting Command, the National \\nSea Scout Support Committee of the Boy Scouts of America, and the Coast Guard Academy. \\nMilestones : \\n1. Track Sea Scouts or AUP participants who are new Auxiliary members by having the ANSC -\\n7001 form modified. By 31 DEC 2022. \\n2. Update AUXDATA II to reflect Sea Scout and AUP membership. By 31 MAR 2023 . \\n3. Develop a way to track AUP selection rates to officer accession programs. By 31 MAR 2023 . \\n4. Develop the means to track Sea Scout selection to the Coast Guard Academy and to the Academy Introduction Mission (AIM). By 3 1 MAR 2023 \\n5. Update the AUP Leadership and Management Guide to simplify internal processes and \\ninstitutionalize best practices. By 3 0 JUN 2023 . \\n6. Integrate leadership development opportunities for the Auxiliary’s Sea Scout program into the AUP Program of Study . By 3 0 JUN 2023 . \\n7. Showcase at least one Student Programs post on the Coast Guard Auxiliary’s top -level social \\nmedia pages every quarter. Beginning 30 JUN 2023, and then ongoing . \\n8. Develop new relationships with at least one school in each Auxiliary district without an AUP unit with the goal of starting new brick-and- mortar units. By 31 DEC 2023. \\n9. Develop new relationships with military junior colleges with the goal of starting new brick-and- mortar unit s. By 31 DEC 2023 \\n10. Work with each district to assist them in developing new Auxiliary -chartered Sea Scout \\nShips . By 31 DEC 2023 \\n11. Develop an online workshop on Team Coast Guard careers. By 31 DEC 2023 . \\n '),\n", - " Document(metadata={'page': 543, 'source': 'References/Auxiliary Manual CIM_16790_1G.pdf', '_id': 'e11aead6-174a-450d-865f-fe54bc1e6993', '_collection_name': 'ASK_vectorstore'}, page_content='COMDTINST M16790.1G \\n \\n \\n \\n \\n(e) Demonstrated sincere interest and co ncern for others and their success \\nin the Coast Guard Auxiliary. \\n(f) Displayed a keen sense of ethical conduct and exhibited a high degree \\nof personal integrity. \\n(g) Earned the high esteem and admiration of others. \\n(h) Fostered the spirit a nd intent of diversity. \\n(i) Motivated others to excel in mission performance. \\n(j) Was a positive role model and mentor. \\n(k) Projected professional unifor m appearance and bearing. \\n(l) Other related contributions, achieveme nts, and awards during the period \\nshould be included for consideration. \\nA.16.f.(2) \\nSubmission \\nRequirements Commodore Charles S. Greanoff Inspira tional Leadership Award nomination \\npackages shall be processed as follows: \\n(a) The NACO shall solicit nominations during the month of September \\neach year. \\n(b) Nomination packages must originate at the Flotilla level and may be \\nsubmitted by any member directly to the DCDR. Packages must be \\nable to be electronically forwarde d and processed. Packages should \\nadhere to the minimum requirements pr escribed by the sample format in \\nAppendix F. The DCDR must submit the Division’s selection to the \\nDCO by 15 October. \\n(c) The district/regional EXCOM must validate all nomination packages \\nand determine which nomination to forward. The DCO shall endorse \\nand forward only one award nomination from the district/region to the \\nrespective DNACO by 1 November. \\n(d) Upon review of all packages, the DNACO shall endorse and forward all \\nnominations for the area to the Ch ief Director, with copies to the \\nVNACO and the NACO, for review by 5 November. \\n(e) Given concurrence of the VNACO an d the NACO, the Chief Director \\nshall forward all nomination packages to the Chief, Office of \\nLeadership and Development (CG-133) by 10 November. \\n(f) CG-133 shall convene a selection committee consisting of one O-6 \\n(Captain), one E-9 (Master Chief Pe tty Officer), one civilian, and one \\nAuxiliary Commodore. The final nominee will be selected by January. \\n11-18 '),\n", - " Document(metadata={'page': 194, 'source': 'References/Auxiliary Manual CIM_16790_1G.pdf', '_id': 'fb97a40f-ed61-4c9c-881a-c857adfb0af1', '_collection_name': 'ASK_vectorstore'}, page_content='COMDTINST M16790.1G \\n \\n \\n \\n \\n \\n \\nSection D. National \\nIntroduction The national level of administrati on contains the National Executive \\nCommittee (NEXCOM) presided over by the NACO and composed of the \\nChief Director, the Immediate Pa st National Commodore (IPNACO), \\nVNACO, and the four DNACOs. The Assistant National Commodores \\n(ANACOs) may attend NEXCOM meeti ngs upon invitation of the NACO, \\nbut are not voting Auxiliarists of th e NEXCOM. The NEXCOM functions \\nas the Auxiliary’s senior leadership and management team. The NEXCOM, \\nNational Board, and National Executive Staff comprise the Auxiliary \\nnational organization that maintains general Auxiliary leadership and \\nmanagement over all Auxiliary programs and activities. \\nD.1. Deputy \\nNational \\nCommodore \\n(DNACO) There shall be four DNACOs: DNACO-Operations (O), \\nDNACO-Recreational Boating Safe ty (RBS), DNACO-Mission Support \\n(MS), and DNACO-Information Tec hnology and Planning (ITP). Three \\nDNACOs shall be elected officers in accordance with the provisions of \\nAppendix C. These three DNACOs shall be elected to re present the three \\nAuxiliary Areas (Atlantic Area – East, Atlantic Area – West, and Pacific) \\namong the DNACO-O, DNACO-RBS, DNA CO-MS offices. The NACO, in \\nconsultation with the VNACO and IP NACO, shall select these three \\nDNACOs for their specific O, RBS, or MS office. \\nThe NACO, in consultation with the VNACO and IPNACO, shall select the \\nDNACO-ITP. Minimum eligibility criteria for this appointment shall be: \\ncompletion of a term of office as a DNACO-ITP or ANACO, or completion \\nof a term of office as DCO or above. Completion of any such term must \\nhave occurred within the past eight years. As an appointed position, \\nDNACO-ITP shall not be eligible for th e office of NACO or VNACO strictly \\nby having served in this office. \\nAll DNACO appointments shall only be made upon concurrence of the Chief \\nDirector. \\nD.2. Assistant \\nNational \\nCommodores \\n(ANACO) and \\nNational \\nDirectors The NACO shall appoint, with Chief Director concurrence, all ANACOs and \\nnational Directors and their deputies in order to define th e national staff for \\nadministration and management of Auxiliary programs. Associated office \\nfunctional statements shall be appended to the Auxiliary National Program \\nand the Auxiliary web site, www.cgaux.org . \\n4-17 ')],\n", - " 'answer': {'answer': 'To become the National Commodore of the Auxiliary, an Auxiliarist must be elected by the National Board. The National Board is composed of the National Executive Committee (NEXCOM), which includes the Chief Director, the Immediate Past National Commodore (IPNACO), Vice National Commodore (VNACO), and the four Deputy National Commodores (DNACOs). The National Commodore is elected from among the DNACOs. The process for electing the National Commodore is outlined in Appendix C of the Auxiliary Manual (COMDTINST M16790.1G).',\n", - " 'llm_sources': ['ALAUX 18-14 - CHIEF DIRECTOR FINAL ACTION ON NATIONAL BOARD RECOMMENDATIONS',\n", - " 'COMDTINST M16790.1G']}}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "response" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "answer_text = response['answer']['answer']\n", + "\n", + "# Print the answer\n", + "print(answer_text)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -161,6 +155,13 @@ " }\n", " '''" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {