Skip to content

Commit

Permalink
Merge pull request #13 from nextcloud/feat/no-context-option-prompt
Browse files Browse the repository at this point in the history
add no-context option to prompt command
  • Loading branch information
marcelklehr authored Feb 16, 2024
2 parents 7b0086c + e20bf81 commit ceb8576
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,25 @@ jobs:
make all
composer install --no-dev
- name: Set up Nextcloud and install app
- name: Set up Nextcloud
if: ${{ matrix.databases != 'pgsql'}}
run: |
sleep 25
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$MYSQL_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable -vvv -f ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: Set up Nextcloud and install app
- name: Set up Nextcloud
if: ${{ matrix.databases == 'pgsql'}}
run: |
sleep 25
mkdir data
./occ maintenance:install --verbose --database=${{ matrix.databases }} --database-name=nextcloud --database-host=127.0.0.1 --database-port=$PGSQL_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
./occ app:enable -vvv -f ${{ env.APP_NAME }}
php -S localhost:8080 &
- name: Enable app and app_api
run: ./occ app:enable -vvv -f ${{ env.APP_NAME }} app_api

- name: Checkout documentation
uses: actions/checkout@v4
with:
Expand All @@ -144,14 +145,12 @@ jobs:
find ./ -depth -name "*.rst" -exec sh -c 'mv "$1" "${1%.rst}.txt"' _ {} \;
git status
- name: Install app and app_api
run: |
./occ app:enable -vvv ${{ env.APP_NAME }} app_api
- name: Install and init backend
- name: Setup python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install and init backend
run: |
cd context_chat_backend
pip install --no-deps -r reqs.txt
Expand All @@ -169,7 +168,7 @@ jobs:
- name: Scan files
run: |
./occ files:scan --all
./occ context_chat:scan admin
./occ context_chat:scan -m text/plain admin
- name: Run prompt
run: |
Expand Down
17 changes: 13 additions & 4 deletions lib/Command/Prompt.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
namespace OCA\ContextChat\Command;

use OCA\ContextChat\TextProcessing\ContextChatTaskType;
use OCP\TextProcessing\FreePromptTaskType;
use OCP\TextProcessing\IManager;
use OCP\TextProcessing\Task;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Prompt extends Command {
Expand All @@ -32,21 +34,28 @@ protected function configure() {
$this->setName('context_chat:prompt')
->setDescription('Prompt Nextcloud Assistant Context Chat')
->addArgument(
'user_id',
'uid',
InputArgument::REQUIRED,
'The ID of the user to prompt the documents of'
)
->addArgument(
'prompt',
InputArgument::REQUIRED,
'The prompt'
);
)
->addOption('no-context', null, InputOption::VALUE_NONE, 'Do not use context');
}

protected function execute(InputInterface $input, OutputInterface $output) {
$userId = $input->getArgument('user_id');
$userId = $input->getArgument('uid');
$prompt = $input->getArgument('prompt');
$task = new Task(ContextChatTaskType::class, $prompt, 'context_chat', $userId);
$noContext = $input->getOption('no-context');

if ($noContext) {
$task = new Task(FreePromptTaskType::class, $prompt, 'context_chat', $userId);
} else {
$task = new Task(ContextChatTaskType::class, $prompt, 'context_chat', $userId);
}

$this->textProcessingManager->runTask($task);
$output->writeln($task->getOutput());
Expand Down
1 change: 1 addition & 0 deletions lib/Service/LangRopeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function getWithPresentableSources(string $llmResponse, string ...$source

foreach ($sourceRefs as $source) {
if (str_starts_with($source, 'file: ') && is_numeric($fileId = substr($source, 6))) {
// use `overwritehost` setting in config.php to overwrite the host
$output .= $this->urlGenerator->linkToRouteAbsolute('files.View.showFile', ['fileid' => $fileId]) . PHP_EOL;
} elseif (str_contains($source, '__')) {
// source id ($appId__$providerId: $itemId)
Expand Down

0 comments on commit ceb8576

Please sign in to comment.