From 9a66f8c220075359bf4ed242b045954bebb5fd16 Mon Sep 17 00:00:00 2001 From: hfhoffman1144 Date: Mon, 22 Jan 2024 10:14:12 -0600 Subject: [PATCH] formatting fixes --- .../src/agents/hospital_rag_agent.py | 2 +- .../src/chains/hospital_review_chain.py | 13 +++++---- .../chatbot_frontend/src/main.py | 28 +++++++++++++------ .../src/hospital_bulk_csv_write.py | 12 ++------ langchain-rag-app/langchain_intro/chatbot.py | 7 +++-- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/langchain-rag-app/chatbot_api/src/agents/hospital_rag_agent.py b/langchain-rag-app/chatbot_api/src/agents/hospital_rag_agent.py index 650f45f7c4..675771db54 100644 --- a/langchain-rag-app/chatbot_api/src/agents/hospital_rag_agent.py +++ b/langchain-rag-app/chatbot_api/src/agents/hospital_rag_agent.py @@ -6,7 +6,7 @@ from chains.hospital_cypher_chain import hospital_cypher_chain from tools.wait_times import ( get_current_wait_times, - find_most_available_hospital + find_most_available_hospital, ) HOSPITAL_AGENT_MODEL = os.getenv("HOSPITAL_AGENT_MODEL") diff --git a/langchain-rag-app/chatbot_api/src/chains/hospital_review_chain.py b/langchain-rag-app/chatbot_api/src/chains/hospital_review_chain.py index 4f07e1673a..4fdb1f382f 100644 --- a/langchain-rag-app/chatbot_api/src/chains/hospital_review_chain.py +++ b/langchain-rag-app/chatbot_api/src/chains/hospital_review_chain.py @@ -19,10 +19,12 @@ password=os.getenv("NEO4J_PASSWORD"), index_name="reviews", node_label="Review", - text_node_properties=["physician_name", - "patient_name", - "text", - "hospital_name"], + text_node_properties=[ + "physician_name", + "patient_name", + "text", + "hospital_name", + ], embedding_node_property="embedding", ) @@ -36,7 +38,8 @@ review_system_prompt = SystemMessagePromptTemplate( prompt=PromptTemplate( - input_variables=["context"], template=review_template) + input_variables=["context"], template=review_template + ) ) review_human_prompt = HumanMessagePromptTemplate( diff --git a/langchain-rag-app/chatbot_frontend/src/main.py b/langchain-rag-app/chatbot_frontend/src/main.py index 3fadf3f6d5..e3cadb2a07 100644 --- a/langchain-rag-app/chatbot_frontend/src/main.py +++ b/langchain-rag-app/chatbot_frontend/src/main.py @@ -3,7 +3,8 @@ import streamlit as st CHATBOT_URL = os.getenv( - "CHATBOT_URL", "http://localhost:8000/hospital-rag-agent") + "CHATBOT_URL", "http://localhost:8000/hospital-rag-agent" +) with st.sidebar: st.header("About") @@ -21,7 +22,8 @@ st.header("Example Questions") st.markdown("- Which hospitals are in the hospital system?") st.markdown( - """- What is the current wait time at wallace-hamilton hospital?""") + """- What is the current wait time at wallace-hamilton hospital?""" + ) st.markdown( """- At which hospitals are patients complaining about billing and insurance issues?""" @@ -32,23 +34,28 @@ Castaneda-Hardy?""" ) st.markdown( - "- What was the total billing amount charged to each payer for 2023?") + "- What was the total billing amount charged to each payer for 2023?" + ) st.markdown("- What is the average billing amount for medicaid visits?") st.markdown( - "- Which physician has the lowest average visit duration in days?") + "- Which physician has the lowest average visit duration in days?" + ) st.markdown("- How much was billed for patient 789's stay?") st.markdown( """- Which state had the largest percent increase in medicaid visits from 2022 to 2023?""" ) st.markdown( - "- What is the average billing amount per day for Aetna patients?") + "- What is the average billing amount per day for Aetna patients?" + ) st.markdown( """- What was the percent change in average billing amount by state from 2022 to 2023?""" ) - st.markdown("""- How many reviews have been written from - patients in Florida?""") + st.markdown( + """- How many reviews have been written from + patients in Florida?""" + ) st.markdown( """- For visits that are not missing chief complaints, what percentage have reviews?""" @@ -106,6 +113,9 @@ st.status("How was this generated", state="complete").info(explanation) st.session_state.messages.append( - {"role": "assistant", "output": output_text, - "explanation": explanation} + { + "role": "assistant", + "output": output_text, + "explanation": explanation, + } ) diff --git a/langchain-rag-app/hospital_neo4j_etl/src/hospital_bulk_csv_write.py b/langchain-rag-app/hospital_neo4j_etl/src/hospital_bulk_csv_write.py index 85df9ebbc4..4df9a4a71f 100644 --- a/langchain-rag-app/hospital_neo4j_etl/src/hospital_bulk_csv_write.py +++ b/langchain-rag-app/hospital_neo4j_etl/src/hospital_bulk_csv_write.py @@ -38,10 +38,8 @@ def load_hospital_graph_from_csv() -> None: LOGGER.info("Setting uniqueness constraints on nodes") with driver.session(database="neo4j") as session: - query = ( - """CREATE CONSTRAINT IF NOT EXISTS FOR (h:Hospital) + query = """CREATE CONSTRAINT IF NOT EXISTS FOR (h:Hospital) REQUIRE h.id IS UNIQUE;""" - ) _ = session.run(query, {}) with driver.session(database="neo4j") as session: @@ -50,17 +48,13 @@ def load_hospital_graph_from_csv() -> None: _ = session.run(query, {}) with driver.session(database="neo4j") as session: - query = ( - """CREATE CONSTRAINT IF NOT EXISTS FOR (p:Physician) + query = """CREATE CONSTRAINT IF NOT EXISTS FOR (p:Physician) REQUIRE p.id IS UNIQUE;""" - ) _ = session.run(query, {}) with driver.session(database="neo4j") as session: - query = ( - """CREATE CONSTRAINT IF NOT EXISTS FOR (p:Patient) + query = """CREATE CONSTRAINT IF NOT EXISTS FOR (p:Patient) REQUIRE p.id IS UNIQUE;""" - ) _ = session.run(query, {}) with driver.session(database="neo4j") as session: diff --git a/langchain-rag-app/langchain_intro/chatbot.py b/langchain-rag-app/langchain_intro/chatbot.py index dd3c5cfebd..1991e12e4e 100644 --- a/langchain-rag-app/langchain_intro/chatbot.py +++ b/langchain-rag-app/langchain_intro/chatbot.py @@ -28,8 +28,9 @@ """ review_system_prompt = SystemMessagePromptTemplate( - prompt=PromptTemplate(input_variables=["context"], - template=review_template_str) + prompt=PromptTemplate( + input_variables=["context"], template=review_template_str + ) ) review_human_prompt = HumanMessagePromptTemplate( @@ -47,7 +48,7 @@ reviews_vector_db = Chroma( persist_directory=REVIEWS_CHROMA_PATH, - embedding_function=OpenAIEmbeddings() + embedding_function=OpenAIEmbeddings(), ) reviews_retriver = reviews_vector_db.as_retriever(k=10)