scaleapi / llm-engine

Scale LLM Engine public repository

Home Page:https://llm-engine.scale.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: API calls don't work on Windows due to os.path.join

f-linus opened this issue · comments

Hey everyone. This stems from an older, closed issue: #170.

The post_sync method in api_engine.py concatenates parts of the URL to make the API call against using the os.path.join Python method.

See:

    @classmethod
    def post_sync(cls, resource_name: str, data: Dict[str, Any], timeout: int) -> Dict[str, Any]:
        api_key = get_api_key()
        response = requests.post(
            os.path.join(LLM_ENGINE_BASE_PATH, resource_name),
            json=data,
            timeout=timeout,
            headers={"x-api-key": api_key},
            auth=(api_key, ""),
        )
        if response.status_code != 200:
            raise parse_error(response.status_code, response.content)
        payload = response.json()
        return payload

However, that method is designed to join paths on file systems depending on the OS Python is being executed on. When on Windows, this results in the path being joined into a URL where one slash is actually a backslash since that is the "divider" used on the Windows file system.

Long story short: bug that breaks all API calls when using package on Windows since os.path.join is used which puts a backslash instead of a slash into the endpoint URL

#225 should fix the issue - I've tested on a Windows machine and it worked for me!