Skip to content

Commit

Permalink
Allo for source exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskiesel committed Nov 8, 2024
1 parent 7c2e8c2 commit a94aebc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Flexible simulation and evaluation framework for generative IR.
[![docker workflow](https://img.shields.io/github/actions/workflow/status/webis-de/GenIRSim/ghcr.yml?label=docker)](https://github.com/webis-de/GenIRSim/pkgs/container/GenIRSim)
[![license](https://img.shields.io/github/license/webis-de/GenIRSim)](https://github.com/webis-de/GenIRSim/blob/main/LICENSE)

<sup>Tested in node 21.7.2 with npm 10.5.0</sup>
<sup>Tested in node 21.7.2 with npm 10.9.0</sup>

## Quickstart

Expand Down
16 changes: 13 additions & 3 deletions src/systems/generative-elastic-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { LLM } from "../llm.js"

async function queryElastic(query, searchConfiguration, logbook) {
const data = {query: query};
for (const optionalAttribute of [ "_source" ]) {
if (optionalAttribute in searchConfiguration) {
data[optionalAttribute] = searchConfiguration[optionalAttribute];
}
}
const body = JSON.stringify(data);
const headers = new Headers();
headers.append("Content-Type", "application/json");
Expand All @@ -15,6 +20,9 @@ async function queryElastic(query, searchConfiguration, logbook) {
searchConfiguration.url + "_search?size=" + searchConfiguration.size,
params);
const responseJson = await response.json();
if ("error" in responseJson) {
throw new Error("Elasticsearch error: " + JSON.stringify(responseJson));
}
const results = responseJson.hits.hits.map((hit, index) => {
const result = Object.assign({}, hit["_source"]);
result.key = index + 1;
Expand Down Expand Up @@ -53,14 +61,16 @@ async function queryElastic(query, searchConfiguration, logbook) {
* `variables.userTurn.utterance`
* @param {Array} [configuration.preprocessing.requiredKeys] - The properties
* that the preprocessing response must have (none by default)
* @param {Object} configuration.search
* @param {string} configuration.search.url - The complete URL of the
* Elasticsearch server's API endpoint (up to but excluding `_search`)
* @param {string} configuration.search.query - The Elasticsearch query object
* for retrieving results, but every string in it is treated as a template.
* Variables are the same as for `configuration.preprocessing.message`, plus:
* - `{{variables.preprocessing}}`: The parsed output of the preprocessing (if
* preprocessing was performed)
* @param {Object} configuration.search
* @param {string} configuration.search.url - The complete URL of the
* Elasticsearch server's API endpoint (up to but excluding `_search`)
* @param {Array} [configuration.search._source_excludes] - A comma-separated
* list of source fields to exclude from the response
* @param {number} configuration.search.size - The number of results to retrieve
* @param {Object} configuration.generation
* @param {string} configuration.generation.message - Template for the
Expand Down

0 comments on commit a94aebc

Please sign in to comment.