Skip to content

Commit

Permalink
Merge pull request #863 from UN-OCHA/feature/RW-1035
Browse files Browse the repository at this point in the history
feat: Index entities
  • Loading branch information
attiks authored Sep 20, 2024
2 parents 761b401 + b826f66 commit 0059071
Show file tree
Hide file tree
Showing 13 changed files with 1,436 additions and 4 deletions.
39 changes: 39 additions & 0 deletions PATCHES/remove-tcpdf-footer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/src/MyPdf.php b/src/MyPdf.php
index 082131a..bb3cb96 100644
--- a/src/MyPdf.php
+++ b/src/MyPdf.php
@@ -21,6 +21,7 @@ class MyPdf extends TCPDF
protected $_transf = array();
protected $_myLastPageGroup = null;
protected $_myLastPageGroupNb = 0;
+ protected $tcpdflink = false;

// used to make a radius with bezier : (4/3 * (sqrt(2) - 1))
const MY_ARC = 0.5522847498;
@@ -267,7 +268,7 @@ class MyPdf extends TCPDF
$cornerBL = null,
$cornerBR = null
) {
-
+
// init the path
$path = '';

@@ -1087,7 +1088,7 @@ class MyPdf extends TCPDF
$drawFirst = true,
$trans = false
) {
-
+
// if we want the no trigo direction : add 2PI to the begin angle, to invert the direction
if (!$direction) {
$angleBegin+= M_PI*2.;
@@ -1387,7 +1388,7 @@ class MyPdf extends TCPDF
$page = null,
$fontName = 'helvetica'
) {
-
+
// bookmark the Title if wanted
if ($bookmarkTitle) {
$this->Bookmark($titre, 0, -1);
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,25 @@ XDEBUG_MODE=coverage vendor/bin/phpunit
# without coverage
vendor/bin/phpunit
```

## For dev

```bash
drush rapi-i --alias job --verbose
drush rw-job:index --verbose

cget ocha_ai.settings --include-overridden
cget ocha_ai_tag.settings --include-overridden
cget ocha_ai_chat.settings --include-overridden
cget reliefweb_api.settings --include-overridden

cset ocha_ai.settings plugins.source.reliefweb.api_url https://dev.api-reliefweb-int.ahconu.org/v1
cset ocha_ai.settings plugins.source.reliefweb.converter_url https://xxx:[email protected]/search/converter/json
cset reliefweb_api.settings api_url https://dev.api-reliefweb-int.ahconu.org/v1
cset reliefweb_api.settings api_url_external https://dev.api-reliefweb-int.ahconu.org/v1
cset reliefweb_api.settings website: https://dev.reliefweb-int.ahconu.org

queue:list
queue:run --verbose reliefweb_job_tagger

```
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"reliefweb/api-indexer": "^v2.8",
"reliefweb/simple-autocomplete": "^v1.3",
"reliefweb/simple-datepicker": "^v1.3",
"spipu/html2pdf": "^5.2",
"symfony/uid": "^6.2",
"unocha/common_design": "^9.4",
"unocha/gtm_barebones": "^1.1",
Expand Down
137 changes: 133 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"drush/drush": {
"https://humanitarian.atlassian.net/browse/OPS-8026": "PATCHES/drush--timeout-override.patch"
},
"spipu/html2pdf": {
"Remove promo link": "PATCHES/remove-tcpdf-footer.patch"
},
"unocha/common_design": {
"https://humanitarian.atlassian.net/browse/CD-519": "PATCHES/common_design--default-logo-remove.patch"
}
Expand Down
76 changes: 76 additions & 0 deletions html/modules/custom/reliefweb_semantic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# ReliefWeb - Semantic module

This module provides integration with the ReliefWeb Semantic API.

## To do

- [x] Add service to query API

## AWS

Dashboards:

- https://us-east-1.console.aws.amazon.com/s3/lens/dashboard/RW-KB?region=us-east-1&bucketType=general

Config:

- Role: `BedrockRoleKbRw`
- Collection: `arn:aws:aoss:us-east-1:694216630861:collection/b2h8ajgjb3x87ur892hc`
- Vector field: `embedding`
- Text field name: `AMAZON_BEDROCK_TEXT_CHUNK`
- Metadata field name: `AMAZON_BEDROCK_METADATA`

All content is using a single KB, current Id is `VIEPSPYNSS`

## Drush

```bash
drush reliefweb-semantic:index Index content in the ReliefWeb API.
drush reliefweb-semantic:list-kbs List kbs.
drush reliefweb-semantic:list-datasources List datasources.
drush reliefweb-semantic:list-jobs List ingestion jobs.
drush reliefweb-semantic:trigger-sync Trigger sync..
drush reliefweb-semantic:query-kb --id=WYBGQOFQLN --q="Any jobs in Europe"
drush reliefweb-semantic:list-apikeys
```

## Openseach

```json
GET /bedrock-knowledge-base-default-index/_search
{
"query": {
"match_all": {}
}
}
```

```json
GET /bedrock-knowledge-base-default-index/_search
{
"query": {
"match": {
"country": "*"
}

}
}
```

```json
GET /bedrock-knowledge-base-default-index/_search
{
"query": {
"match": {
"title": {
"query": "china",
"fuzziness": "AUTO"
}
}
}
}
```

## Questions

- Describe the weather in china in june 2024
12 changes: 12 additions & 0 deletions html/modules/custom/reliefweb_semantic/drush.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
reliefweb_semantic.commands:
class: \Drupal\reliefweb_semantic\Commands\ReliefWebSemanticCommands
arguments: ['@config.factory', '@entity_field.manager', '@entity_type.manager', '@module_handler', '@state', '@http_client', '@file_system', '@renderer']
tags:
- { name: drush.command }
reliefweb_semantic.aws_commands:
class: \Drupal\reliefweb_semantic\Commands\ReliefWebSemanticAwsCommands
arguments: ['@config.factory', '@state', '@reliefweb_semantic.search_service']
tags:
- { name: drush.command }

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: module
name: ReliefWeb Semantic
description: 'Provides integration with the ReliefWeb Semantic API.'
package: reliefweb
core_version_requirement: ^9 || ^10
Loading

0 comments on commit 0059071

Please sign in to comment.