hub9-assignment / app.py
datafreak's picture
Update app.py
5eaa060 verified
import gradio as gr
import os
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq
from langchain_core.prompts import FewShotChatMessagePromptTemplate
from dotenv import load_dotenv
load_dotenv()
api_key = os.getenv("GROQ_API_KEY")
example_prompt = ChatPromptTemplate.from_messages(
[
("human", "{input}"),
("ai", "{output}"),
]
)
chat = ChatGroq(model = "mixtral-8x7b-32768", api_key = api_key)
examples = [
{
"input": "What does the eligibility verification agent (EVA) do?",
"output": "EVA automates the process of verifying a patient’s eligibility and benefits information in real-time, eliminating manual data entry errors and reducing claim rejections."
},
{
"input": "What does the claims processing agent (CAM) do?",
"output": "CAM streamlines the submission and management of claims, improving accuracy, reducing manual intervention, and accelerating reimbursements."
},
{
"input": "How does the payment posting agent (PHIL) work?",
"output": "PHIL automates the posting of payments to patient accounts, ensuring fast, accurate reconciliation of payments and reducing administrative burden."
},
{
"input": "Tell me about Hub9 AI's Agents.",
"output": "Hub9 AI provides a suite of AI-powered automation agents designed to streamline healthcare processes. These include Eligibility Verification (EVA), Claims Processing (CAM), and Payment Posting (PHIL), among others."
},
{
"input": "What are the benefits of using Hub9 AI's agents?",
"output": "Using Hub9 AI's Agents can significantly reduce administrative costs, improve operational efficiency, and reduce errors in critical processes like claims management and payment posting."
}
]
prompt = FewShotChatMessagePromptTemplate(
examples=examples,
example_prompt = example_prompt,
)
final_prompt = ChatPromptTemplate.from_messages(
[
("system", "You have extensive knowledge of Hub9 AI. DO NOT HALLUCINATE."),
prompt,
("human", "{input}"),
]
)
chain = final_prompt | chat
def response(text, history):
answer = chain.invoke(text)
return answer.content
gr.ChatInterface(
response,
type="messages"
).launch()