Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dynamic JSON modification at the beginning of openaiBot.py #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/app/control/bot/openaiBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from app.model.agentModel import AgentModel
from .baseBot import BaseBot
from app.tool import *
from app.tool.gtfs import GTFS_data

file_path="storage/tool/tool_register.json"

Expand All @@ -15,6 +16,12 @@
# Load the JSON data from the file
with open(file_path, 'r') as file:
tools = json.load(file)

# Dynamically update tools before tool calls are invoked
for tool in tools:
if tool['function']['name'] == 'get_all_stop_times':
tool['function']['parameters']['properties']['stop_name']['enum'] = GTFS_data().stops['stop_name']
break

class OpenAIBot(BaseBot):
def __init__(self, api_key):
Expand Down
6 changes: 1 addition & 5 deletions backend/storage/tool/tool_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@
"properties": {
"stop_name": {
"type": "string",
"enum": [
"centrepoint Metro Station 1",
"Emirates Metro Station 1",
"Airport Terminal 3 Metro Station 1"
],
"enum": [],
"description": "The name of the public transport station"
}
},
Expand Down