CodeForPhilly / balancer-main

CodeForPhilly balancer project (https://opencollective.com/code-for-philly/projects/balancer)
GNU Affero General Public License v3.0
11 stars 8 forks source link

Create agent and tools; enable chatbot to answer general questions #174

Open katjost opened 1 week ago

katjost commented 1 week ago

The chatbot needs to be able to list all the medications in our database and be able to answer questions like:

  1. What are the side effects of medication x? (chatbot should check our DB)
  2. Does medication x interact with any blood pressure medications? (chatbot should ask ChatGPT because we don't have a drug interaction API)

Later on:

  1. Why is medication X in the second tier and not the first tier?
taichan03 commented 1 day ago
  1. System Table Purpose: This table stores system-level prompts that decide which agent should be engaged based on the user's query.

Fields:

id (Primary Key, INT, Auto-increment) – Unique identifier for each system prompt. prompt (VARCHAR) – The text prompt that the system uses to select the appropriate agent. agent_id (Foreign Key, INT) – References the agent to which the system directs the query based on the prompt. Example Schema:

  1. Agents Table Purpose: This table handles prompts from the system and determines which tool to use based on the agent's analysis.

Fields:

id (Primary Key, INT, Auto-increment) – Unique identifier for each agent. name (VARCHAR) – Name of the agent. tool_selection_prompt (VARCHAR) – The text prompt that the agent uses to select the correct tool. tool_id (Foreign Key, INT) – References the tool that will handle the request. Example Schema:

  1. Tools Table Purpose: This table contains the tools used to generate the response message based on the agent's selection.

Fields:

id (Primary Key, INT, Auto-increment) – Unique identifier for each tool. name (VARCHAR) – Name of the tool. response_prompt (TEXT) – The text prompt that the tool uses to generate the final return message. Example Schema:

Process Flow The System table uses a prompt to decide which agent from the Agents table should handle the request. The selected Agent evaluates the tool-selection prompt to decide which tool from the Tools table will generate the response. The Tool then uses its response_prompt to return the final message.

taichan03 commented 1 day ago

User Story: As a user, when I ask a question such as, "What meds are good for bipolar?", the system will:

  1. System Prompt: Analyze my question and determine which agent is best suited to handle it.
  2. Agent Selection: The selected agent will then evaluate my query and decide which tool is appropriate for generating the most accurate response.
  3. Tool Response Generation: Once the appropriate tool is selected, it will use a predefined prompt to generate the response and provide an answer to my query.
taichan03 commented 1 day ago

Feature: Admin-Controlled Agent and Tool Management via Database Feature Description: This feature enables system administrators to add new agents and tools by inserting rows directly into the PostgreSQL tables without requiring any additional coding or modifications on the Python backend.

User Story: As an administrator, I should be able to add new agents and tools to the system by simply inserting records into the respective database tables. The system will automatically recognize these new entries and use them as part of the query processing flow without any need for code changes or redeployments.

Requirements: PostgreSQL Tables: Agents Table: Admins can insert a new agent by adding a row into the agents table, specifying its name and associated prompts. Tools Table: Admins can insert a new tool by adding a row into the tools table, specifying the tool's name and its response-generation prompt. No Additional Code Changes: The system is designed in such a way that it dynamically uses the data from the agents and tools tables. When an admin adds a new agent or tool, the system will immediately recognize and incorporate it into the decision flow without requiring any Python code updates or redeployments. Example Scenario: Admin Task: Insert a new agent into the agents table. Insert a new tool into the tools table. The system will automatically incorporate these new entries when processing user queries. Benefit: This setup allows for flexible and scalable management of the system, where new agents and tools can be added by modifying the database, ensuring a quicker and more efficient update process.

taichan03 commented 1 day ago

what is bipolar? Could you show the list of meds stored in the database?