Module: css_mux
Library containing functions for accessing closed source models.
Currently, 3 APIs are supported: OPENAI, PERPLEXITYAI, and GOOSEAI.
CSSCompletionParams
CSSEmbeddingParams
CSSRequest
Bases: BaseModel
A CSSRequest, meant for querying closed source models.
Attributes:
Name | Type | Description |
---|---|---|
provider |
CSSProvider
|
Provider Closed source model provider |
endpoint |
str
|
str Endpoint to query |
model |
str
|
str Id of model to use: e.g. "gpt-3.5-turbo" |
api_keys |
ApiKeys
|
ApiKeys API keys to use, it's a mapping of provider to api key |
params |
Union[CSSCompletionParams, CSSEmbeddingParams]
|
Union[CSSCompletionParams, CSSEmbeddingParams] Parameters associated with the request |
stream |
bool
|
bool Flag to indicate if the API should stream the response |
extra_args |
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]] Extra arguments to pass to the API. They
are appended to the body of the request: i.e. |
Source code in src/infernet_ml/utils/css_mux.py
ConvoMessage
Bases: BaseModel
A convo message is a part of a conversation.
Source code in src/infernet_ml/utils/css_mux.py
css_mux(req)
By this point, we've already validated the request, so we can proceed with the actual API call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
CSSRequest |
required |
Returns:
Name | Type | Description |
---|---|---|
response |
str
|
processed output from api |
Source code in src/infernet_ml/utils/css_mux.py
css_streaming_mux(req)
Make a streaming request to the respective closed-source model provider.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
CSSRequest |
required |
Returns:
Type | Description |
---|---|
Iterator[str]
|
Iterator[str]: a generator that yields the response in chunks |
Source code in src/infernet_ml/utils/css_mux.py
get_request_configuration(req)
Get the configuration for a given request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
a CSSRequest object, containing provider, endpoint, model, |
required |
Returns:
Name | Type | Description |
---|---|---|
configuration |
Tuple[str, Dict[str, str], Dict[str, Any]]
|
dict[str, Any] |
Source code in src/infernet_ml/utils/css_mux.py
goose_ai_request_generator(req)
Returns base url & json input for Goose AI API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
a CSSRequest object, containing provider, endpoint, model, |
required |
Returns:
Name | Type | Description |
---|---|---|
base_url |
str
|
str |
dict[str, Any]
|
processed input: dict[str, Any] |
Raises:
Type | Description |
---|---|
InfernetMLException
|
if an unsupported model or params specified. |
Source code in src/infernet_ml/utils/css_mux.py
open_ai_request_generator(req)
Returns base url & json input for OpenAI API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
a CSSRequest object, containing provider, endpoint, model, |
required |
Returns:
Name | Type | Description |
---|---|---|
base_url |
str
|
str |
dict[str, Any]
|
processed input: dict[str, Any] |
Raises:
Type | Description |
---|---|
InfernetMLException
|
if an unsupported model or params specified. |
Source code in src/infernet_ml/utils/css_mux.py
perplexity_ai_request_generator(req)
Returns base url & json input for Perplexity AI API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
a CSSRequest object, containing provider, endpoint, model, |
required |
Returns:
Name | Type | Description |
---|---|---|
base_url |
str
|
str |
dict[str, Any]
|
processed input: dict[str, Any] |
Raises:
Type | Description |
---|---|
InfernetMLException
|
if an unsupported model or params specified. |
Source code in src/infernet_ml/utils/css_mux.py
validate(req)
helper function to validate provider and endpoint
Parameters:
Name | Type | Description | Default |
---|---|---|---|
req |
CSSRequest
|
a CSSRequest object, containing provider, endpoint, model, |
required |
Raises:
Type | Description |
---|---|
InfernetMLException
|
if API Key not specified or an unsupported provider or endpoint specified. |