fix: import block syntax in split dashboard files
- Add missing closing ) in clients.go, providers_admin.go, users.go, system.go - Add SetTimeout(30s) to OpenAI provider (was resty.New() with no timeout)
This commit is contained in:
@@ -2,5 +2,5 @@
|
|||||||
"files": {},
|
"files": {},
|
||||||
"turnCycles": 0,
|
"turnCycles": 0,
|
||||||
"maxCycles": 3,
|
"maxCycles": 3,
|
||||||
"lastUpdated": "2026-04-26T18:49:43.830Z"
|
"lastUpdated": "2026-04-26T18:55:13.038Z"
|
||||||
}
|
}
|
||||||
@@ -2,26 +2,26 @@ package providers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
"gophergate/internal/config"
|
"gophergate/internal/config"
|
||||||
"gophergate/internal/models"
|
"gophergate/internal/models"
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OpenAIProvider struct {
|
type OpenAIProvider struct {
|
||||||
client *resty.Client
|
client *resty.Client
|
||||||
config config.OpenAIConfig
|
config config.OpenAIConfig
|
||||||
apiKey string
|
apiKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOpenAIProvider(cfg config.OpenAIConfig, apiKey string) *OpenAIProvider {
|
func NewOpenAIProvider(cfg config.OpenAIConfig, apiKey string) *OpenAIProvider {
|
||||||
return &OpenAIProvider{
|
return &OpenAIProvider{
|
||||||
client: resty.New(),
|
client: resty.New().SetTimeout(30 * time.Second),
|
||||||
config: cfg,
|
config: cfg,
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func (p *OpenAIProvider) ChatCompletionStream(ctx context.Context, req *models.U
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch := make(chan *models.ChatCompletionStreamResponse)
|
ch := make(chan *models.ChatCompletionStreamResponse)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
err := StreamOpenAI(resp.RawBody(), ch)
|
err := StreamOpenAI(resp.RawBody(), ch)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Server) handleGetClients(c *gin.Context) {
|
func (s *Server) handleGetClients(c *gin.Context) {
|
||||||
var clients []db.Client
|
var clients []db.Client
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Server) handleGetProviders(c *gin.Context) {
|
func (s *Server) handleGetProviders(c *gin.Context) {
|
||||||
var dbConfigs []db.ProviderConfig
|
var dbConfigs []db.ProviderConfig
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Server) handleSystemHealth(c *gin.Context) {
|
func (s *Server) handleSystemHealth(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, SuccessResponse(gin.H{
|
c.JSON(http.StatusOK, SuccessResponse(gin.H{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Server) handleGetUsers(c *gin.Context) {
|
func (s *Server) handleGetUsers(c *gin.Context) {
|
||||||
var users []db.User
|
var users []db.User
|
||||||
|
|||||||
Reference in New Issue
Block a user