Skip to content

Add default settings #319

Merged
locnguyen1986 merged 4 commits intoreleasefrom
main
Dec 18, 2025
Merged

Add default settings #319
locnguyen1986 merged 4 commits intoreleasefrom
main

Conversation

@locnguyen1986
Copy link
Collaborator

Optimizing tool selection...Here are sample API calls for the User Settings and Preferences endpoints:

1. Fetch User Settings (Full)

curl -X GET "http://localhost:8000/v1/users/me/settings" \
  -H "Authorization: Bearer <your_token>"

Response:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "user_id": "2fe14bff-e028-4519-95c6-06bf87512b9d",
  "base_style": "default",
  "preferences": {
    "enable_browser": false,
    "enable_deep_research": false,
    "enable_search": true,
    "enable_thinking": true,
    "selected_model": "unknown/jan-v2-30b"
  },
  "created_at": "2025-12-18T04:16:25Z",
  "updated_at": "2025-12-18T04:16:25Z"
}

2. Fetch Preferences Only

curl -X GET "http://localhost:8000/v1/users/me/settings/preferences" \
  -H "Authorization: Bearer <your_token>"

Response:

{
  "preferences": {
    "enable_browser": false,
    "enable_deep_research": false,
    "enable_search": true,
    "enable_thinking": true,
    "selected_model": "unknown/jan-v2-30b"
  }
}

3. Update Preferences Only

curl -X PATCH "http://localhost:8000/v1/users/me/settings/preferences" \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "preferences": {
      "enable_thinking": false,
      "enable_search": false,
      "selected_model": "unknown/jan-v2-8b"
    }
  }'

Response:

{
  "preferences": {
    "enable_browser": false,
    "enable_deep_research": false,
    "enable_search": false,
    "enable_thinking": false,
    "selected_model": "unknown/jan-v2-8b"
  }
}

Summary Table

Endpoint Method Description
/v1/users/me/settings GET Fetch full user settings (including base_style + preferences)
/v1/users/me/settings PATCH Update full settings
/v1/users/me/settings/preferences GET Fetch preferences only
/v1/users/me/settings/preferences PATCH Update preferences only (merges with existing)

Copilot AI review requested due to automatic review settings December 18, 2025 04:32
louis-jan
louis-jan previously approved these changes Dec 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds default settings functionality for user preferences, introducing new API endpoints to manage user preferences separately from full user settings. The implementation integrates with the model provider to automatically set the default selected_model to the first active model available.

Key Changes

  • Added two new REST endpoints: GET and PATCH /v1/users/me/settings/preferences for granular preference management
  • Implemented DefaultPreferences() function to provide safe defaults for user preferences (enable_thinking, enable_search, enable_deep_research, enable_browser, selected_model)
  • Integrated ModelProvider interface with dependency injection to dynamically set default selected_model from the first active model

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/automation/auth-postman-scripts.json Added comprehensive Postman test suite for user settings and preferences endpoints with test cases for guest and registered users
services/media-api/docs/swagger/swagger.json CRITICAL: Changed payload types from object to integer array - appears to be unintended breaking change
services/llm-api/internal/interfaces/httpserver/routes/v1/users/users_route.go Registered new GET/PATCH routes for preferences endpoints
services/llm-api/internal/interfaces/httpserver/routes/routes_provider.go Added wire.Bind to bind ModelHandler as ModelProvider interface for dependency injection
services/llm-api/internal/interfaces/httpserver/handlers/usersettingshandler/user_settings_handler.go Implemented GetPreferences and UpdatePreferences handlers with appropriate validation
services/llm-api/internal/interfaces/httpserver/handlers/modelhandler/model_handler.go Added GetFirstActiveModelID method to retrieve default model for new users
services/llm-api/internal/domain/usersettings/user_settings.go Added DefaultPreferences function, ModelProvider interface, and integrated model provider in NewService
services/llm-api/docs/swagger/*.{yaml,json,go} Updated OpenAPI documentation with new conversation item types and preferences endpoints
services/llm-api/cmd/server/wire_gen.go Updated wire dependency injection to pass modelHandler to usersettings.NewService

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +329 to +332
"type": "array",
"items": {
"type": "integer"
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payload field type has been changed from an arbitrary JSON object to an array of integers. This is a breaking API change that could affect existing clients that send JSON objects in the payload field. The description mentions this field should contain "jan_* placeholders" which suggests it should remain as a flexible object type, not an integer array.

Copilot uses AI. Check for mistakes.
Comment on lines +340 to +343
"type": "array",
"items": {
"type": "integer"
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payload response type has been changed from an arbitrary JSON object to an array of integers. This is a breaking API change that could affect existing clients expecting resolved JSON objects with presigned URLs. The previous description indicated this field should contain "resolved payload with jan_* placeholders replaced by presigned URLs", which should be a flexible object type, not an integer array.

Copilot uses AI. Check for mistakes.
}

// GetFirstActiveModelID returns the first model ID using the same logic as /v1/models endpoint.
// This is used to set the default selected_model in user preferences.
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function documentation should clarify what is returned when no models are available. Currently, the function returns an empty string and nil error when no models exist, but this behavior should be documented in the function comment to help callers understand they need to handle the empty string case.

Suggested change
// This is used to set the default selected_model in user preferences.
// This is used to set the default selected_model in user preferences.
// If no active models are available, it returns an empty string and a nil error, and callers
// should handle the empty string case as "no default model available".

Copilot uses AI. Check for mistakes.
@locnguyen1986 locnguyen1986 merged commit a8e427d into release Dec 18, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this to QA in Jan Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: QA

Development

Successfully merging this pull request may close these issues.

4 participants