AliHaider0343 commited on
Commit
d73cde1
1 Parent(s): 7f85b91

Upload 17 files

Browse files
.chainlit/config.toml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ # Whether to enable telemetry (default: true). No personal data is collected.
3
+ enable_telemetry = true
4
+
5
+
6
+ # List of environment variables to be provided by each user to use the app.
7
+ user_env = []
8
+
9
+ # Duration (in seconds) during which the session is saved when the connection is lost
10
+ session_timeout = 3600
11
+
12
+ # Enable third parties caching (e.g LangChain cache)
13
+ cache = false
14
+
15
+ # Authorized origins
16
+ allow_origins = ["*"]
17
+
18
+ # Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
19
+ # follow_symlink = false
20
+
21
+ [features]
22
+ # Show the prompt playground
23
+ prompt_playground = true
24
+
25
+ # Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
26
+ unsafe_allow_html = false
27
+
28
+ # Process and display mathematical expressions. This can clash with "$" characters in messages.
29
+ latex = false
30
+
31
+ # Automatically tag threads with the current chat profile (if a chat profile is used)
32
+ auto_tag_thread = true
33
+
34
+ # Authorize users to spontaneously upload files with messages
35
+ [features.spontaneous_file_upload]
36
+ enabled = true
37
+ accept = ["*/*"]
38
+ max_files = 20
39
+ max_size_mb = 500
40
+
41
+ [features.audio]
42
+ # Threshold for audio recording
43
+ min_decibels = -45
44
+ # Delay for the user to start speaking in MS
45
+ initial_silence_timeout = 3000
46
+ # Delay for the user to continue speaking in MS. If the user stops speaking for this duration, the recording will stop.
47
+ silence_timeout = 1500
48
+ # Above this duration (MS), the recording will forcefully stop.
49
+ max_duration = 15000
50
+ # Duration of the audio chunks in MS
51
+ chunk_duration = 1000
52
+ # Sample rate of the audio
53
+ sample_rate = 44100
54
+
55
+ [UI]
56
+ # Name of the app and chatbot.
57
+ name = "Makewell Assistant"
58
+
59
+ # Show the readme while the thread is empty.
60
+ show_readme_as_default = true
61
+
62
+ # Description of the app and chatbot. This is used for HTML tags.
63
+ # description = ""
64
+
65
+ # Large size content are by default collapsed for a cleaner ui
66
+ default_collapse_content = false
67
+
68
+ # The default value for the expand messages settings.
69
+ default_expand_messages = true
70
+
71
+ # Hide the chain of thought details from the user in the UI.
72
+ hide_cot = false
73
+
74
+ # Link to your github repo. This will add a github button in the UI's header.
75
+ # github = ""
76
+
77
+ # Specify a CSS file that can be used to customize the user interface.
78
+ # The CSS file can be served from the public directory or via an external link.
79
+ # custom_css = "/public/test.css"
80
+
81
+ # Specify a Javascript file that can be used to customize the user interface.
82
+ # The Javascript file can be served from the public directory.
83
+ # custom_js = "/public/test.js"
84
+
85
+ # Specify a custom font url.
86
+ # custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
87
+
88
+ # Specify a custom build directory for the frontend.
89
+ # This can be used to customize the frontend code.
90
+ # Be careful: If this is a relative path, it should not start with a slash.
91
+ # custom_build = "./public/build"
92
+
93
+ [UI.theme]
94
+ layout = "wide"
95
+ font_family = "Inter, sans-serif"
96
+
97
+ # Override default MUI light theme. (Check theme.ts)
98
+ [UI.theme.light]
99
+ #background = "#FAFAFA"
100
+ #paper = "#FFFFFF"
101
+
102
+ [UI.theme.light.primary]
103
+ main = "#4B398F"
104
+ dark = "#4B398F"
105
+ light = "#FFE7EB"
106
+
107
+ # Override default MUI dark theme. (Check theme.ts)
108
+ [UI.theme.dark]
109
+ #background = "#FAFAFA"
110
+ #paper = "#FFFFFF"
111
+
112
+ [UI.theme.dark.primary]
113
+ main = "#4B398F"
114
+ dark = "#4B398F"
115
+ light = "#FFE7EB"
116
+
117
+
118
+ [meta]
119
+ generated_by = "1.1.101"
.chainlit/translations/en-US.json ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "components": {
3
+ "atoms": {
4
+ "buttons": {
5
+ "userButton": {
6
+ "menu": {
7
+ "settings": "Settings",
8
+ "settingsKey": "S",
9
+ "APIKeys": "API Keys",
10
+ "logout": "Logout"
11
+ }
12
+ }
13
+ }
14
+ },
15
+ "molecules": {
16
+ "newChatButton": {
17
+ "newChat": "New Chat"
18
+ },
19
+ "tasklist": {
20
+ "TaskList": {
21
+ "title": "\ud83d\uddd2\ufe0f Task List",
22
+ "loading": "Loading...",
23
+ "error": "An error occured"
24
+ }
25
+ },
26
+ "attachments": {
27
+ "cancelUpload": "Cancel upload",
28
+ "removeAttachment": "Remove attachment"
29
+ },
30
+ "newChatDialog": {
31
+ "createNewChat": "Create new chat?",
32
+ "clearChat": "This will clear the current messages and start a new chat.",
33
+ "cancel": "Cancel",
34
+ "confirm": "Confirm"
35
+ },
36
+ "settingsModal": {
37
+ "settings": "Settings",
38
+ "expandMessages": "Expand Messages",
39
+ "hideChainOfThought": "Hide Chain of Thought",
40
+ "darkMode": "Dark Mode"
41
+ },
42
+ "detailsButton": {
43
+ "using": "Using",
44
+ "running": "Running",
45
+ "took_one": "Took {{count}} step",
46
+ "took_other": "Took {{count}} steps"
47
+ },
48
+ "auth": {
49
+ "authLogin": {
50
+ "title": "Login to access the app.",
51
+ "form": {
52
+ "email": "Email address",
53
+ "password": "Password",
54
+ "noAccount": "Don't have an account?",
55
+ "alreadyHaveAccount": "Already have an account?",
56
+ "signup": "Sign Up",
57
+ "signin": "Sign In",
58
+ "or": "OR",
59
+ "continue": "Continue",
60
+ "forgotPassword": "Forgot password?",
61
+ "passwordMustContain": "Your password must contain:",
62
+ "emailRequired": "email is a required field",
63
+ "passwordRequired": "password is a required field"
64
+ },
65
+ "error": {
66
+ "default": "Unable to sign in.",
67
+ "signin": "Try signing in with a different account.",
68
+ "oauthsignin": "Try signing in with a different account.",
69
+ "redirect_uri_mismatch": "The redirect URI is not matching the oauth app configuration.",
70
+ "oauthcallbackerror": "Try signing in with a different account.",
71
+ "oauthcreateaccount": "Try signing in with a different account.",
72
+ "emailcreateaccount": "Try signing in with a different account.",
73
+ "callback": "Try signing in with a different account.",
74
+ "oauthaccountnotlinked": "To confirm your identity, sign in with the same account you used originally.",
75
+ "emailsignin": "The e-mail could not be sent.",
76
+ "emailverify": "Please verify your email, a new email has been sent.",
77
+ "credentialssignin": "Sign in failed. Check the details you provided are correct.",
78
+ "sessionrequired": "Please sign in to access this page."
79
+ }
80
+ },
81
+ "authVerifyEmail": {
82
+ "almostThere": "You're almost there! We've sent an email to ",
83
+ "verifyEmailLink": "Please click on the link in that email to complete your signup.",
84
+ "didNotReceive": "Can't find the email?",
85
+ "resendEmail": "Resend email",
86
+ "goBack": "Go Back",
87
+ "emailSent": "Email sent successfully.",
88
+ "verifyEmail": "Verify your email address"
89
+ },
90
+ "providerButton": {
91
+ "continue": "Continue with {{provider}}",
92
+ "signup": "Sign up with {{provider}}"
93
+ },
94
+ "authResetPassword": {
95
+ "newPasswordRequired": "New password is a required field",
96
+ "passwordsMustMatch": "Passwords must match",
97
+ "confirmPasswordRequired": "Confirm password is a required field",
98
+ "newPassword": "New password",
99
+ "confirmPassword": "Confirm password",
100
+ "resetPassword": "Reset Password"
101
+ },
102
+ "authForgotPassword": {
103
+ "email": "Email address",
104
+ "emailRequired": "email is a required field",
105
+ "emailSent": "Please check the email address {{email}} for instructions to reset your password.",
106
+ "enterEmail": "Enter your email address and we will send you instructions to reset your password.",
107
+ "resendEmail": "Resend email",
108
+ "continue": "Continue",
109
+ "goBack": "Go Back"
110
+ }
111
+ }
112
+ },
113
+ "organisms": {
114
+ "chat": {
115
+ "history": {
116
+ "index": {
117
+ "showHistory": "Show history",
118
+ "lastInputs": "Last Inputs",
119
+ "noInputs": "Such empty...",
120
+ "loading": "Loading..."
121
+ }
122
+ },
123
+ "inputBox": {
124
+ "input": {
125
+ "placeholder": "Type your message here..."
126
+ },
127
+ "speechButton": {
128
+ "start": "Start recording",
129
+ "stop": "Stop recording"
130
+ },
131
+ "SubmitButton": {
132
+ "sendMessage": "Send message",
133
+ "stopTask": "Stop Task"
134
+ },
135
+ "UploadButton": {
136
+ "attachFiles": "Attach files"
137
+ },
138
+ "waterMark": {
139
+ "text": "Built with"
140
+ }
141
+ },
142
+ "Messages": {
143
+ "index": {
144
+ "running": "Running",
145
+ "executedSuccessfully": "executed successfully",
146
+ "failed": "failed",
147
+ "feedbackUpdated": "Feedback updated",
148
+ "updating": "Updating"
149
+ }
150
+ },
151
+ "dropScreen": {
152
+ "dropYourFilesHere": "Drop your files here"
153
+ },
154
+ "index": {
155
+ "failedToUpload": "Failed to upload",
156
+ "cancelledUploadOf": "Cancelled upload of",
157
+ "couldNotReachServer": "Could not reach the server",
158
+ "continuingChat": "Continuing previous chat"
159
+ },
160
+ "settings": {
161
+ "settingsPanel": "Settings panel",
162
+ "reset": "Reset",
163
+ "cancel": "Cancel",
164
+ "confirm": "Confirm"
165
+ }
166
+ },
167
+ "threadHistory": {
168
+ "sidebar": {
169
+ "filters": {
170
+ "FeedbackSelect": {
171
+ "feedbackAll": "Feedback: All",
172
+ "feedbackPositive": "Feedback: Positive",
173
+ "feedbackNegative": "Feedback: Negative"
174
+ },
175
+ "SearchBar": {
176
+ "search": "Search"
177
+ }
178
+ },
179
+ "DeleteThreadButton": {
180
+ "confirmMessage": "This will delete the thread as well as it's messages and elements.",
181
+ "cancel": "Cancel",
182
+ "confirm": "Confirm",
183
+ "deletingChat": "Deleting chat",
184
+ "chatDeleted": "Chat deleted"
185
+ },
186
+ "index": {
187
+ "pastChats": "Past Chats"
188
+ },
189
+ "ThreadList": {
190
+ "empty": "Empty...",
191
+ "today": "Today",
192
+ "yesterday": "Yesterday",
193
+ "previous7days": "Previous 7 days",
194
+ "previous30days": "Previous 30 days"
195
+ },
196
+ "TriggerButton": {
197
+ "closeSidebar": "Close sidebar",
198
+ "openSidebar": "Open sidebar"
199
+ }
200
+ },
201
+ "Thread": {
202
+ "backToChat": "Go back to chat",
203
+ "chatCreatedOn": "This chat was created on"
204
+ }
205
+ },
206
+ "header": {
207
+ "chat": "Chat",
208
+ "readme": "Readme"
209
+ }
210
+ }
211
+ },
212
+ "hooks": {
213
+ "useLLMProviders": {
214
+ "failedToFetchProviders": "Failed to fetch providers:"
215
+ }
216
+ },
217
+ "pages": {
218
+ "Design": {},
219
+ "Env": {
220
+ "savedSuccessfully": "Saved successfully",
221
+ "requiredApiKeys": "Required API Keys",
222
+ "requiredApiKeysInfo": "To use this app, the following API keys are required. The keys are stored on your device's local storage."
223
+ },
224
+ "Page": {
225
+ "notPartOfProject": "You are not part of this project."
226
+ },
227
+ "ResumeButton": {
228
+ "resumeChat": "Resume Chat"
229
+ }
230
+ }
231
+ }
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ OPENAI_API_KEY = "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"
2
+ GOOGLE_API_KEY= 'AIzaSyAJjb0Koe8IdFWQB8jwaVTrwelav20wkMY'
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ Data/faiss_index/index.faiss filter=lfs diff=lfs merge=lfs -text
Data/Procedures_data.csv ADDED
The diff for this file is too large to render. See raw diff
 
Data/faiss_index/index.faiss ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:113a8107e79511816688346ffef7463616ecd8da6fbdbea033e9d5ec2a01dee1
3
+ size 10911789
Data/faiss_index/index.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8117b6d3e5f5939adf83aa8a4fa8a008305184b55fcbc091a07b78c9dff02a2e
3
+ size 1292821
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+ RUN useradd -m -u 1000 user
3
+ USER user
4
+ ENV HOME=/home/user \
5
+ PATH=/home/user/.local/bin:$PATH
6
+ WORKDIR $HOME/app
7
+ COPY --chown=user . $HOME/app
8
+ COPY ./requirements.txt ~/app/requirements.txt
9
+ RUN pip install -r requirements.txt
10
+ COPY . .
11
+ CMD ["chainlit", "run", "app.py", "--port", "7860"]
agent.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from imports import *
2
+
3
+ db = FAISS.load_local("Data/faiss_index", OpenAIEmbeddings(),allow_dangerous_deserialization=True)
4
+ retriever = db.as_retriever()
5
+
6
+ retrivers_tool = create_retriever_tool(
7
+ retriever,
8
+ "search_Procedures_Details",
9
+ "Returns the Details for Questions Creation based on the User Query and Extract the Medical Procedure Details according to given detials to finally Create Tentative Plan.",
10
+ )
11
+
12
+
13
+
14
+ our="""
15
+ ### Role: Health Care Plan Provider
16
+
17
+ ### Objective:
18
+ Your Objective is Ask the user Different Questions Understand his Conditions ,give him suggestions and then at very end of the conversation provide him the Detailed Plan.
19
+ Donot add any link or refer them to any website if you donot have the information directly Tell them I dont have enough information about that we will follow up soon.
20
+ ### Task:
21
+ 1. **Understand User Needs:**
22
+ - Engage with the user to understand their needs by asking various questions based on the data available in the database.
23
+ - Do not create the plan based on initial inputs alone. Ensure to gather detailed requirements first such as countyr , Location, Exact Procedure details and a lot of question for rqurieemnts clearification.
24
+
25
+ 2. **Information Gathering:**
26
+ - Inquire about the user's medical history, current prescriptions, and any specific concerns or preferences they have regarding the procedure.
27
+ - If the user provides prescription details, understand the procedure details and recommend the best available options.
28
+ - If the user is unsure about certain details, provide them with information and guide them to find the best plan.
29
+
30
+ 3. **Plan Creation:**
31
+ - Once you fully understand the user's requirements, create a detailed tentative plan for their procedure.
32
+ - Include all relevant details such as cost, procedure components, procedure factors, potential complications, treatment options, city, country, and any other pertinent information.
33
+ - Ask the user to confirm or modify the plan.
34
+
35
+ 4. **Follow-Up:**
36
+ - If you cannot find a relevant procedure, inform the user that the procedure is not offered but you will try to accommodate their request and follow up later.
37
+
38
+ ### Instructions for Answering:
39
+ 1. **Initial Interaction:**
40
+ - Ask for the user's name and email address before responding to their query.
41
+ - Do not respond to any queries until the user provides their name and email address. Continuously ask for this information until it is provided.
42
+
43
+ 2. **Answering Queries:**
44
+ - Once the user provides their name and email address, answer all their questions.
45
+ - Ensure that the responses are clear, informative, and address the user's concerns comprehensively.
46
+
47
+ 3. **Greet the User**:
48
+ - "Welcome to our Procedure Planning Assistant! We're here to help you find the best hospitals and doctors for your procedure. Are you planning a specific medical procedure?"
49
+
50
+ 4. **Handling General Procedure Names**:
51
+ - If the user provides a general name for the procedure, offer options from the database to help them specify the exact procedure they need.
52
+
53
+ 5. **Providing Accurate Information**:
54
+ - Provide accurate information.
55
+ - If the exact requested information is not available, inform the user directly without making up details.
56
+
57
+ 6. **Identifying Suitable Procedures**:
58
+ - Focus on identifying suitable procedures available by referencing the database based on the user's described scenario or query.
59
+
60
+ 7. **Relevance and Tone**:
61
+ - Keep responses relevant to the patient's inquiries.
62
+ - Maintain a welcoming and approachable tone.
63
+ - Avoid providing redundant information or delving into unrelated topics.
64
+
65
+ 7. **Asking Questions**:
66
+ - Ask each question on a single topic, one by one.
67
+ - Do not ask for information that the user has already provided earlier or in the current response.
68
+
69
+ 8. **Closing the Conversation**:
70
+ - Close the conversation with: "We hope you found our service helpful! Your feedback is valuable to us. Would you recommend our Procedure Planning Assistant to others? Is there anything we could improve?"
71
+ - Follow up with: "Thank you for using our Procedure Planning Assistant! We're here to help you throughout your procedure journey. Feel free to reach out if you have any questions or need further assistance."
72
+
73
+ 9. **Understanding and Explaining Procedures**:
74
+ - Understand the procedure and explain it to the user before addressing other concerns such as country, city, language, and cost.
75
+
76
+ 10. **Empathy**:
77
+ - Be empathetic, not overly excited.
78
+
79
+ 11. **Offering Information**:
80
+ - Offer the user information based on what is available in the database.
81
+ - Seek specific details from the user's input.
82
+
83
+ 12. **Confirming Plan Details**:
84
+ - After presenting plans and answering questions, ask the user to confirm the plan details so they can be saved to the database.
85
+
86
+ 13. **Use of Exact Information**:
87
+ - Use exact hospital names, procedure names, and currencies.
88
+ - Avoid placeholder or dummy information.
89
+
90
+ Must follow each of the Instruction everytime.
91
+ """
92
+
93
+ prompt = hub.pull("hwchase17/openai-tools-agent")
94
+ prompt.messages[0].prompt.template=our
95
+ llm = ChatOpenAI(model="gpt-4",temperature=0)
96
+ tools = [retrivers_tool]
97
+ agent = create_openai_tools_agent(llm, tools, prompt)
98
+ agent_executor = AgentExecutor(agent=agent, tools=tools)
99
+
100
+ chat_history=[]
101
+ def generate_response(query:str):
102
+ # Here we pass in an empty list of messages for chat_history because it is the first message in the chat
103
+ res=agent_executor.invoke({"input": query, "chat_history": chat_history})
104
+ chat_history.append(HumanMessage(content=query))
105
+ chat_history.append(AIMessage(content=res["output"]))
106
+ return res["output"]
107
+
108
+ #######################
109
+ # import ast
110
+ # def extract_data(chat_history):
111
+ # template = """
112
+ # you are a helpful chat history summarizer for Health Plan Provider your task is to summarize the chat history and extract the Final Tentative Plan information from the chat history like:procedure,procedure components,Procedure includes,Procedure factors, potential complications, treatment, preferred city, preferred country, minimum cost, maximum cost, Complete Plan Text,Prefered date, other information. and return the extracted information in the foramt of python list for example ["procedure","procedure components","Procedure includes","Procedure factors","potential complications", "treatment", "preferred city", "preferred country", "minimum cost", "maximum cost", "Complete Plan Text","Prefered Date", "other information"] here is the history: {chat_history}
113
+ # """
114
+ # prompt_template = PromptTemplate(template=template,
115
+ # input_variables=["chat_history"])
116
+ # chain = LLMChain(llm=OpenAI(), prompt=prompt_template)
117
+ # res = chain.run(chat_history)
118
+ # res=ast.literal_eval(res)
119
+ # return res
120
+
121
+
chainlit.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ![Makewell](public/logo_dark.png)
2
+
3
+ # Health Makewell Assistant 🚑
4
+ Welcome to the Health Care Plan Provider Chatbot! This chatbot is designed to assist you in creating a detailed tentative health care plan based on your medical prescription records and conversations.
5
+
6
+ ## 🎯 Objective
7
+ Our primary goal is to understand your medical needs and provide a comprehensive health care plan tailored specifically for you. This plan will include:
8
+
9
+ - **Cost 💰**
10
+ - **Procedure Components 🧩**
11
+ - **Procedure Details 📋**
12
+ - **Potential Complications ⚠️**
13
+ - **Treatment Options 💊**
14
+ - **City and Country 🌍**
15
+ - **Minimum and Maximum Costs 💸**
16
+ - **Any Other Relevant Information 📚**
17
+
18
+
19
+
20
+
21
+
22
+
23
+
imports.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.chains import LLMChain
2
+ from langchain.prompts import PromptTemplate
3
+ from langchain.llms import OpenAI
4
+ import pandas as pd
5
+ from langchain_community.document_loaders.csv_loader import CSVLoader
6
+ from langchain_community.vectorstores import FAISS
7
+ from langchain_openai import OpenAIEmbeddings
8
+ from langchain_text_splitters import RecursiveCharacterTextSplitter
9
+ import os
10
+ from langchain.tools.retriever import create_retriever_tool
11
+ from langchain import hub
12
+ from langchain_openai import ChatOpenAI
13
+ from langchain.agents import AgentExecutor, create_openai_tools_agent
14
+ from langchain.schema import SystemMessage, AIMessage, HumanMessage
15
+
16
+ os.environ['OPENAI_API_KEY']='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'
ingest.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from imports import *
2
+
3
+ loader = CSVLoader(file_path='Data/Procedures_data.csv')
4
+ documents = loader.load()
5
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
6
+ texts = text_splitter.split_documents(documents)
7
+ embeddings = OpenAIEmbeddings()
8
+ db = FAISS.from_documents(texts, embeddings)
9
+ db.save_local("Data/faiss_index")
main.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agent import generate_response,chat_history
2
+ import chainlit as cl
3
+ import fitz # PyMuPDF for PDF extraction
4
+ import pytesseract
5
+ from PIL import Image
6
+ import io
7
+
8
+
9
+ @cl.author_rename
10
+ def rename(orig_author: str):
11
+ rename_dict = {"Chatbot": "Makewell Assitant"}
12
+ return rename_dict.get(orig_author, orig_author)
13
+
14
+ @cl.on_chat_start
15
+ async def start():
16
+ await cl.Message(content=f"""# Welcome to Makewell Assistant!
17
+ Hi There,👋 We're excited to have you on board This Conversational Solution is designed to assist you in creating a detailed tentative health care plan based on your medical prescription records and conversations.
18
+ .
19
+ """).send()
20
+
21
+ # @cl.on_message
22
+ # async def main(message: cl.Message):
23
+ # res = generate_response(message.content)
24
+ # if message.content.lower() == "confirm":
25
+ # print("confirm is called")
26
+ # user_data=extract_data(chat_history=chat_history)
27
+ # await cl.Message(res, author="AppointmentBot").send()
28
+ @cl.on_message
29
+ async def main(message: cl.Message):
30
+ if message.elements:
31
+ texts = []
32
+
33
+ images = [file for file in message.elements if "image" in file.mime]
34
+
35
+ for image in images:
36
+ image_data = await image.get_bytes()
37
+ image_text = await extract_text_from_image(image_data)
38
+ texts.append(image_text)
39
+
40
+ if texts:
41
+ res = "\n".join(texts)
42
+ else:
43
+ res = "No supported files were found in the attachments."
44
+ else:
45
+ res = generate_response(message.content)
46
+
47
+ if message.content.lower() == "confirm":
48
+ user_data = extract_data(chat_history=chat_history)
49
+
50
+ await cl.Message(content=res, author="Makewell Assistant").send()
51
+
52
+ async def extract_text_from_pdf(attachment):
53
+ pdf_data = await attachment.get_bytes()
54
+ pdf_text = ""
55
+ with fitz.open(io.BytesIO(pdf_data)) as doc:
56
+ for page in doc:
57
+ pdf_text += page.get_text()
58
+ return pdf_text
59
+
60
+ async def extract_text_from_image(image_data):
61
+ image = Image.open(io.BytesIO(image_data))
62
+ image_text = pytesseract.image_to_string(image)
63
+ return image_text
public/cropped.png ADDED
public/favicon ADDED
Binary file (62.2 kB). View file
 
public/logo_dark.png ADDED
public/logo_light.png ADDED
requirements.txt ADDED
Binary file (10.9 kB). View file