-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ai-proxy): add support for vertex ai provider (#1590)
- Loading branch information
Showing
16 changed files
with
495 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package vertex | ||
|
||
import ( | ||
ollamaapi "github.com/ollama/ollama/api" | ||
"github.com/pluralsh/polly/algorithms" | ||
) | ||
|
||
type Endpoint string | ||
|
||
const ( | ||
EndpointChat = "/v1/projects/${PROJECT_ID}/locations/${LOCATION}/endpoints/openapi/chat/completions" | ||
EnvProjectID = "PROJECT_ID" | ||
EnvLocation = "LOCATION" | ||
) | ||
|
||
type ErrorResponse struct { | ||
Error struct { | ||
Code int `json:"code"` | ||
Message string `json:"message"` | ||
Status string `json:"status,omitempty"` | ||
} `json:"error"` | ||
} | ||
|
||
func FromErrorResponse(statusCode int) func(response []ErrorResponse) []ollamaapi.StatusError { | ||
return func(in []ErrorResponse) []ollamaapi.StatusError { | ||
return algorithms.Map(in, func(err ErrorResponse) ollamaapi.StatusError { | ||
return ollamaapi.StatusError{ | ||
StatusCode: statusCode, | ||
ErrorMessage: err.Error.Message, | ||
Status: err.Error.Status, | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.