| |
| INT GetDefaultUrl( |
| |
DWORD dwProviderId, |
|
| |
LPCTSTR lpszBaseUrl, |
|
| |
INT nMaxLength |
|
| ); |
| INT GetDefaultUrl( |
| |
DWORD dwProviderId, |
|
| |
CString &strBaseUrl |
|
| ); |
The GetDefaultUrl method returns the default endpoint
URL for the specified provider.
Parameters
- dwProviderId
- Specifies the service provider. This parameter must be one of the
LLM_PROVIDER constants. Refer to the
providers page for a list of supported
providers and their default models.
- lpszBaseUrl
- A pointer to a buffer that receives the default base endpoint URL
used when making requests to the provider. If this parameter is NULL,
the method will return the length of the URL without copying to
the string buffer. An alternate version of this method accepts a
reference to a CString object which will contain the endpoint
URL when the method returns.
- nMaxLength
- The size of the buffer specified by the lpszBaseUrl parameter, in
characters. If lpszBaseUrl is NULL, this value should be zero.
If a buffer is provided, it must be large enough to store the complete URL,
including the terminating null character.
Return Value
If the method succeeds, the return value is the number of
characters copied into the string buffer, not including the terminating
null character. If the method fails, the return value is zero.
To get extended error information, call GetLastError.
Remarks
The GetDefaultUrl method returns the default base
endpoint URL used when a client makes a request to the provider. If
the provider ID is unknown or does not have a default endpoint, this
method will return zero. If the provider does not have a default
endpoint, the last error code will be set to ST_ERROR_NO_PROVIDER_BASE_URL.
In this case, a client must always provide a URL endpoint.
To return the base endpoint URL being used with the current client session,
use the GetProviderUrl method. The GetDefaultUrl method
does not require an active client session and will only return the default
endpoint for a specific provider. It will not return a custom endpoint
specified for a provider.
The base URL is returned as a null-terminated string. If the buffer is not
large enough to receive the entire string, the method fails and sets the
error code to ST_ERROR_BUFFER_TOO_SMALL. We recommend a buffer size of at
least 256 characters when retrieving the base URL.
Example
DWORD dwProviderId = LLM_PROVIDER_OPENAI;
TCHAR szDefaultUrl[256] = {0};
INT cchDefaultUrl = llmClient.GetDefaultUrl(dwProviderId, szDefaultUrl, _countof(szDefaultUrl));
if (cchDefaultUrl > 0)
{
_tprintf(_T("The default endpoint for provider %lu is %s\n"), dwProviderId, szDefaultUrl);
}
else
{
DWORD dwError = LlmGetLastError();
_tprintf(_T("Unable to get the provider endpoint, error 0x%08lx\n"), dwError);
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csllmv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|