Skip to content

Commit

Permalink
api tool support multiple env url (langgenius#12249)
Browse files Browse the repository at this point in the history
Co-authored-by: mabo <[email protected]>
  • Loading branch information
mboo2005 and mabo authored Jan 13, 2025
1 parent 69d58fb commit 1859d57
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit 1859d57

Please sign in to comment.