Skip to content

feat: add Context Chat OCP API #53859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

edward-ly
Copy link
Contributor

@edward-ly edward-ly commented Jul 8, 2025

Checklist

@edward-ly edward-ly added this to the Nextcloud 32 milestone Jul 8, 2025
@edward-ly edward-ly added enhancement 3. to review Waiting for reviews php Pull requests that update Php code pending documentation This pull request needs an associated documentation update labels Jul 8, 2025
@edward-ly edward-ly requested a review from marcelklehr July 8, 2025 00:04
@edward-ly edward-ly force-pushed the feat/context-chat-ocp branch from 4dc4697 to 1290be2 Compare July 8, 2025 00:27
@marcelklehr
Copy link
Member

Looks good! You can suppress psalm errors for the OCA\ContextChat classes by adding them to the psalm.xml suppress handler.

@edward-ly edward-ly marked this pull request as ready for review July 8, 2025 15:11
@edward-ly edward-ly requested a review from a team as a code owner July 8, 2025 15:11
@edward-ly edward-ly requested review from icewind1991, yemkareems and sorbaugh and removed request for a team July 8, 2025 15:11
@edward-ly edward-ly force-pushed the feat/context-chat-ocp branch 2 times, most recently from 0291146 to ccbf226 Compare July 9, 2025 20:52
Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

It would be nice to have a isContextChatAvailable method in the content manager so providers could even avoid calling submitContent if it's not available.

There could be a new section in the docs (after "Submitting ContentItem data") about this new method.

@marcelklehr
Copy link
Member

Ah, yes. Good point. OCA\ContextChat\Public\ContentManager would also have to implement this, then, which is a bit useless, but we can just return true there.

Signed-off-by: Edward Ly <contact@edward.ly>
Signed-off-by: Edward Ly <contact@edward.ly>
…ContentManager

Signed-off-by: Edward Ly <contact@edward.ly>
Signed-off-by: Edward Ly <contact@edward.ly>
@marcelklehr marcelklehr force-pushed the feat/context-chat-ocp branch from 87d4253 to 70204ea Compare July 14, 2025 07:50
/**
* @since 32.0.0
*/
class ContentItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this class really be in OCP?
Would it not be better to have it an interface instead as we do everywhere else?

Copy link
Contributor

Choose a reason for hiding this comment

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

(and implementation in OC)

Copy link
Member

Choose a reason for hiding this comment

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

It's a data object that is supposed to be used be consumers of the API to submit data to context chat.

Copy link
Member

Choose a reason for hiding this comment

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

See docs on how this is intended to be used.

Copy link
Member

Choose a reason for hiding this comment

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

Can be helpful if the items are generated by the apps

@marcelklehr marcelklehr removed the pending documentation This pull request needs an associated documentation update label Jul 14, 2025
Comment on lines +12 to +16
*/
class UpdateAccessOp {
public const ALLOW = 'allow';
public const DENY = 'deny';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Op? Should probably have a better understandable name?
Also why not use an enum instead?

Copy link
Member

Choose a reason for hiding this comment

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

This PR is based on an existing API in OCA\ContextChat\Public with the rationale being to change as little as possible for apps that already implement the old API.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Some comments

* @return void
* @since 32.0.0
*/
public function registerContentProvider(string $appId, string $providerId, string $providerClass): void;
Copy link
Member

Choose a reason for hiding this comment

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

Could this be moved into the app bootstrap mechanism to be a bit more lightweight? The current implementation needs the content manager to be build to perform a registration. The bootstrap context is always built when we bootstrap apps, but only if the context chat content manager is really needed in a request it will be built

/**
* @since 32.0.0
*/
class ContentItem {
Copy link
Member

Choose a reason for hiding this comment

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

Can be helpful if the items are generated by the apps

* @since 32.0.0
*/
public function __construct(
public string $itemId,
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: missing since tags for the properties

@@ -0,0 +1,113 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

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

new classes do are not strict. it should not cause an issues to make the strict from the beginning, so I suggest to add the declare line for the newly added interfaces and classes

@@ -0,0 +1,54 @@
<?php

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
declare(strict_types=1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement an OCP API for Context Chat
7 participants