mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
refactor(core): migrate channel identity and binding across app
Align channel identity and bind flow across backend and app-facing layers, including generated swagger artifacts and package lock updates while excluding docs content changes.
This commit is contained in:
@@ -33,7 +33,7 @@ type DashScopeUsage struct {
|
||||
}
|
||||
|
||||
type dashScopeRequest struct {
|
||||
Model string `json:"model"`
|
||||
Model string `json:"model"`
|
||||
Input dashScopeRequestInput `json:"input"`
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ const (
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Type string
|
||||
Provider string
|
||||
Model string
|
||||
Dimensions int
|
||||
Input Input
|
||||
UserID string
|
||||
Type string
|
||||
Provider string
|
||||
Model string
|
||||
Dimensions int
|
||||
Input Input
|
||||
ChannelIdentityID string
|
||||
}
|
||||
|
||||
type Input struct {
|
||||
@@ -180,8 +180,8 @@ func (r *Resolver) selectEmbeddingModel(ctx context.Context, req Request) (model
|
||||
}
|
||||
|
||||
// If no model specified and no provider specified, try to get per-user embedding model.
|
||||
if req.Model == "" && req.Provider == "" && strings.TrimSpace(req.UserID) != "" {
|
||||
modelID, err := r.loadUserEmbeddingModelID(ctx, req.UserID)
|
||||
if req.Model == "" && req.Provider == "" && strings.TrimSpace(req.ChannelIdentityID) != "" {
|
||||
modelID, err := r.loadChannelIdentityEmbeddingModelID(ctx, req.ChannelIdentityID)
|
||||
if err != nil {
|
||||
return models.GetResponse{}, err
|
||||
}
|
||||
@@ -257,15 +257,15 @@ func (r *Resolver) fetchProvider(ctx context.Context, providerID string) (sqlc.L
|
||||
return r.queries.GetLlmProviderByID(ctx, pgID)
|
||||
}
|
||||
|
||||
func (r *Resolver) loadUserEmbeddingModelID(ctx context.Context, userID string) (string, error) {
|
||||
func (r *Resolver) loadChannelIdentityEmbeddingModelID(ctx context.Context, channelIdentityID string) (string, error) {
|
||||
if r.queries == nil {
|
||||
return "", nil
|
||||
}
|
||||
pgUserID, err := parseUUID(userID)
|
||||
pgChannelIdentityID, err := parseUUID(channelIdentityID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
row, err := r.queries.GetSettingsByUserID(ctx, pgUserID)
|
||||
row, err := r.queries.GetSettingsByUserID(ctx, pgChannelIdentityID)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return "", nil
|
||||
|
||||
Reference in New Issue
Block a user