forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
378 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
define("CLI_SCRIPT", true); | ||
require_once("../../../../config.php"); | ||
|
||
$search = $search = \core_search\manager::instance(true, true); | ||
|
||
$engine = $search->get_engine(); | ||
|
||
/** | ||
* \core\ai\AIProvider | ||
*/ | ||
$provider = core\ai\api::get_provider(1); | ||
|
||
$doccontent = file_get_contents($CFG->dirroot . "/search/engine/solrrag/tests/testdoc.txt"); | ||
if (file_exists($CFG->dirroot . "/search/engine/solrrag/tests/testdoc_vector.txt")) { | ||
$vector = file_get_contents($CFG->dirroot . "/search/engine/solrrag/tests/testdoc_vector.txt"); | ||
} else { | ||
$client = new \core\ai\AIClient($provider); | ||
$vector = $client->embed_query($doccontent); | ||
file_put_contents($CFG->dirroot . "/search/engine/solrrag/tests/testdoc_vector.txt", $vector); | ||
} | ||
$doc = [ | ||
'id' => 'testdoc', | ||
'solr_vector_1356' => $vector, | ||
'title' => "this is a test document" | ||
]; | ||
|
||
$document = new \search_solrrag\document("1", "mod_xaichat", "files"); | ||
$document->set('title', 'test document'); | ||
$document->set('solr_vector_1536', $vector); | ||
$document->set('content',$doccontent); | ||
$document->set('contextid', context_system::instance()->id); | ||
$document->set('courseid', SITEID); | ||
$document->set('owneruserid', $USER->id); | ||
$document->set('modified', time()); | ||
$engine->add_document($document); | ||
|
14 changes: 14 additions & 0 deletions
14
search/engine/solrrag/tests/fixtures/mock_vector_search.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
namespace search_solrrag; | ||
|
||
use core_mocksearch\search\mock_search_area; | ||
|
||
defined ('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Provides unit test fixtures for vector search tests. | ||
*/ | ||
class mock_vector_search extends mock_search_area { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace search_solr; | ||
|
||
/** | ||
* Search engine for testing purposes. | ||
* | ||
* @package search_solr | ||
* @category phpunit | ||
* @copyright 2016 Eric Merrill {@link http://www.merrilldigital.com} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die; | ||
|
||
class testable_enginer extends \search_solrrag\engine { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Moodle requires a directory to store all of its files (all your site's uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. | ||
|
||
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the Performance recommendations carefully and consider using (e.g.) redis or memcached for Caching. | ||
|
||
IMPORTANT: This directory must NOT be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. | ||
|
||
Here is an example (Unix/Linux) of creating the directory and setting the permissions for anyone on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files. | ||
|
||
# mkdir /path/to/moodledata | ||
# chmod 0777 /path/to/moodledata |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.