aasiavakil commited on
Commit
e00d62d
·
verified ·
1 Parent(s): d6e6d92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -12,12 +12,28 @@ with open("info.txt", "r", encoding="utf-8") as file:
12
  clinic_data = file.read().lower()
13
 
14
  # Keep track of conversation state
15
- conversation_state = {
16
- "stage": "intro",
17
- "age": None,
18
- "income": None,
19
- "last_eligible_program": None,
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Helper to get clinics by county
23
  def find_clinic_by_county(county_name, file_path="info.txt"):
 
12
  clinic_data = file.read().lower()
13
 
14
  # Keep track of conversation state
15
+ def chatbot(message, history, state):
16
+ # Use `state` dict instead of global `conversation_state`
17
+ if not state:
18
+ state = {
19
+ "stage": "intro",
20
+ "age": None,
21
+ "income": None,
22
+ "last_eligible_program": None,
23
+ }
24
+
25
+ message = message.strip().lower()
26
+
27
+ # (Insert your same logic here, replacing conversation_state with state)
28
+
29
+ # Example:
30
+ if state["stage"] == "intro":
31
+ response = "Hi! I can help you find free clinics in your Washington county, or figure out what health programs you may qualify for."
32
+ state["stage"] = "wait_for_choice"
33
+
34
+ # ... rest of your logic using state["..."]
35
+
36
+ return response, state
37
 
38
  # Helper to get clinics by county
39
  def find_clinic_by_county(county_name, file_path="info.txt"):