INNER CODE UNIT · Python

get_lm_studio_models

mrwadams/stride-gpt · apps/web/main.py:392

def get_lm_studio_models(endpoint, api_key="not-needed"):
    try:
        client = OpenAI(base_url=f"{endpoint}/v1", api_key=api_key)
        models = client.models.list()
        return [model.id for model in models.data]
    except requests.exceptions.ConnectionError:
        st.error(
            """Unable to connect to LM Studio Server. Please ensure:
1. LM Studio is running and the local server is started
2. The endpoint URL is correct (default: http://localhost:1234)
3. No firewall is blocking the connection"""
        )
        return ["local-model"]
    except Exception as e:
        st.error(
            f"""Error fetching models from LM Studio Server: {e}

Please check:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…