Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 39 additions & 57 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ jobs:
matrix:
php-versions: [ '8.1' ]
databases: [ 'pgsql' ]
server-versions: [ 'stable30', 'stable31', 'master' ]
server-versions: [ 'stable32', 'master' ]
encryption: ['on', 'off']
exclude:
- server-versions: stable30
databases: pgsql
php-versions: 8.1
encryption: on
- server-versions: stable31
- server-versions: stable32
databases: pgsql
php-versions: 8.1
encryption: on
Expand Down Expand Up @@ -184,13 +180,13 @@ jobs:
run: |
cd data/admin/files
LIMIT=100

# Find all files in the directory and its subdirectories
FILES=($(find papers/ -type f))

# Count the number of files
FILE_COUNT=${#FILES[@]}

# Check if the current number of files exceeds the limit
if [ "$FILE_COUNT" -le "$LIMIT" ]; then
echo "No files need to be deleted. Current count: $FILE_COUNT"
Expand All @@ -199,7 +195,7 @@ jobs:

# Calculate how many files to delete
FILES_TO_DELETE=$((FILE_COUNT - LIMIT))

# Sort files by modification time (oldest first) and delete the oldest ones
for FILE in $(ls -t "${FILES[@]}" | tail -n "$FILES_TO_DELETE"); do
echo "Deleting: $FILE"
Expand Down Expand Up @@ -280,7 +276,7 @@ jobs:
echo "$OUT1" | grep -q "If all of these points are met, we give a Green label." || exit 1
echo "$OUT2" | grep -q "If all of these points are met, we give a Green label." || exit 1
echo "$OUT3" | grep -q "overview.rst" || exit 1

kill -9 $WORKER1_PID
kill -9 $WORKER2_PID

Expand Down Expand Up @@ -342,14 +338,10 @@ jobs:
matrix:
php-versions: [ '8.1' ]
databases: [ 'pgsql' ]
server-versions: [ 'stable30', 'stable31', 'master' ]
server-versions: [ 'stable32', 'master' ]
encryption: ['on', 'off']
exclude:
- server-versions: stable30
databases: pgsql
php-versions: 8.1
encryption: on
- server-versions: stable31
- server-versions: stable32
databases: pgsql
php-versions: 8.1
encryption: on
Expand Down Expand Up @@ -523,13 +515,13 @@ jobs:
run: |
cd data/admin/files
LIMIT=100

# Find all files in the directory and its subdirectories
FILES=($(find papers/ -type f))

# Count the number of files
FILE_COUNT=${#FILES[@]}

# Check if the current number of files exceeds the limit
if [ "$FILE_COUNT" -le "$LIMIT" ]; then
echo "No files need to be deleted. Current count: $FILE_COUNT"
Expand All @@ -538,7 +530,7 @@ jobs:

# Calculate how many files to delete
FILES_TO_DELETE=$((FILE_COUNT - LIMIT))

# Sort files by modification time (oldest first) and delete the oldest ones
for FILE in $(ls -t "${FILES[@]}" | tail -n "$FILES_TO_DELETE"); do
echo "Deleting: $FILE"
Expand All @@ -561,7 +553,7 @@ jobs:
./occ config:app:set --value 10 --type integer context_chat crawl_job_interval # 10 seconds
./occ config:app:set --value 10 --type integer context_chat action_job_interval # 10 seconds
./occ config:app:set --value 10 --type integer context_chat fs_listener_job_interval # 10 seconds
for i in {1..100}; do
for i in {1..100}; do
php cron.php & # Starting with stable31 we can use -v here for better visibility
wait
./occ context_chat:stats
Expand Down Expand Up @@ -612,7 +604,7 @@ jobs:
echo "$OUT1" | grep -q "If all of these points are met, we give a Green label." || exit 1
echo "$OUT2" | grep -q "If all of these points are met, we give a Green label." || exit 1
echo "$OUT3" | grep -q "overview.rst" || exit 1

kill -9 $WORKER1_PID
kill -9 $WORKER2_PID

Expand Down Expand Up @@ -643,26 +635,16 @@ jobs:
matrix:
php-versions: [ '8.1' ]
databases: [ 'pgsql' ]
server-versions: [ 'stable30', 'stable31', 'master' ]
server-versions: [ 'stable32', 'master' ]
encryption: ['on', 'off']
file-deletion-method: [ 'occ', 'os' ]
exclude:
- server-versions: stable30
- server-versions: stable32
file-deletion-method: os
databases: pgsql
php-versions: 8.1
encryption: on
- server-versions: stable31
file-deletion-method: os
databases: pgsql
php-versions: 8.1
encryption: on
- server-versions: stable30
file-deletion-method: os
databases: pgsql
php-versions: 8.1
encryption: off
- server-versions: stable31
- server-versions: stable32
file-deletion-method: os
databases: pgsql
php-versions: 8.1
Expand Down Expand Up @@ -853,13 +835,13 @@ jobs:
run: |
cd data/admin/files
LIMIT=100

# Find all files in the directory and its subdirectories
FILES=($(find papers/ -type f))

# Count the number of files
FILE_COUNT=${#FILES[@]}

# Check if the current number of files exceeds the limit
if [ "$FILE_COUNT" -le "$LIMIT" ]; then
echo "No files need to be deleted. Current count: $FILE_COUNT"
Expand All @@ -868,7 +850,7 @@ jobs:

# Calculate how many files to delete
FILES_TO_DELETE=$((FILE_COUNT - LIMIT))

# Sort files by modification time (oldest first) and delete the oldest ones
for FILE in $(ls -t "${FILES[@]}" | tail -n "$FILES_TO_DELETE"); do
echo "Deleting: $FILE"
Expand All @@ -883,7 +865,7 @@ jobs:

- name: Run indexer cron
run: |
for i in {1..100}; do
for i in {1..100}; do
php cron.php & # Starting with stable31 we can use -v here for better visibility
wait
./occ context_chat:stats
Expand Down Expand Up @@ -923,21 +905,21 @@ jobs:
./occ background-job:worker -v 'OC\TaskProcessing\SynchronousBackgroundJob' &
WORKER2_PID=$!
set +e

# Check for user admin: Should be there
OUT_ADMIN_ENGLISH_PROMPT_AI=$(./occ context_chat:prompt admin "Which factors are taken into account for the Ethical AI Rating?")
OUT_ADMIN_GERMAN_PROMPT_AI=$(./occ context_chat:prompt admin "Welche Faktoren beeinflussen das Ethical AI Rating?")
OUT_ADMIN_SEARCH_AI=$(./occ context_chat:search admin "Welche Faktoren beeinflussen das Ethical AI Rating?")

# Check for user test: Shouldn't be there
OUT_TEST_ENGLISH_PROMPT_AI=$(./occ context_chat:prompt test "Which factors are taken into account for the Ethical AI Rating?")
OUT_TEST_GERMAN_PROMPT_AI=$(./occ context_chat:prompt test "Welche Faktoren beeinflussen das Ethical AI Rating?")
OUT_TEST_SEARCH_AI=$(./occ context_chat:search test "Welche Faktoren beeinflussen das Ethical AI Rating?")

# Check for user test: Shouldn't be there, because it was not shared yet
OUT_TEST_PROMPT_JOBS=$(./occ context_chat:prompt test "How do I set my TimedJob to be time insensitive?")
OUT_TEST_SEARCH_JOBS=$(./occ context_chat:search test "How do I set my TimedJob to be time insensitive?")

echo "OUT_ADMIN_ENGLISH_PROMPT_AI"
echo "$OUT_ADMIN_ENGLISH_PROMPT_AI"
echo "OUT_ADMIN_GERMAN_PROMPT_AI"
Expand All @@ -954,7 +936,7 @@ jobs:
echo "$OUT_TEST_PROMPT_JOBS"
echo "OUT_TEST_SEARCH_JOBS"
echo "$OUT_TEST_SEARCH_JOBS"

echo "$OUT_ADMIN_ENGLISH_PROMPT_AI" | grep -q "If all of these points are met, we give a Green label." && echo '✅ Admin does see AI overview' || exit 1
echo "$OUT_ADMIN_GERMAN_PROMPT_AI" | grep -q "If all of these points are met, we give a Green label." && echo '✅ Admin does see AI overview, after german question' || exit 1
echo "$OUT_ADMIN_SEARCH_AI" | grep -q "overview.rst" && echo '✅ Admin does see AI overview, when using search' || exit 1
Expand All @@ -963,7 +945,7 @@ jobs:
echo "$OUT_TEST_SEARCH_AI" | grep -q -v "overview.rst" && echo '✅Test user does not see AI overview, when using search' || exit 1
echo "$OUT_TEST_PROMPT_JOBS" | grep -q -v "background jobs" && echo '✅Test user does not see BackgroundJobs docs' || exit 1
echo "$OUT_TEST_SEARCH_JOBS" | grep -q -v "backgroundjobs.md" && echo '✅Test user does not see BackgroundJobs docs' || exit 1

kill -9 $WORKER1_PID
kill -9 $WORKER2_PID

Expand All @@ -975,7 +957,7 @@ jobs:
- name: Remove some files using os
if: ${{ matrix.file-deletion-method == 'os'}}
run: |
cd data/admin/files
cd data/admin/files
rm -rf ./admin_manual # this + files:scan sadly doesn't work, currently see https://github.com/nextcloud/context_chat/issues/153
cd ../../..
./occ files:scan admin # We run the scan again to check if the files are successfully removed from the vectordb
Expand All @@ -990,7 +972,7 @@ jobs:

- name: Run indexer cron
run: |
for i in {1..100}; do
for i in {1..100}; do
php cron.php & # Starting with stable31 we can use -v here for better visibility
wait
./occ context_chat:stats
Expand All @@ -1002,23 +984,23 @@ jobs:
WORKER1_PID=$!
./occ background-job:worker -v 'OC\TaskProcessing\SynchronousBackgroundJob' &
WORKER2_PID=$!

set +e

# Check for user admin: Shouldn't be there
OUT_ADMIN_ENGLISH_PROMPT_AI=$(./occ context_chat:prompt admin "Which factors are taken into account for the Ethical AI Rating?")
OUT_ADMIN_GERMAN_PROMPT_AI=$(./occ context_chat:prompt admin "Welche Faktoren beeinflussen das Ethical AI Rating?")
OUT_ADMIN_SEARCH_AI=$(./occ context_chat:search admin "Welche Faktoren beeinflussen das Ethical AI Rating?")

# Check for user test: Shouldn't be there
OUT_TEST_ENGLISH_PROMPT_AI=$(./occ context_chat:prompt test "Which factors are taken into account for the Ethical AI Rating?")
OUT_TEST_GERMAN_PROMPT_AI=$(./occ context_chat:prompt test "Welche Faktoren beeinflussen das Ethical AI Rating?")
OUT_TEST_SEARCH_AI=$(./occ context_chat:search test "Welche Faktoren beeinflussen das Ethical AI Rating?")

# Check for user test: Should be there, because it was shared
OUT_TEST_PROMPT_JOBS=$(./occ context_chat:prompt test "How do I set my TimedJob to be time insensitive?")
OUT_TEST_SEARCH_JOBS=$(./occ context_chat:search test "How do I set my TimedJob to be time insensitive?")

echo "OUT_ADMIN_ENGLISH_PROMPT_AI"
echo "$OUT_ADMIN_ENGLISH_PROMPT_AI"
echo "OUT_ADMIN_GERMAN_PROMPT_AI"
Expand All @@ -1035,7 +1017,7 @@ jobs:
echo "$OUT_TEST_PROMPT_JOBS"
echo "OUT_TEST_SEARCH_JOBS"
echo "$OUT_TEST_SEARCH_JOBS"

echo "$OUT_ADMIN_ENGLISH_PROMPT_AI" | grep -q -v "If all of these points are met, we give a Green label." && echo '✅ Admin does not see AI overview anymore' || exit 1
echo "$OUT_ADMIN_GERMAN_PROMPT_AI" | grep -q -v "If all of these points are met, we give a Green label." && echo '✅ Admin does not see AI overview anymore, after german question' || exit 1
echo "$OUT_ADMIN_SEARCH_AI" | grep -q -v "overview.rst" && echo '✅ Admin does not see AI overview anymore, when using search' || exit 1
Expand All @@ -1044,7 +1026,7 @@ jobs:
echo "$OUT_TEST_SEARCH_AI" | grep -q -v "overview.rst" && echo '✅Test user does not see AI overview, when using search' || exit 1
echo "$OUT_TEST_PROMPT_JOBS" | grep -q "background jobs" && echo '✅Test user does see BackgroundJobs docs' || exit 1
echo "$OUT_TEST_SEARCH_JOBS" | grep -q "backgroundjobs.md" && echo '✅Test user does see BackgroundJobs docs' || exit 1

kill -9 $WORKER1_PID
kill -9 $WORKER2_PID

Expand Down Expand Up @@ -1079,4 +1061,4 @@ jobs:

steps:
- name: Summary status
run: if ${{ needs.scan-test.rest != 'success' && needs.cron-test.result != 'success' && needs.listener-test.result != 'success' }}; then exit 1; fi
run: if ${{ needs.scan-test.rest != 'success' && needs.cron-test.result != 'success' && needs.listener-test.result != 'success' }}; then exit 1; fi
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Refer to the [Context Chat Backend's readme](https://github.com/nextcloud/contex
<screenshot>https://raw.githubusercontent.com/nextcloud/context_chat/main/screenshots/context_chat_4.png</screenshot>
<screenshot>https://raw.githubusercontent.com/nextcloud/context_chat/main/screenshots/context_chat_5.png</screenshot>
<dependencies>
<nextcloud min-version="30" max-version="33"/>
<nextcloud min-version="32" max-version="33"/>
</dependencies>
<background-jobs>
<job>OCA\ContextChat\BackgroundJobs\FileSystemListenerJob</job>
Expand Down
6 changes: 6 additions & 0 deletions doc/Implementing_a_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

> [!IMPORTANT]
> As of Nextcloud 32, the internal API described in this document has been replaced with the OCP API.
>
> For more details, see the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/context_chat.html).

# How to implement a content provider for Context Chat

### The content provider interface
Expand Down
21 changes: 1 addition & 20 deletions lib/Event/ContentProviderRegisterEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,5 @@

namespace OCA\ContextChat\Event;

use OCA\ContextChat\Public\ContentManager;
use OCA\ContextChat\Public\IContentProvider;
use OCP\EventDispatcher\Event;

class ContentProviderRegisterEvent extends Event {
public function __construct(
private ContentManager $contentManager,
) {
}

/**
* @param string $appId
* @param string $providerId
* @param class-string<IContentProvider> $providerClass
* @return void
* @since 2.2.2
*/
public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
$this->contentManager->registerContentProvider($appId, $providerId, $providerClass);
}
class ContentProviderRegisterEvent extends \OCP\ContextChat\Events\ContentProviderRegisterEvent {
}
21 changes: 1 addition & 20 deletions lib/Public/ContentItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,5 @@

namespace OCA\ContextChat\Public;

class ContentItem {
/**
* @param string $itemId
* @param string $providerId
* @param string $title
* @param string $content
* @param string $documentType
* @param \DateTime $lastModified
* @param string[] $users
*/
public function __construct(
public string $itemId,
public string $providerId,
public string $title,
public string $content,
public string $documentType,
public \DateTime $lastModified,
public array $users,
) {
}
class ContentItem extends \OCP\ContextChat\ContentItem {
}
Loading
Loading