ultisuite-backend/internal/contacts/discovery/llm_settings.go
R3D347HR4Y 556d5f416d Enhance API and configuration for contact discovery and public sharing
- Introduced new endpoints for contact discovery, including scanning, listing, and managing discovered contacts.
- Implemented retry logic for handling missing DAV credentials during contact operations.
- Added public share functionality for drive API, allowing users to manage public shares, including upload, delete, and rename operations.
- Updated Nextcloud configuration to support public share links and improved error handling for public share permissions.
- Enhanced logging and validation across contact and drive APIs for better error tracking and user feedback.
- Added tests for new contact matching and ranking functionalities to ensure accuracy and reliability.
2026-06-06 20:27:02 +02:00

48 lines
1.2 KiB
Go

package discovery
import (
"context"
"encoding/json"
"fmt"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/ultisuite/ulti-backend/internal/llm"
)
func (s *Service) GetLLMSettings(ctx context.Context, externalUserID string) (llm.Settings, error) {
return s.loadLLMSettings(ctx, externalUserID)
}
func (s *Service) UpdateLLMSettings(ctx context.Context, externalUserID string, settings llm.Settings) (llm.Settings, error) {
if s.db == nil {
return llm.Settings{}, fmt.Errorf("database unavailable")
}
raw, err := json.Marshal(settings)
if err != nil {
return llm.Settings{}, err
}
_, err = s.db.Exec(ctx, `
INSERT INTO settings (user_id, preferences)
VALUES (
(SELECT id FROM users WHERE external_id = $1),
jsonb_build_object('llm', $2::jsonb)
)
ON CONFLICT (user_id) DO UPDATE SET
preferences = jsonb_set(
COALESCE(settings.preferences, '{}'::jsonb),
'{llm}',
$2::jsonb
),
updated_at = NOW()
`, externalUserID, string(raw))
if err != nil {
return llm.Settings{}, err
}
return s.loadLLMSettings(ctx, externalUserID)
}
func LoadLLMSettingsFromPool(ctx context.Context, db *pgxpool.Pool, externalUserID string) (llm.Settings, error) {
s := NewService(db)
return s.loadLLMSettings(ctx, externalUserID)
}