Refactor client handling and improve error responses
docker-image / docker (push) Has been cancelled
goreleaser / goreleaser (push) Has been cancelled

- Centralized client retrieval logic with `getClient` function for reduced redundancy.
- Simplified client rotation and error handling by removing excessive load balancing logic.
- Updated server address in `auth.go` to use dynamic binding (`:8085`).
This commit is contained in:
Luis Pater
2025-07-15 17:03:18 +08:00
parent 368796349e
commit f49a530c1a
3 changed files with 10 additions and 52 deletions
+4
View File
@@ -86,6 +86,10 @@ func (h *APIHandlers) Models(c *gin.Context) {
}
func (h *APIHandlers) getClient(modelName string) (*client.Client, *client.ErrorMessage) {
if len(h.cliClients) == 0 {
return nil, &client.ErrorMessage{StatusCode: 500, Error: fmt.Errorf("no clients available")}
}
var cliClient *client.Client
// Lock the mutex to update the last used client index