Skip to content

Commit

Permalink
add new provider Solar (#6884)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuHyung-Son authored Aug 2, 2024
1 parent 541bf1d commit 2e941bb
Show file tree
Hide file tree
Showing 22 changed files with 1,328 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/core/model_runtime/model_providers/_position.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- nvidia
- nvidia_nim
- cohere
- upstage
- bedrock
- togetherai
- openrouter
Expand Down
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions api/core/model_runtime/model_providers/upstage/_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

from collections.abc import Mapping

import openai
from httpx import Timeout

from core.model_runtime.errors.invoke import (
InvokeAuthorizationError,
InvokeBadRequestError,
InvokeConnectionError,
InvokeError,
InvokeRateLimitError,
InvokeServerUnavailableError,
)


class _CommonUpstage:
def _to_credential_kwargs(self, credentials: Mapping) -> dict:
"""
Transform credentials to kwargs for model instance
:param credentials:
:return:
"""
credentials_kwargs = {
"api_key": credentials['upstage_api_key'],
"base_url": "https://api.upstage.ai/v1/solar",
"timeout": Timeout(315.0, read=300.0, write=20.0, connect=10.0),
"max_retries": 1
}

return credentials_kwargs

@property
def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:
"""
Map model invoke error to unified error
The key is the error type thrown to the caller
The value is the error type thrown by the model,
which needs to be converted into a unified error type for the caller.
:return: Invoke error mapping
"""
return {
InvokeConnectionError: [openai.APIConnectionError, openai.APITimeoutError],
InvokeServerUnavailableError: [openai.InternalServerError],
InvokeRateLimitError: [openai.RateLimitError],
InvokeAuthorizationError: [openai.AuthenticationError, openai.PermissionDeniedError],
InvokeBadRequestError: [
openai.BadRequestError,
openai.NotFoundError,
openai.UnprocessableEntityError,
openai.APIError,
],
}


Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- soloar-1-mini-chat
Loading

0 comments on commit 2e941bb

Please sign in to comment.