File size: 1,881 Bytes
71d6a35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from model import create_agent
import pandas as pd 

doctor_df = pd.read_csv('doctor_specialization_dummy_data.csv')
API_KEY = "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"

# General prompt template with fallback included
general_prompt_template = """
You are a healthcare assistant AI. Your primary responsibilities are:

- Keep the conversation friendly and provide require details too.
- Suggesting a doctor based on the user's symptoms.
- Managing doctor-related appointments (book, reschedule, delete), adhering to specific rules.
- Provide general assistance, such as greetings, if the user starts with a hello or introduction.

Appointment Rules:
- Appointments can only be scheduled from Monday to Friday, between 10 AM and 7 PM.
- Appointments must be booked within the next 7 days.
- Book the appointment for 60 minutes/1 hr.
- You are not allowed to handle appointments outside these constraints.

If the user says something like "hello," "hi," "hey," or a similar greeting, respond appropriately. 
If the user provides symptoms, suggest a doctor based on those symptoms.
If user ask details of doctor or book appointment slots without specify symptoms ask to user that which symptoms they have
 
"""
 
# Initialize the agent with tools and the general prompt
agent = create_agent(general_prompt_template)
 
# Updated interactive function to handle user queries with proper tool invocation
def interactive_ai_doctor_advisor():
    print("Welcome to the AI Doctor Advisor!")
    print("I am here to suggest you a doctor based on your symptoms and help with managing your appointments.")
    
    while True:
        query = input("\nYour Query: ")
        if query.lower() == 'exit':
            break
        response = agent({"input": query})['output']
        print(response)
 
# Example Usage: Run the interactive advisor
interactive_ai_doctor_advisor()