|
My Project
|
Functions | |
| _get_error_log_path () | |
| str | get_current_time_tool () |
| str | get_department_list_tool () |
| str | get_departments_in_category_tool (str category) |
| str | course_query_tool_by_code (str course_code) |
| str | course_query_tool_by_title (str course_title) |
| str | course_filter_tool (schemas.CourseFilters filters=None) |
| str | get_course_description_tool (int course_id) |
| str | section_filter_tool (schemas.SectionFilters filters=None) |
| str | get_student_basic_info_tool (ToolRuntime runtime) |
| str | get_student_course_history_tool (ToolRuntime runtime) |
| str | get_student_interests_tool (ToolRuntime runtime) |
| str | get_student_tracked_sections_tool (ToolRuntime runtime) |
| str | get_program_requirements_tool (str program_name) |
| str | get_upcoming_events_tool () |
| str | get_event_dates_tool (str event_name) |
| str | web_search_tool (str query, int max_results=5) |
| str | get_web_page_content_tool (str url, int max_chars=3000) |
| str | insert_student_interests_tool (ToolRuntime runtime, str interest) |
| str | insert_student_tracked_sections_tool (ToolRuntime runtime, str course_code, str section_id) |
| str | get_student_id_by_name_tool (ToolRuntime runtime, str student_name) |
| str | get_advisor_students_tool (ToolRuntime runtime) |
| str | a_get_student_basic_info_tool (ToolRuntime runtime, int student_id) |
| str | a_get_student_course_history_tool (ToolRuntime runtime, int student_id) |
| str | a_get_student_interests_tool (ToolRuntime runtime, int student_id) |
| str | a_get_student_tracked_sections_tool (ToolRuntime runtime, int student_id) |
Variables | |
| ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) | |
| PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) | |
| CONFIG_PATH = os.path.join(ROOT_DIR, "config.json") | |
| CONFIG = json.load(f) | |
| TOOL_CONFIG = CONFIG["tool_select"] | |
| DEPARTMENT_LIST_PATH = os.path.join(ROOT_DIR, "department_mapping.json") | |
| dict | DEPARTMENT_LIST = {"departments": []} |
| START_TIMESTAMP = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| ERROR_LOG_DIR = os.path.join(ROOT_DIR, "error_logs") | |
| exist_ok | |
| list | d_tools |
| list | db_tools = [] |
| list | w_tools |
| list | web_tools = [] |
| list | i_tools |
| list | insertion_tools = [] |
| list | ad_tools |
| list | alt_db_tools = [] |
Copyright 2026 Luca Silver This file contains the tool implementations for the course-planning agent. Each tool is defined as a function decorated with `@tool` from LangChain, which specifies the tool's name, description, and return behavior. Database agent tools for student users: - `get_current_time_tool`: Retrieves the current date and time as a formatted string. - `get_department_list_tool`: Retrieves a list of all 3-letter department codes and their meanings. - `get_departments_in_category_tool`: Retrieves a list of what types of courses are considered a part of a specified category. - `course_query_tool_by_code`: Retrieves information about a specific course based on its course code. - `course_query_tool_by_title`: Retrieves information about a specific course based on its title. - `course_filter_tool`: Retrieves a list of courses that match specified filter criteria. - `get_course_description_tool`: Retrieves the description of a course based on its ID. - `section_filter_tool`: Retrieves a list of sections that match specified filter criteria. - `get_student_basic_info_tool`: Retrieves basic profile information for the current student user, including their name, email, advisor, GPA, total credits, and programs of study. - `get_student_course_history_tool`: Retrieves the course history for the current student user, including course codes, titles, and grades. - `get_student_interests_tool`: Retrieves the interests for the current student user. - `get_student_tracked_sections_tool`: Retrieves the course sections that the student user is currently tracking for openings. - `get_program_requirements_tool`: Retrieves the course requirements for a specified program of study. - `get_upcoming_events_tool`: Retrieves a list of upcoming events. - `get_event_dates_tool`: Retrieves the dates for a specified event. Database agent tools for advisor users: - `get_current_time_tool`: Retrieves the current date and time as a formatted string. - `get_department_list_tool`: Retrieves a list of all 3-letter department codes and their meanings. - `get_departments_in_category_tool`: Retrieves a list of what types of courses are considered a part of a specified category. - `course_query_tool_by_code`: Retrieves information about a specific course based on its course code. - `course_query_tool_by_title`: Retrieves information about a specific course based on its title. - `course_filter_tool`: Retrieves a list of courses that match specified filter criteria. - `get_course_description_tool`: Retrieves the description of a course based on its ID. - `section_filter_tool`: Retrieves a list of sections that match specified filter criteria. - `get_student_id_by_name_tool`: Retrieves a student's ID based on their name. Only works for students who have the current user as their advisor. - `get_advisor_students_tool`: Retrieves a list of students assigned to the advisor user, including their names and IDs. - `a_get_student_basic_info_tool`: Retrieves basic profile information for a specified student who is assigned to the advisor user, including their name, email, advisor, GPA, total credits, and programs of study. - `a_get_student_course_history_tool`: Retrieves the course history for a specified student who is assigned to the advisor user, including course codes, titles, and grades. - `a_get_student_interests_tool`: Retrieves the current interests for a specified student who is assigned to the advisor user. - `a_get_student_tracked_sections_tool`: Retrieves the sections that a specified student who is assigned to the advisor user is currently tracking for openings. - `get_program_requirements_tool`: Retrieves the course requirements for a specified program of study. - `get_upcoming_events_tool`: Retrieves a list of upcoming events. - `get_event_dates_tool`: Retrieves the dates for a specified event. Insertion agent tools: - `get_student_interests_tool`: Retrieves the interests for the current student user. - `get_student_tracked_sections_tool`: Retrieves the course sections that the student user is currently tracking for openings. - `insert_student_interests_tool`: Inserts a new interest for the current student user. - `insert_student_tracked_section_tool`: Inserts a new tracked section for the current student user. Web agent tools: - `web_search_tool`: Performs a web search for a given query and returns a list of results with sources. - `fetch_web_page_content_tool`: Fetches and extracts the main textual content from a specified URL. Individual tools can be disabled using the `tool_config.json` file. If a tool is disabled, it will not be registered with the agent and cannot be called by the agent's language model. This allows for dynamic control over which tools the agent has access to without needing to modify the code.
|
protected |
Ensure error_logs directory exists and return the path for error log file.
| str a_get_student_basic_info_tool | ( | ToolRuntime | runtime, |
| int | student_id ) |
Return basic profile information for an advisor-visible student.
Performs advisor ownership checks, then wraps `database_utils.get_student_basic_info`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID.
student_id (int): Student ID to retrieve:
Format: Primary key value from `Students.ID` column (e.g. 12345).
Returns:
out (str): JSON-encoded student profile info:
Format: {
"Name": str,
Format: Student name as stored in `Students.Name` column (e.g. "Alice Smith")
"Email": str,
Format: Student email as stored in `Students.Email` column (e.g. "alice@university.edu")
"Advisor": str,
Format: Advisor name as stored in `Advisors.Name` column (e.g. "Dr. John Doe")
"GPA": float,
Format: GPA value as stored in `Students.GPA` column (e.g. 3.75)
"CreditsEarned": int,
Format: Total credits earned as stored in `Students.CreditsEarned` column (e.g. 90)
"ProgramsOfStudy": list[dict]
Format of list items: {
"Title": str,
Format: Program title as stored in `ProgramsOfStudy.Title` column (e.g. "Computer Information Systems")
"Status": str
Format: Status string as stored in `StudentProgramsOfStudy.Status` column (e.g. "Declared", "In Progress", "Completed")
}
}
Access failure format: "Student with ID {student_id} is not assigned to the current user."
Not-found format: "No student found with ID {student_id}"
| str a_get_student_course_history_tool | ( | ToolRuntime | runtime, |
| int | student_id ) |
Return course history for an advisor-visible student.
Performs advisor ownership checks, then wraps `database_utils.get_student_course_history`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID.
student_id (int): Student ID to retrieve:
Format: Primary key value from `Students.ID` column (e.g. 12345).
Returns:
out (str): JSON-encoded list of course-history entries:
Format: List[{
"CourseCode": str,
Format: Course code as stored in `Courses.Code` column (e.g. "CS101")
"Name": str,
Format: Course name as stored in `Courses.Name` column (e.g. "Introduction to Computer Science")
"Grade": str
Format: Grade string as stored in `StudentCourseHistory.Grade` column (e.g. "A", "B+", "Pass", "Fail")
}]
Note: If no courses are found, serialized value is ["No courses taken"].
Access failure format: "Student with ID {student_id} is not assigned to the current user."
Not-found format: "No student found with ID {student_id}"
| str a_get_student_interests_tool | ( | ToolRuntime | runtime, |
| int | student_id ) |
Return interests for an advisor-visible student.
Performs advisor ownership checks, then wraps `database_utils.get_student_interests`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID.
student_id (int): Student ID to retrieve:
Format: Primary key value from `Students.ID` column (e.g. 12345).
Returns:
out (str): JSON-encoded list of interests:
Format of list items: Interest string as stored in `Interests.Interest`.
Note: If no interests are found, serialized value is ["No interests specified"].
Access failure format: "Student with ID {student_id} is not assigned to the current user."
Not-found format: "No student found with ID {student_id}"
| str a_get_student_tracked_sections_tool | ( | ToolRuntime | runtime, |
| int | student_id ) |
Return tracked sections for an advisor-visible student.
Performs advisor ownership checks, then wraps `database_utils.get_student_tracked_sections`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID.
student_id (int): Student ID to retrieve:
Format: Primary key value from `Students.ID` column (e.g. 12345).
Returns:
out (str): JSON-encoded list of tracked sections:
Format: List[{
"CourseCode": str,
Format: Course code as stored in `Courses.Code` column (e.g. "CS101")
"SectionNumber": str,
Format: Section number as stored in `Sections.SectionNumber` column (e.g. "001")
"Name": str,
Format: Section name as stored in `Sections.Name` column (e.g. "Introduction to Computer Science")
}]
Note: If no tracked sections are found, serialized value is ["No sections currently being tracked"].
Access failure format: "Student with ID {student_id} is not assigned to the current user."
Not-found format: "No student found with ID {student_id}"
| str course_filter_tool | ( | schemas.CourseFilters | filters = None | ) |
Return courses that match the provided `schemas.CourseFilters`.
Wraps `database_utils.get_courseIDs_by_filters` then resolves each ID with
`database_utils.get_course_info_by_id`.
Args:
filters (schemas.CourseFilters): Filters to apply to the course search:
Format: {
Optional[List[DBTerm]] terms,
DBTerm format: {
"year": int,
Format: 4-digit year (e.g. 2024)
"season": str,
Format: ["Fall", "Winter", "Spring", "Summer"]
"number": Optional[int]
Format: Integer term number (e.g. 1, 2, 3, etc).
Note: If not provided, filter matches any term number for the given year/season.
}
Note: Uses OR logic
Optional[List[str]] departments,
Format: Department abbreviations as stored in `Courses.Department` (e.g. ["PHY", "MAT"]).
Note: Uses OR logic
Optional[List[CodeCondition]] course_levels,
CodeCondition format: {
"condition": str ["=" | ">" | "<" | ">=" | "<=" | "!="],
"code": str
Format: Course number as stored in `Courses.Code` (e.g. "101", "210").
}
Note: Uses AND logic
Optional[List[CreditCondition]] credits,
CreditCondition format: {
"condition": str ["=" | ">" | "<" | ">=" | "<=" | "!="],
"credits": int (e.g. 3 or 4)
}
Note: Uses AND logic
Optional[List[str]] keywords,
Format: Keywords searched in `Courses.Description`.
Note: Uses OR logic
Optional[List[str]] prerequisites,
Format: Keywords searched in `Courses.Requirements`.
Note: Uses OR logic
}
Returns:
out (str): JSON-encoded list of course metadata dicts:
Format: List[{
"ID": str,
Format: Primary key value from `Courses.ID` column (eg. "12345")
"Name": str,
Format: Course name as stored in `Courses.Name` (e.g. "Introduction to Computer Science")
"Department": str,
Format: Department abbreviation as stored in `Courses.Department` (e.g. "HST")
"Code": str,
Format: Course number as stored in `Courses.Code` (e.g. "101")
"Credits": int,
Format: Number of credits as stored in `Courses.Credits` (e.g. 3)
"Requirements": str
Format: Text string from `Courses.Requirements` column describing prerequisites/requirements.
}]
Note: If no matches are found, returns "No courses found matching the specified criteria.".
Raises:
ValueError: Propagated from underlying filter logic when an invalid operator is provided:
Course code error message: "Invalid course code condition: {condition}"
Credit error message: "Invalid credit condition: {condition}"
Warnings:
Don't use this tool with overly broad filters (eg: all courses in a given term or all courses in a department) as it can return a lot of courses and consume a lot of tokens. Always wait until you have narrowed down the filters as much as possible before using this tool.
| str course_query_tool_by_code | ( | str | course_code | ) |
Return course metadata for a course identified by its course code.
Wraps `database_utils.get_courseID_by_code` and `database_utils.get_course_info_by_id`.
Args:
course_code (str): The course code to look up:
Format: "DPT NUM" | "DPTNUM" (eg. "MAT 101" or "MAT101").
Returns:
out (str): Either a not-found message or course metadata for the matched course:
Format if found: {
"ID": str,
Format: Primary key value from `Courses.ID` column (eg. "12345")
"Name": str,
Format: Course name as stored in `Courses.Name` (e.g. "Introduction to Computer Science")
"Department": str,
Format: Department abbreviation as stored in `Courses.Department` (e.g. "HST")
"Code": str,
Format: Course number as stored in `Courses.Code` (e.g. "101")
"Credits": int,
Format: Number of credits as stored in `Courses.Credits` (e.g. 3)
"Requirements": str
Format: Text string from `Courses.Requirements` column describing prerequisites/requirements.
}
Format if not found: "No course found with code {course_code}."
| str course_query_tool_by_title | ( | str | course_title | ) |
Return course metadata for a course identified by its title.
Wraps `database_utils.get_courseID_by_title`, `database_utils.get_coops`, and
`database_utils.get_course_info_by_id`.
Args:
course_title (str): The course title to look up.
Format: Exact course title as stored in `Courses.Name` column (eg. "Introduction to Computer Science").
Returns:
out (str): Either a not-found/clarification message or course metadata:
Format if found: {
"ID": str,
Format: Primary key value from `Courses.ID` column (eg. "12345")
"Name": str,
Format: Course name as stored in `Courses.Name` (e.g. "Introduction to Computer Science")
"Department": str,
Format: Department abbreviation as stored in `Courses.Department` (e.g. "HST")
"Code": str,
Format: Course number as stored in `Courses.Code` (e.g. "101")
"Credits": int,
Format: Number of credits as stored in `Courses.Credits` (e.g. 3)
"Requirements": str
Format: Text string from `Courses.Requirements` column describing prerequisites/requirements.
}
Format if not found: "No course found with title {course_title}."
Warnings:
Course-title lookup assumes titles are unique except for "Cooperative Work Experience".
For that title, this tool returns a clarification message containing matching course IDs and asks for a code-based query.
| str get_advisor_students_tool | ( | ToolRuntime | runtime | ) |
Return a list of students assigned to the current advisor.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID.
Returns:
out (str): JSON-encoded list of students assigned to the current advisor:
Format: List[{
"name": str,
Format: Student name as stored in `Students.Name` column (e.g. "Alice Smith")
"id": int
Format: Primary key value from `Students.ID` column (e.g. 12345)
}]
Note: If no students are found for the current advisor, returns a message indicating that no students were found.
| str get_course_description_tool | ( | int | course_id | ) |
Return the textual description for a course identified by `course_id`.
Wraps `database_utils.get_course_description_by_id`.
Args:
course_id (int): The ID of the course to retrieve the description for:
Format: Primary key value from `Courses.ID` column (eg. "12345").
Returns:
out (str): Course description as stored in `Courses.Description` for the matched course:
Format: Text string from `Courses.Description` column describing the course.
Note: If no course is found with that ID, returns "Course not found".
Warnings:
Don't use this tool for more than a few courses at a time, as it can consume a lot of tokens.
| str get_current_time_tool | ( | ) |
Return the current date and time as a formatted string.
Returns:
out (str): Current date and time:
Format: "YYYY-MM-DD HH:MM:SS"
| str get_department_list_tool | ( | ) |
Return the list of 3-letter department codes.
Returns:
out (str): JSON-encoded list of all department mappings:
Format: List[{
"Code": str,
Format: 3-letter department code (e.g. "CSC", "HST", etc).
"Department": str
Format: Full department name corresponding to the code (e.g. "Computer Science", "History", etc).
}]
Warnings:
This tool should only be used if you initialy fail to guess the 3-letter code for a department as it can consume a lot of tokens.
| str get_departments_in_category_tool | ( | str | category | ) |
Return department codes considered part of the specified elective/category.
Args:
category (str): The category to query:
Format: one of ["Behavioral Science Elective" | "Humanities Elective" | "Mathematics Elective" | "Science Elective" | "Lab Science Elective" | "Social Sciences Elective" | "Liberal Arts Elective" | "General Elective" | "GenEd"]
Returns:
out (str): Comma-separated list of department codes or a short explanatory string. The exact format varies by category.
| str get_event_dates_tool | ( | str | event_name | ) |
Return future dates for a specific event identified by name.
Wraps `database_utils.get_event_dates_by_name`.
Args:
event_name (str): Event name to look up:
Format: Exact event name as stored in `Events.Name` column (e.g. "Spring Career Fair").
Returns:
out (str): JSON-encoded list of event date entries:
Format: List[{
"Date": str,
Format: Date of the event in YYYY-MM-DD format (e.g. "2024-04-15")
"StartTime": str,
Format: Start time in 24-hour format (e.g. "13:00" for 1 PM)
"EndTime": str,
Format: End time in 24-hour format (e.g. "14:15" for 2:15 PM)
"Location": str
Format: Location string as stored in `EventDates.Location` column (e.g. "Building A Room 101", "Online")
}]
Note: If no event is found with the provided name, serialized value is ["Event not found"].
Note: If the event exists but has no future dates, serialized value is [].
| str get_program_requirements_tool | ( | str | program_name | ) |
Return requirement strings for a program identified by title.
Wraps `database_utils.get_program_requirements_by_title`.
Args:
program_name (str): Program title to look up:
Format: Exact title as stored in `ProgramsOfStudy.Title` column (e.g. "Computer Information Systems").
Returns:
out (str): JSON-encoded list of requirement strings:
Format of list items: Requirement string with one or more options joined by " OR ".
Format for course options: "Department: {Department}, Course Number: {Code}, Title: {Name}"
Format for elective options: "Any {Elective} course"
Note: If no program is found, serialized value is ["Program not found"].
Note: If found but no requirements exist, serialized value is ["No requirements found"].
Warnings:
Avoid high-volume program lookups in one call because payload size can become large. It should be used primarily for questions about course planning or if the user is curious about a specific program.
| str get_student_basic_info_tool | ( | ToolRuntime | runtime | ) |
Return basic profile information for the current student user.
Wraps `database_utils.get_student_basic_info` using `runtime.state["user_id"]`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
Returns:
out (str): JSON-encoded student profile info:
Format: {
"Name": str,
Format: Student's full name as stored in `Students.Name` column (e.g. "John Doe")
"Email": str,
Format: Student's email as stored in `Students.Email` column (e.g. "john.doe@university.edu")
"Advisor": str,
Format: Student's advisor name as stored in `Students.Advisor` column (e.g. "Dr. Smith")
"GPA": float,
Format: Student's current GPA as stored in `Students.GPA` column (e.g. 3.75)
"CreditsEarned": int,
Format: Total number of credits earned as stored in `Students.CreditsEarned` column (e.g. 90)
"ProgramsOfStudy": list[dict]
Format: List of dicts representing the student's programs of study.
Each dict format: {
"Title": str,
Format: Program title as stored in `ProgramsOfStudy.Title` column (e.g. "Computer Information Systems")
"Status": str
Format: Student's status in the program as stored in `StudentPrograms.Status` column (e.g. "Declared", "Undeclared", "Completed", etc)
}
Note: If no student is found with that ID, serialized value is {}.
| str get_student_course_history_tool | ( | ToolRuntime | runtime | ) |
Return course history for the current student user.
Wraps `database_utils.get_student_course_history` using `runtime.state["user_id"]`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
Returns:
out (str): JSON-encoded list of course-history entries:
Format: List[{
"CourseCode": str,
Format: Department and course number as stored in `Courses.Department` and `Courses.Code` columns (e.g. "HST 210")
"Name": str,
Format: Course name as stored in `Courses.Name` column (e.g. "World History Since 1500")
"Grade": str
Format: Grade earned in the course as stored in `StudentCourses.Grade` column (e.g. "A", "B+", "Satisfactory", etc)
}]
Note: If no courses are found, serialized value is ["No courses taken"].
| str get_student_id_by_name_tool | ( | ToolRuntime | runtime, |
| str | student_name ) |
Tool for getting a student's ID based on their name.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as the advisor's parent user ID
student_name (str): The name of the student to look up:
Format: Exact name as stored in `Students.Name` column (e.g. "Alice Smith").
Returns:
out (str): The student's ID:
Format: JSON-encoded dict {"Student ID": int} where the value is the primary key from `Students.ID` column (e.g. {"Student ID": 12345})
Note: If no student with the given name is found or if the student does not have the current user as their advisor, returns "No student found with name {student_name}."
Warnings:
Name must be an exact match. If this fails to find the student, try using the get_advisor_students tool instead.
| str get_student_interests_tool | ( | ToolRuntime | runtime | ) |
Return interests for the current student user.
Wraps `database_utils.get_student_interests` using `runtime.state["user_id"]`.
Args:
ToolRuntime runtime: Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
Returns:
out (str): JSON-encoded list of interests:
Format of list items: Interest string as stored in `Interests.Interest` (e.g. "Artificial Intelligence").
Note: If no interests are found, serialized value is ["No interests specified"].
| str get_student_tracked_sections_tool | ( | ToolRuntime | runtime | ) |
Return tracked sections for the current student user.
Wraps `database_utils.get_student_tracked_sections` using `runtime.state["user_id"]`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
Returns:
out (str): JSON-encoded list of tracked section entries:
Format: List[{
"CourseCode": str,
Format: Department and course number as stored in `Courses.Department` and `Courses.Code` columns (e.g. "HST 210")
"SectionNumber": str,
Format: Section number as stored in `Sections.SectionNumber` column (e.g. "001")
"Name": str
Format: Course name as stored in `Courses.Name` column (e.g. "World History Since 1500")
}]
Note: If no tracked sections are found, serialized value is ["No sections currently being tracked"].
| str get_upcoming_events_tool | ( | ) |
Return upcoming events that have at least one future date.
Wraps `database_utils.get_upcoming_events`.
Returns:
out (str): JSON-encoded list of upcoming events:
Format: List[{
"ID": str,
Format: Primary key value from `Events.ID` column (eg. "54321")
"Name": str,
Format: Event name as stored in `Events.Name` column (e.g. "Spring Career Fair")
"Description": str
Format: Event description as stored in `Events.Description` column (e.g. "An event where students can meet with potential employers and learn about job opportunities.")
}]
| str get_web_page_content_tool | ( | str | url, |
| int | max_chars = 3000 ) |
Fetches the content of a web page and return it as text.
Args:
url (str): The URL of the web page to get the content from:
Format: Valid URL string (e.g. "https://www.example.com").
max_chars (int): The maximum number of characters to return:
Format: Positive integer (e.g. 3000).
Returns:
out (str): A string containing the text content of the web page:
Format: Text content of the web page with all HTML tags removed.
Warnings:
Use this tool sparingly as it can consume a lot of tokens, especially for if max_chars is set to a high value. Only use this tool if you are confident that the information you need is available on the page.
| str insert_student_interests_tool | ( | ToolRuntime | runtime, |
| str | interest ) |
Insert an interest string for the current student user.
Wraps `database_utils.insert_student_interests` with a single-item list input.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
interest (str): Interest string to be inserted:
Format: Value to be stored in `Interests.Interest` column (e.g. "Data Science").
Returns:
out (str): Confirmation string from insert operation:
Format: "{counter} new interest(s) added"
Warnings:
Always check for close duplicates before inserting to avoid duplicate interest rows.
| str insert_student_tracked_sections_tool | ( | ToolRuntime | runtime, |
| str | course_code, | ||
| str | section_id ) |
Add a tracked section for the current student user.
Wraps `database_utils.insert_student_tracked_section`.
Args:
runtime (ToolRuntime): Runtime state for the current tool call:
Required key: `runtime.state["user_id"]` as a student ID.
course_code (str): Course code of the section to track:
Format: "DPT NUM" | "DPTNUM" (e.g. "CSC 101" or "CSC101").
section_id (str): Section number to track:
Format: Section number as stored in `Sections.SectionNum` (e.g. "1", "b1", "50").
Returns:
out (str): Confirmation string indicating result of the insert operation:
Possible return values:
"Section added to tracked sections"
"Section not found"
"Section already being tracked"
| str section_filter_tool | ( | schemas.SectionFilters | filters = None | ) |
Return sections that match the provided `schemas.SectionFilters`.
Wraps `database_utils.get_sectionIDs_by_filters` then resolves each ID with
`database_utils.get_section_info_by_id`.
Args:
filters (schemas.SectionFilters): Filters to apply to the section search:
Format: {
Optional[List[DBTerm]] terms,
DBTerm format: {
"year": int,
Format: 4-digit year (e.g. 2024)
"season": str,
Format: ["Fall", "Winter", "Spring", "Summer"]
"number": Optional[int]
Format: Integer term number (e.g. 1, 2, 3, etc).
Note: If not provided, filter matches any term number for the given year/season.
}
Note: Uses OR logic
Optional[List[str]] course_codes,
Format: Course codes as stored in `Courses.Code` column (e.g. ["101", "210"]).
Note: Uses OR logic
Optional[List[str]] instructors,
Format: Instructor names as stored in `Sections.Instructor` column (e.g. ["Dr. Smith", "Prof. Johnson"]).
Note: Uses OR logic
Optional[List[str]] teaching_methods,
Format: Teaching methods as stored in `Sections.Method` column (e.g. ["In-Person", "Online", "Hybrid"]).
Note: Uses OR logic
Optional[List[EnrollmentCondition]] enrollment_capacity,
EnrollmentCondition format: {
"condition": str ["=" | ">" | "<" | ">=" | "<=" | "!="],
"capacity": int (e.g. 30 or 100)
}
Note: Uses AND logic
Optional[List[EnrollmentCondition]] enrollment,
EnrollmentCondition format: {
"condition": str ["=" | ">" | "<" | ">=" | "<=" | "!="],
"enrollment": int (e.g. 25 or 100)
}
Note: Uses AND logic
Optional[List[str]] locations,
Format: Location keywords as stored in `Sections.Location` column (e.g. ["Building A", "Online"]).
Note: Filter matches any section whose location contains any of the specified keywords. Uses AND logic.
Optional[List[DBMeetTime]] meet_times
DBMeetTime format: {
"day": str,
Format: Day of the week (e.g. "Monday", "Tuesday", etc).
"start_time": str,
Format: Start time in 24-hour format (e.g. "13:00" for 1 PM).
"end_time": str,
Format: End time in 24-hour format (e.g. "14:15" for 2:15 PM).
}
Note: Uses OR logic
}
Note: Field-level formats and operator restrictions match `database_utils.get_sectionIDs_by_filters`.
Returns:
out (str): JSON-encoded list of section metadata dicts:
Format: List[{
"ID": str,
Format: Primary key value from `Sections.ID` column (eg. "67890")
"Department": str,
Format: Department abbreviation as stored in `Courses.Department` (e.g. "HST")
"Code": str,
Format: Course number as stored in `Courses.Code` (e.g. "101")
"Name": str,
Format: Course name as stored in `Courses.Name` (e.g. "Introduction to Computer Science")
"SectionNum": str,
Format: Section number as stored in `Sections.SectionNumber` column (e.g. "001")
"Instructor": str,
Format: Instructor name as stored in `Sections.Instructor` column (e.g. "Dr. Smith")
"Method": str,
Format: Teaching method as stored in `Sections.Method` column (e.g. "In-Person", "Online", "Hybrid")
"Location": str,
Format: Location string as stored in `Sections.Location` column (e.g. "Building A Room 101", "Online")
"MaxSeats": int,
Format: Maximum enrollment capacity as stored in `Sections.MaxSeats` column (e.g. 30 or 100)
"SeatsLeft": int
Format: Current available seats as stored in `Sections.SeatsLeft` column (e.g. 25 or 100)
}]
Note: If no matches are found, returns "No sections found matching the specified criteria.".
Raises:
ValueError: Propagated from underlying filter logic when an invalid operator is provided:
Enrollment capacity error message: "Invalid enrollment capacity condition: {condition}"
Current enrollment error message: "Invalid enrollment condition: {condition}"
Warnings:
Don't use this tool with overly broad filters (eg: all sections in a given term or all sections taught by a certain instructor) as it can return a lot of sections and consume a lot of tokens. Always wait until you have narrowed down the filters as much as possible before using this tool.
| str web_search_tool | ( | str | query, |
| int | max_results = 5 ) |
Performs a web search for the given query and return a list of results.
Args:
query (str): The search query.
max_results (int): The maximum number of results to return.
Returns:
out (str): A string containing a list of search results:
Format: List[{
"Title": str,
Format: Title of the search result as returned by the search engine.
"Link": str,
Format: URL of the search result as returned by the search engine.
"Snippet": str
Format: A brief snippet of text from the search result as returned by the search engine.
}]
Warnings:
Don't set the max_results parameter too high as it can consume a lot of tokens.
| list lg_agent.utilities.tools.ad_tools |
| list lg_agent.utilities.tools.alt_db_tools = [] |
| lg_agent.utilities.tools.CONFIG = json.load(f) |
| lg_agent.utilities.tools.CONFIG_PATH = os.path.join(ROOT_DIR, "config.json") |
| list lg_agent.utilities.tools.d_tools |
| list lg_agent.utilities.tools.db_tools = [] |
| dict lg_agent.utilities.tools.DEPARTMENT_LIST = {"departments": []} |
| lg_agent.utilities.tools.DEPARTMENT_LIST_PATH = os.path.join(ROOT_DIR, "department_mapping.json") |
| lg_agent.utilities.tools.ERROR_LOG_DIR = os.path.join(ROOT_DIR, "error_logs") |
| lg_agent.utilities.tools.exist_ok |
| list lg_agent.utilities.tools.i_tools |
| list lg_agent.utilities.tools.insertion_tools = [] |
| lg_agent.utilities.tools.PARENT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) |
| lg_agent.utilities.tools.ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) |
| lg_agent.utilities.tools.START_TIMESTAMP = datetime.now().strftime("%Y%m%d_%H%M%S") |
| lg_agent.utilities.tools.TOOL_CONFIG = CONFIG["tool_select"] |
| list lg_agent.utilities.tools.w_tools |
| list lg_agent.utilities.tools.web_tools = [] |