Skip to content

Commit

Permalink
fix: patch vllm/local endpoint model GET bug (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacker authored Mar 21, 2024
1 parent 84d9dbf commit 64ac714
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion memgpt/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def get_model_options(
else:
# Attempt to do OpenAI endpoint style model fetching
# TODO support local auth
fetched_model_options_response = openai_get_model_list(url=model_endpoint, api_key=None)
fetched_model_options_response = openai_get_model_list(url=model_endpoint, api_key=None, fix_url=True)
model_options = [obj["id"] for obj in fetched_model_options_response["data"]]
# NOTE no filtering of local model options

Expand Down
11 changes: 9 additions & 2 deletions memgpt/llm_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
import requests
import time
from typing import Union
from typing import Union, Optional
import urllib

from memgpt.credentials import MemGPTCredentials
Expand Down Expand Up @@ -81,10 +81,17 @@ def clean_azure_endpoint(raw_endpoint_name):
return endpoint_address


def openai_get_model_list(url: str, api_key: Union[str, None]) -> dict:
def openai_get_model_list(url: str, api_key: Union[str, None], fix_url: Optional[bool] = False) -> dict:
"""https://platform.openai.com/docs/api-reference/models/list"""
from memgpt.utils import printd

# In some cases we may want to double-check the URL and do basic correction, eg:
# In MemGPT config the address for vLLM is w/o a /v1 suffix for simplicity
# However if we're treating the server as an OpenAI proxy we want the /v1 suffix on our model hit
if fix_url:
if not url.endswith("/v1"):
url = smart_urljoin(url, "v1")

url = smart_urljoin(url, "models")

headers = {"Content-Type": "application/json"}
Expand Down

0 comments on commit 64ac714

Please # to comment.