Skip to content

Commit

Permalink
Append v1 to ServerlessConnection in _tool_resolver.py (#2640)
Browse files Browse the repository at this point in the history
Append v1 to ServerlessConnection in _tool_resolver.py

---------

Co-authored-by: Ge Gao <[email protected]>
  • Loading branch information
dorisjoy and gegao-MS authored Apr 3, 2024
1 parent 2a97cb3 commit 526bd08
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/promptflow-core/promptflow/executor/_tool_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,23 @@ def _resolve_llm_connection_with_provider(connection):
# This is a fallback for the case that ServerlessConnection related tool is not ready
# in legacy versions, then we can directly use OpenAIConnection.
if isinstance(connection, ServerlessConnection):
# The ServerlessConnection should be passed into promptflow-tools as it is.
# And this append "/v1" logic should exist in promptflow-tools.
# But since old version promptflow package doesn't support below things:
# 1. There is NO ServerlessConnection;
# 2. Register_apis doesn't support Union;
# So in order to release this append "/v1" function without breaking old promptflow package.
# We move this logic here.
# This is a short-term solution. After MaaS supports OpenAI compatible rest API,
# we should remove the V1 tricky here.
suffix = "/v1"
base_url = connection.api_base
if not base_url.endswith(suffix):
# append "/v1" to ServerlessConnection api_base so that it can directly use the OpenAI SDK.
base_url += suffix
connection = OpenAIConnection(
api_key=connection.api_key,
base_url=connection.api_base,
base_url=base_url,
name=connection.name,
)
connection_type = "OpenAIConnection"
Expand Down

0 comments on commit 526bd08

Please sign in to comment.