Skip to content

Basic AI config functions#4140

Open
nelsonkopliku wants to merge 8 commits intomainfrom
basic-ai-config-functions
Open

Basic AI config functions#4140
nelsonkopliku wants to merge 8 commits intomainfrom
basic-ai-config-functions

Conversation

@nelsonkopliku
Copy link
Copy Markdown
Member

@nelsonkopliku nelsonkopliku commented Apr 1, 2026

Description

This PR introduces the scaffolding to support users' AI onboarding/configuration.

Create/Update functions added.

What's next:

  • retrieving a user's AI configuration
  • expose the functionalities via API endpoints (GET,POST,PATCH)
  • UI

Trying to keep the PRs as contained as possible.
Half of the changes in this PR are tests 🙈

@nelsonkopliku nelsonkopliku self-assigned this Apr 1, 2026
@nelsonkopliku nelsonkopliku added the enhancement New feature or request label Apr 1, 2026
@nelsonkopliku nelsonkopliku force-pushed the basic-ai-config-functions branch from e1467b0 to e158e52 Compare April 2, 2026 07:54
@@ -0,0 +1,49 @@
defmodule Trento.AI do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The flow overall is:

If AI is enabled system wide, it can be enabled on a per user basis; what is not clear to me is how to disable it once enabled at the user level. I wonder if we also need an AI configuration enabled_at (either a ts or nil) or similar field?

Copy link
Copy Markdown
Member Author

@nelsonkopliku nelsonkopliku Apr 2, 2026

Choose a reason for hiding this comment

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

As discussed privately: yes there is a missing piece in the picture, that is "once I have enrolled for AI, how can I opt out?". Meaning that we might need to consider a user action to either:

  • clear out its whole AI configuration
  • enable/disable it

Will raise it with @abravosuse and @jagabomb

@nelsonkopliku nelsonkopliku changed the title Basic ai config functions Basic AI config functions Apr 2, 2026
@balanza balanza added env Create an ephimeral environment for the pr branch and removed enhancement New feature or request labels Apr 2, 2026
@balanza
Copy link
Copy Markdown
Member

balanza commented Apr 2, 2026

Half of the changes in this PR are tests

perfectly balanced, as always should be

@nelsonkopliku nelsonkopliku added the enhancement New feature or request label Apr 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

The preview environment for this pull request is ready at 4140.prenv.trento.suse.com.

add :user_id, references(:users, on_delete: :delete_all), primary_key: true
add :provider, :string
add :model, :string
add :api_key, :binary
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

issue: ‏As far as I understand, we are storing unencrypted user's api keys in the application database, are we? If so, I think we should rethink this approach.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should be covered here by

field :api_key, EncryptedBinary, redact: true

Let me know if you find something I missed.

Copy link
Copy Markdown
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey!
I just did a superficial review.
The core logic looks good.
I'm just wondering of the extra complexity of the enabled logic, which protects parts of code that shouldn't be accessible for regular users

lib/trento/ai.ex Outdated

See `Trento.AI.Configurations.create_user_configuration/2` for more details.
"""
def create_user_configuration(user, attrs) do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

question:
is this not a bit of an overkill?
no user can access this functions as long as the api routes are disabled.
it would only be available from the console, which i don't find it dangerous.
I don't know, it adds a layer of complexity that might not be needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, removed 6095286

@nelsonkopliku nelsonkopliku force-pushed the basic-ai-config-functions branch from e8f9f91 to 6095286 Compare April 8, 2026 08:12
Copy link
Copy Markdown
Contributor

@gagandeepb gagandeepb left a comment

Choose a reason for hiding this comment

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

Thanks for this. I would be fine if we can revisit the enable/disable of the AI config in this or in a follow up PR.

@nelsonkopliku nelsonkopliku force-pushed the basic-ai-config-functions branch from 6095286 to ecb3839 Compare April 8, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request env Create an ephimeral environment for the pr branch

Development

Successfully merging this pull request may close these issues.

4 participants