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

api tool support multiple env url #12249

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions api/core/tools/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from json.decoder import JSONDecodeError
from typing import Optional

from flask import request
from requests import get
from yaml import YAMLError, safe_load # type: ignore

Expand All @@ -29,6 +30,10 @@ def parse_openapi_to_tool_bundle(
raise ToolProviderNotFoundError("No server found in the openapi yaml.")

server_url = openapi["servers"][0]["url"]
request_env = request.headers.get("X-Request-Env")
if request_env:
matched_servers = [server["url"] for server in openapi["servers"] if server["env"] == request_env]
server_url = matched_servers[0] if matched_servers else server_url

# list all interfaces
interfaces = []
Expand Down
Loading