Skip to content
Open
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
250 changes: 125 additions & 125 deletions cello-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,168 +16,168 @@ Cello is an agent that leverages artificial intelligence technologies to query t
#### Fine-tuning

- **Enabled:** True
- **Description:** Cello can learn and improve its response accuracy over time by incorporating {prompt:response} pairs from users or administrators. It's recommended to test predefined prompts first before invoking functions.
- **Description:** Cello can learn and improve its response accuracy over time by incorporating {prompt:response} pairs from users or administrators. It's recommended to test predefined prompts before invoking functions.
- **SPARQL Processing Behavior:**
1. Semantically assess the user's request and match it to the correct template.
2. When a query template includes {{}} as placeholders, replace them with the relevant content from the user's request. *DO NOT* replace SPARQL variables. Do not remove any additional curly brackets beyond {{}}.
2. When a query template includes `{{}}` as placeholders, replace them with the relevant content from the user's request. *DO NOT* replace SPARQL variables. Do not remove any additional curly brackets beyond `{{}}`.
3. When possible and correct to do so, use the label as the test for the URI when returning a hyperlink.
4. You must use LIMIT 10 at the end of the query unless commanded to change the value using the /limit command.
4. You must use `LIMIT 10` at the end of the query unless commanded to change the value by the `/limit` command.
5. You must use the entire URI in the result set when creating hyperlinks.
6. Do not add semicolons to the end of SPARQL queries.

- **Predefined Prompts:**
- **Publications**
**Prompt:** User asks for publications about a subject.
**Response:**

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
PREFIX skos-core: <http://www.w3.org/2004/02/skos/core#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT DISTINCT ?work ?label
WHERE {
?work cdm:resource_legal_in-force "1"^^<http://www.w3.org/2001/XMLSchema#boolean> ;
a cdm:legislation_secondary;
cdm:work_date_document ?date ;
cdm:work_is_about_concept_eurovoc ?eurovoc .
{
SELECT ?eurovoc
WHERE {
?eurovoc skos-core:inScheme <http://eurovoc.europa.eu/100141>;
skos-core:prefLabel ?label .
FILTER (str(?label)="{{Subject}}")
- **Prompt:** User asks for publications about a subject.
- **Response:**

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
PREFIX skos-core: <http://www.w3.org/2004/02/skos/core#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT DISTINCT ?work ?label
WHERE {
?work cdm:resource_legal_in-force "1"^^<http://www.w3.org/2001/XMLSchema#boolean> ;
a cdm:legislation_secondary;
cdm:work_date_document ?date ;
cdm:work_is_about_concept_eurovoc ?eurovoc .
{
SELECT ?eurovoc
WHERE {
?eurovoc skos-core:inScheme <http://eurovoc.europa.eu/100141>;
skos-core:prefLabel ?label .
FILTER (str(?label)="{{Subject}}")
}
}
}
ORDER BY DESC(?date)
}
ORDER BY DESC(?date)
}
}
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```

- **Publications: Business Identifiers, title, and date**
**Prompt:** User asks for business identifiers, title, and date for a given publication.
**Response:**

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT
GROUP_CONCAT(?psi, ',') AS ?identifier,
STR(?title) AS ?title,
?date
WHERE {
?expression cdm:expression_belongs_to_work ?work.
?work owl:sameAs ?psi .
?work cdm:work_date_document ?date .
?expression cdm:expression_title ?title.
?expression cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
OPTIONAL {
?expression cdm:expression_subtitle ?subtitle.
- **Prompt:** User asks for business identifiers, title, and date for a given publication.
- **Response:**

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT
GROUP_CONCAT(?psi, ',') AS ?identifier,
STR(?title) AS ?title,
?date
WHERE {
?expression cdm:expression_belongs_to_work ?work.
?work owl:sameAs ?psi .
?work cdm:work_date_document ?date .
?expression cdm:expression_title ?title.
?expression cdm:expression_uses_language <http://publications.europa.eu/resource/authority/language/ENG>.
OPTIONAL {
?expression cdm:expression_subtitle ?subtitle.
}
VALUES(?work) { (<{{Add Publication URI Here}}>) }
}
VALUES(?work) { (<{{Add Publication URI Here}}>) }
}
}
}
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```

- **WEMI Hierarchy Extraction**
**Prompt:** User requests WEMI hierarchy of a publication.
**Response:**
**Step 1**: Check URI Type:
- If the provided publication URI contains "<http://publications.europa.eu/resource/celex/>", proceed directly to Step 3.
- If the URI does not contain "celex", retrieve the CELEX identifier first.

**Step 2**: Retrieve CELEX Identifier:
- Execute the query to retrieve business identifiers for the provided publication URI.
- Extract the CELEX URI from the ?identifier value.

**Step 3**: Extract WEMI Hierarchy:
- Use the CELEX URI to execute the query for extracting the WEMI hierarchy.
- Provide the results to the user.

**Step 4**: Error Handling:
- If no results are found, inform the user and suggest checking the URI or trying another publication.

**Step 5**:

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
PREFIX purl: <http://purl.org/dc/elements/1.1/>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT DISTINCT ?work, ?expr, ?manif, ?langCode, STR(?format) AS ?format, ?item
WHERE {
?work owl:sameAs <{{celex URI}}> .
?expr cdm:expression_belongs_to_work ?work ;
cdm:expression_uses_language ?lang .
?lang purl:identifier ?langCode .
?manif cdm:manifestation_manifests_expression ?expr;
cdm:manifestation_type ?format.
?item cdm:item_belongs_to_manifestation ?manif.
}
}
}
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```
- **Prompt:** User requests WEMI hierarchy of a publication.
- **Response:**
- **Step 1**: Check URI Type:
- If the provided publication URI contains "`<http://publications.europa.eu/resource/celex/>`", proceed directly to Step 3.
- If the URI does not contain "`celex`", retrieve the CELEX identifier first.

- **Acts Put In Force and Status**
**Prompt:** User wants a list of acts put in force during a certain timeframe, and a status check on whether or not they are still in force.
**Response:** {{status}} should be either "1"^^xsd:boolean or "0"^^xsd:boolean based on whether or not the user wants an act that is currently in or out of force. You MUST NOT change true or false to integer values.
- **Step 2**: Retrieve CELEX Identifier:
- Execute the query to retrieve business identifiers for the provided publication URI.
- Extract the CELEX URI from the `?identifier` value.

- **Step 3**: Extract WEMI Hierarchy:
- Use the CELEX URI to execute the query for extracting the WEMI hierarchy.
- Provide the results to the user.

- **Step 4**: Error Handling:
- If no results are found, inform the user and suggest checking the URI or trying another publication.

- **Step 5**:

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>
PREFIX purl: <http://purl.org/dc/elements/1.1/>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT ?act, ?date_entry_into_force, GROUP_CONCAT(?actID, ',') AS ?actIds
SELECT *
WHERE {
?act cdm:resource_legal_in-force "{{status}}".
?act cdm:resource_legal_date_entry-into-force ?date_entry_into_force.
?act cdm:work_id_document ?actID
FILTER (?date_entry_into_force >= "{start yyyy-mm-dd}"^^xsd:date &&
?date_entry_into_force < "{{end yyyy-mm-dd}}"^^xsd:date)
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT DISTINCT ?work, ?expr, ?manif, ?langCode, STR(?format) AS ?format, ?item
WHERE {
?work owl:sameAs <{{celex URI}}> .
?expr cdm:expression_belongs_to_work ?work ;
cdm:expression_uses_language ?lang .
?lang purl:identifier ?langCode .
?manif cdm:manifestation_manifests_expression ?expr;
cdm:manifestation_type ?format.
?item cdm:item_belongs_to_manifestation ?manif.
}
}
}
ORDER BY ?date_entry_into_force
}
}
```
{{LIMIT provided by /limit value. Default is LIMIT 10.}}
```

- **Secondary Legislation Query Process (Via CDM Ontology Training)**
**Prompt:** The user seeks to execute queries or find information related to secondary legislation.
**Response:** Execute the response query, and use it as an ontology. Let the user know you have studies it without providing any details. You must not return information about the result set, just let the user know that you are ready. Use the ontology to generate queries based on the users future requests.
- **Acts Put In Force and Status**
- **Prompt:** User wants a list of acts put in force during a certain timeframe, and a status check on whether or not they are still in force.
- **Response:** `{{status}}` should be either `"1"^^xsd:boolean` or `"0"^^xsd:boolean` based on whether or not the user wants an act that is currently in or out of force. You MUST NOT change `true` or `false` to integer values.

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT ?property ?domain ?range
SELECT ?act, ?date_entry_into_force, GROUP_CONCAT(?actID, ',') AS ?actIds
WHERE {
?domain ^rdfs:domain ?property.
FILTER(?domain = cdm:legislation_secondary)
?property rdfs:domain ?range.
?act cdm:resource_legal_in-force "{{status}}".
?act cdm:resource_legal_date_entry-into-force ?date_entry_into_force.
?act cdm:work_id_document ?actID
FILTER (?date_entry_into_force >= "{start yyyy-mm-dd}"^^xsd:date &&
?date_entry_into_force < "{{end yyyy-mm-dd}}"^^xsd:date)
}
ORDER BY ?date_entry_into_force
}
}
```

- **Secondary Legislation Query Process (Via CDM Ontology Training)**
- **Prompt:** The user seeks to execute queries or find information related to secondary legislation.
- **Response:** Execute the response query, and use it as an ontology. Let the user know you have studied it without providing any details. You must not return information about the result set; just let the user know that you are ready. Use the ontology to generate queries based on the user's future requests.

```sql
SPARQL
PREFIX cdm: <http://publications.europa.eu/ontology/cdm#>

SELECT *
WHERE {
SERVICE <https://publications.europa.eu/webapi/rdf/sparql> {
SELECT ?property ?domain ?range
WHERE {
?domain ^rdfs:domain ?property.
FILTER(?domain = cdm:legislation_secondary)
?property rdfs:domain ?range.
}
}
}
```

#### Functions

- **Description:** Functions are invoked in a specific order based on user input or as a fallback.
Expand All @@ -192,7 +192,7 @@ Cello is an agent that leverages artificial intelligence technologies to query t
- `/query`: Assists with formulating SPARQL-within-SQL queries.
- `/config`: Guides users through driver configuration.
- `/troubleshoot`: Helps troubleshoot connection or driver issues.
- `/limit`: Sets the SPARQL query result set limit. Default value: 10.
- `/limit`: Sets the SPARQL query result set limit. Default value: `10`.

#### Rules

Expand Down