Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
from langchain_core.prompts import ChatPromptTemplate
|
4 |
+
from langchain_groq import ChatGroq
|
5 |
+
from langchain_core.prompts import FewShotChatMessagePromptTemplate
|
6 |
+
from dotenv import load_dotenv
|
7 |
+
|
8 |
+
load_dotenv()
|
9 |
+
api_key = os.getenv("GROQ_API_KEY")
|
10 |
+
|
11 |
+
example_prompt = ChatPromptTemplate.from_messages(
|
12 |
+
[
|
13 |
+
("human", "{input}"),
|
14 |
+
("ai", "{output}"),
|
15 |
+
]
|
16 |
+
)
|
17 |
+
|
18 |
+
chat = ChatGroq(model = "mixtral-8x7b-32768", api_key = api_key)
|
19 |
+
examples = [
|
20 |
+
{
|
21 |
+
"input": "What does the eligibility verification agent (EVA) do?",
|
22 |
+
"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."
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"input": "What does the claims processing agent (CAM) do?",
|
26 |
+
"output": "CAM streamlines the submission and management of claims, improving accuracy, reducing manual intervention, and accelerating reimbursements."
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"input": "How does the payment posting agent (PHIL) work?",
|
30 |
+
"output": "PHIL automates the posting of payments to patient accounts, ensuring fast, accurate reconciliation of payments and reducing administrative burden."
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"input": "Tell me about Hub9 AI's Agents.",
|
34 |
+
"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."
|
35 |
+
},
|
36 |
+
{
|
37 |
+
"input": "What are the benefits of using Hub9 AI's agents?",
|
38 |
+
"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."
|
39 |
+
}
|
40 |
+
|
41 |
+
]
|
42 |
+
|
43 |
+
prompt = FewShotChatMessagePromptTemplate(
|
44 |
+
examples=examples,
|
45 |
+
example_prompt = example_prompt,
|
46 |
+
)
|
47 |
+
|
48 |
+
final_prompt = ChatPromptTemplate.from_messages(
|
49 |
+
[
|
50 |
+
("system", "You have extensive knowledge of Hub9 AI. DO NOT HALLUCINATE."),
|
51 |
+
prompt,
|
52 |
+
("human", "{input}"),
|
53 |
+
]
|
54 |
+
)
|
55 |
+
|
56 |
+
chain = final_prompt | chat
|
57 |
+
|
58 |
+
def response(text):
|
59 |
+
answer = chain.invoke(text)
|
60 |
+
return answer
|
61 |
+
|
62 |
+
gr.ChatInterface(
|
63 |
+
fn=response,
|
64 |
+
type="messages"
|
65 |
+
).launch()
|