template:
## Task:

Answer the query given immediately below given the context which follows later. Use line item references to like [1], [2], ... refer to specifically numbered items in the provided context. Pay close attention to the title of each given source to ensure it is consistent with the query.

### Query:
{query}

### Context:
{context}

### Query:
{query}

REMINDER - Use line item references to like [1], [2], ... refer to specifically numbered items in the provided context.
## Response:

query: str

context: str


hyde

template:
### Instruction:

Given the query that follows write a double newline separated list of {num_outputs} single paragraph distinct attempted answers to the given query.
DO NOT generate any single answer which is likely to require information from multiple distinct documents,
EACH single answer will be used to carry out a cosine similarity semantic search over distinct indexed documents, such as varied medical documents.
FOR EXAMPLE if asked `how do the key themes of Great Gatsby compare with 1984`, the two attempted answers would be
`The key themes of Great Gatsby are ... ANSWER_CONTINUED` and `The key themes of 1984 are ... ANSWER_CONTINUED`, where `ANSWER_CONTINUED` IS TO BE COMPLETED BY YOU in your response.
Here is the original user query to be transformed into answers:

### Query:
{message}

### Response:

num_outputs: int

message: str


template:
### Instruction:

Given the following query that follows to write a double newline separated list of up to {num_outputs} queries meant to help answer the original query.
DO NOT generate any single query which is likely to require information from multiple distinct documents,
EACH single query will be used to carry out a cosine similarity semantic search over distinct indexed documents, such as varied medical documents.
FOR EXAMPLE if asked `how do the key themes of Great Gatsby compare with 1984`, the two queries would be
`What are the key themes of Great Gatsby?` and `What are the key themes of 1984?`.
Here is the original user query to be transformed into answers:

### Query:
{message}

### Response:

message: str


template:
### Instruction:

You are given a `query`, related `context` and an associated `answer`. Your task is to sequentially score each sentence in the given answer as either 1 or 0, based on whether or not the given sentence is relevant to the given query and supported in full by the given context.
### Example:
#### Input:

Query:
Why does Alice prefer spending her mornings in the garden?

Context:
Alice loves to read books in her garden. She has a large collection of mystery novels. Every morning, she spends an hour reading while drinking her favorite tea. Her garden is filled with various flowers, and she especially loves the roses. On weekends, Alice's friend, Bob, often joins her for tea and they discuss the books they've read.

Answer:
Alice enjoys her mornings in the garden because she loves to read there. She often listens to music while reading.
####### Response:

([1,0], '1/2')### Input:
Query:
{query}

Context:
{context}

Answer:
{answer}

Response:

query: str

context: str

answer: str


template:
### Instruction:

You are given a `query` and an associated `context`. Your task is to sequentially score each sentence in the context as either 1 or 0, based on the relevancy to the given query. For instance, if the query is "What is the capital of France?" then the sentence "The capital of France is Paris" would receive a +1 value, whereas "The french enjoy wine" would receive a 0. Return your response as a tuple containing a list of 1s and 0s, where each value corresponds to the respective sentence in the context, and then the rational fraction of 1's to the total number of sentences (e.g. '1/4'). NOTE - do not include ANY extra text other than the requested tuple.

Query:
{query}

Context:
{context}

###Response

query: str

context: str


template:
### Instruction
You will shortly be asked to perform Named Entity Recognition (NER) and knowledge graph triplet extraction on the text that follows. NER involves identifying named entities in a text, and knowledge graph triplet extraction involves identifying relationships between these entities and other attributes in the text.

A knowledge graph triplet contains the three following pieces of information:
- `subject`: The main entity.
- `predicate`: The relationship type.
- `object`: The related entity.

They are represented below as `[subject]:<predicate>:[object]`.

#### Process
**Identify Named Entities**: Extract entities based on the given entity types, ensuring they appear in the order they are mentioned in the text.
**Establish Triplets**: Form triplets using the provided predicates, again in the order they appear in the text.

Your final response should follow this format:

**Output:**
```json
{{
    "entities_and_triples": [
        "[1], entity_type:entity_name",
        "[1] predicate [2]",
        "[1] predicate [3]",
        "[2], entity_type:entity_name",
        ...
    ]
}}
```

### Example:

**Entity Types:**
ORGANIZATION
COMPANY
CITY
STATE
COUNTRY
OTHER
PERSON
YEAR
MONTH
DAY
OTHER
QUANTITY
EVENT

**Predicates:**
FOUNDED_BY
HEADQUARTERED_IN
OPERATES_IN
OWNED_BY
ACQUIRED_BY
HAS_EMPLOYEE_COUNT
GENERATED_REVENUE
LISTED_ON
INCORPORATED
HAS_DIVISION
ALIAS
ANNOUNCED
HAS_QUANTITY
AS_OF

**Input:**
Walmart Inc. (formerly Wal-Mart Stores, Inc.) is an American multinational retail corporation that operates a chain of hypermarkets (also called supercenters), discount department stores, and grocery stores in the United States, headquartered in Bentonville, Arkansas.[10] The company was founded by brothers Sam and James "Bud" Walton in nearby Rogers, Arkansas in 1962 and incorporated under Delaware General Corporation Law on October 31, 1969. It also owns and operates Sam's Club retail warehouses.[11][12]

As of October 31, 2022, Walmart has 10,586 stores and clubs in 24 countries, operating under 46 different names.[2][3][4] The company operates under the name Walmart in the United States and Canada, as Walmart de México y Centroamérica in Mexico and Central America, and as Flipkart Wholesale in India.

**Output:**
```json
{{
    "entities_and_triples": [
        "[1], company:Walmart Inc.",
        "[2], company:Wal-Mart Stores, Inc.",
        "[1] ALIAS [2]",
        "[3], location:country:United States",
        "[1] OPERATES_IN [3]",
        "[4], location:city:Bentonville",
        "[1] HEADQUARTERED_IN [4]",
        "[5], location:state:Arkansas",
        "[1] HEADQUARTERED_IN [5]",
        "[6], person:Sam Walton",
        "[1] FOUNDED_BY [6]",
        "[7], person:James Walton",
        "[8], person:Bud Walton",
        "[7] ALIAS [8]",
        "[1] FOUNDED_BY [7]",
        "[9], location:city:Rogers",
        "[10], date:year:1962",
        "[11], event:incorporated under Delaware General Corporation Law",
        "[1] INCORPORATED [11]",
        "[12], date:day:October 31",
        "[1] INCORPORATED [12]",
        "[13], date:year:1969",
        "[1] INCORPORATED [13]",
        "[14], company:Sam's Club",
        "[1] INCORPORATED [14]",
        "[15], date:day:October 31, 2022",
        "[16], quantity:10,586 stores and clubs",
        "[16] AS_OF [15]",
        "[1] HAS_QUANTITY [16]",
        "[17], quantity:24 countries",
        "[18], quantity:46 different names",
        "[1] HAS_QUANTITY [18]",
        "[18], organization:company:Walmart de México y Centroamérica",
        "[1] ALIAS [18]",
        "[19], location:country:Mexico",
        "[1] OPERATES_IN [19]",
        "[20], location:region:Central America",
        "[1] OPERATES_IN [20]",
        "[21], organization:company:Flipkart Wholesale",
        "[1] ALIAS [21]",
        "[22], location:country:India",
        "[1] OPERATES_IN [22]"
    ]
}}
```

### Task:
Your task is to perform Named Entity Recognition (NER) and knowledge graph triplet extraction on the text that follows below.

**Input:**
{input}

**Output:**

input: str


template:
### Instruction
You will shortly be asked to perform Named Entity Recognition (NER) and knowledge graph triplet extraction on the text that follows. NER involves identifying named entities in a text, and knowledge graph triplet extraction involves identifying relationships between these entities and other attributes in the text.

A knowledge graph triplet contains the three following pieces of information:
- `subject`: The main entity.
- `predicate`: The relationship type.
- `object`: The related entity.

They are represented below as `[subject]:<predicate>:[object]`.

#### Process
**Identify Named Entities**: Extract entities based on the given entity types, ensuring they appear in the order they are mentioned in the text.
**Establish Triplets**: Form triplets using the provided predicates, again in the order they appear in the text.

Your final response should follow this format:

**Output:**
```json
{{
    "entities_and_triples": [
        "[1], ENTITY_TYPE:ENTITY_NAME",
        "[1] PREDICATE [2]",
        "[1] PREDICATE [3]",
        "[2], ENTITY_TYPE:ENTITY_NAME",
        ...
    ]
}}
```

### Example:

**Entity Types:**
ORGANIZATION
COMPANY
CITY, STATE, COUNTRY, OTHER
PERSON
YEAR, MONTH, DAY, OTHER
QUANTITY
EVENT

**Predicates:**
FOUNDED_BY
HEADQUARTERED_IN
OPERATES_IN
OWNED_BY
ACQUIRED_BY
HAS_EMPLOYEE_COUNT
GENERATED_REVENUE
LISTED_ON
INCORPORATED
HAS_DIVISION
ALIAS
ANNOUNCED
HAS_QUANTITY
AS_OF

**Input:**
Walmart Inc. (formerly Wal-Mart Stores, Inc.) is an American multinational retail corporation that operates a chain of hypermarkets (also called supercenters), discount department stores, and grocery stores in the United States, headquartered in Bentonville, Arkansas.[10] The company was founded by brothers Sam and James "Bud" Walton in nearby Rogers, Arkansas in 1962 and incorporated under Delaware General Corporation Law on October 31, 1969. It also owns and operates Sam's Club retail warehouses.[11][12]

As of October 31, 2022, Walmart has 10,586 stores and clubs in 24 countries, operating under 46 different names.[2][3][4] The company operates under the name Walmart in the United States and Canada, as Walmart de México y Centroamérica in Mexico and Central America, and as Flipkart Wholesale in India.

**Output:**
```json
{{
    "entities_and_triples": [
        "[1], ORGANIZATION:COMPANY:Walmart Inc.",
        "[2], ORGANIZATION:COMPANY:Wal-Mart Stores, Inc.",
        "[1] ALIAS [2]",
        "[3], LOCATION:COUNTRY:United States",
        "[1] OPERATES_IN [3]",
        "[4], LOCATION:CITY:Bentonville",
        "[1] HEADQUARTERED_IN [4]",
        "[5], LOCATION:STATE:Arkansas",
        "[1] HEADQUARTERED_IN [5]",
        "[6], PERSON:Sam Walton",
        "[1] FOUNDED_BY [6]",
        "[7], PERSON:James Walton",
        "[8], PERSON:Bud Walton",
        "[7] ALIAS [8]",
        "[1] FOUNDED_BY [7]",
        "[9], LOCATION:CITY:Rogers",
        "[10], DATE:YEAR:1962",
        "[11], EVENT:Incorporated under Delaware General Corporation Law",
        "[1] INCORPORATED [11]",
        "[12], DATE:DAY:October 31",
        "[1] INCORPORATED [12]",
        "[13], DATE:YEAR:1969",
        "[1] INCORPORATED [13]",
        "[14], ORGANIZATION:COMPANY:Sam's Club",
        "[1] INCORPORATED [14]",
        "[15], DATE:DAY:October 31, 2022",
        "[16], QUANTITY:10,586 stores and clubs",
        "[16] AS_OF [15]",
        "[1] HAS_QUANTITY [16]",
        "[17], QUANTITY:24 countries",
        "[18], QUANTITY:46 different names",
        "[1] HAS_QUANTITY [18]",
        "[18], ORGANIZATION:COMPANY:Walmart de México y Centroamérica",
        "[1] ALIAS [18]",
        "[19], LOCATION:COUNTRY:Mexico",
        "[1] OPERATES_IN [19]",
        "[20], LOCATION:REGION:Central America",
        "[1] OPERATES_IN [20]",
        "[21], ORGANIZATION:COMPANY:Flipkart Wholesale",
        "[1] ALIAS [21]",
        "[22], LOCATION:COUNTRY:India",
        "[1] OPERATES_IN [22]"
    ]
}}
```

### Task:
Your task is to perform Named Entity Recognition (NER) and knowledge graph triplet extraction on the text that follows below. Use the provided entities and predicates as shown

**Entity Types:**
{entity_types}

**Predicates:**
{relations}

**Input:**
{input}

**Output:**

entity_types: str

relations: str

input: str


template:
Perform Named Entity Recognition (NER) and extract knowledge graph triplets from the text. NER identifies named entities of given entity types, and triple extraction identifies relationships between entities using specified predicates.

**Entity Types**:

["PERSON", "ORGANIZATION", "LOCATION", "DATE", "TIME", "MONEY", "PERCENTAGE", "PRODUCT", "EVENT", "LANGUAGE", "NATIONALITY", "RELIGION", "TITLE", "PROFESSION", "ANIMAL", "PLANT", "DISEASE", "MEDICATION", "CHEMICAL", "MATERIAL", "COLOR", "SHAPE", "MEASUREMENT", "WEATHER", "NATURAL_DISASTER", "AWARD", "LAW", "CRIME", "TECHNOLOGY", "SOFTWARE", "HARDWARE", "VEHICLE", "FOOD", "DRINK", "SPORT", "MUSIC_GENRE", "INSTRUMENT", "ARTWORK", "BOOK", "MOVIE", "TV_SHOW", "ACADEMIC_SUBJECT", "SCIENTIFIC_THEORY", "POLITICAL_PARTY", "CURRENCY", "STOCK_SYMBOL", "FILE_TYPE", "PROGRAMMING_LANGUAGE", "MEDICAL_PROCEDURE", "CELESTIAL_BODY"]

**Predicates**
["IS_EMPLOYED_BY", "LIVES_IN", "BORN_IN", "DIED_IN", "FOUNDED", "INVENTED", "WROTE", "DIRECTED", "STARRED_IN", "MARRIED_TO", "PARENT_OF", "CHILD_OF", "SIBLING_OF", "MEMBER_OF", "OWNER_OF", "CEO_OF", "STUDIED_AT", "GRADUATED_FROM", "TEACHES_AT", "SPEAKS", "CAPITAL_OF", "LOCATED_IN", "PART_OF", "CONTAINS", "PRODUCES", "CONSUMES", "EXPORTS", "IMPORTS", "ALLIES_WITH", "CONFLICTS_WITH", "PREDECESSOR_OF", "SUCCESSOR_OF", "DISCOVERED", "DEVELOPED", "FUNDED_BY", "INVESTED_IN", "COLLABORATES_WITH", "COMPETES_WITH", "ACQUIRED", "MERGED_WITH", "SPECIALIZES_IN", "PERFORMS", "AFFECTS", "CAUSES", "PREVENTS", "TREATS", "SYMPTOMS_OF", "BELONGS_TO", "DERIVED_FROM", "MEASURED_IN"]

**Text**{input}

input: str


template:
Perform Named Entity Recognition (NER) and extract knowledge graph triplets from the text. NER identifies named entities of given entity types, and triple extraction identifies relationships between entities using specified predicates.

**Entity Types**
{entity_types}

**Predicates**
{relations}

**Text**{input}

input: str


template:
**System Message:**

You are an AI assistant capable of generating Cypher queries to interact with a Neo4j knowledge graph. The knowledge graph contains information about organizations, people, locations, and their relationships, such as founders of companies, locations of companies, and products associated with companies.

**Instructions:**

When a user asks a question, you will generate a Cypher query to retrieve the relevant information from the Neo4j knowledge graph. Later, you will be given a schema which specifies the available relationships to help you construct the query. First, review the examples provided to understand the expected format of the queries.

### Example(s) - User Questions and Cypher Queries for an Academic Knowledge Graph

**User Question:**
"List all courses available in the computer science department."

**Generated Cypher Query:**
```cypher
MATCH (c:COURSE)-[:OFFERED_BY]->(d:DEPARTMENT)
WHERE d.name CONTAINS 'Computer Science'
RETURN c.id AS Course, d.name AS Department
ORDER BY c.id;
```

**User Question:**
"Retrieve all courses taught by professors who have published research on natural language processing."

**Generated Cypher Query:**
```cypher
MATCH (pr:PERSON)-[:PUBLISHED]->(p:PAPER)
MATCH (p)-[:TOPIC]->(t:TOPIC)
WHERE t.name CONTAINS 'Natural Language Processing'
MATCH (c:COURSE)-[:TAUGHT_BY]->(pr)
RETURN DISTINCT c.id AS Course, pr.name AS Professor, t.name AS Topic
ORDER BY c.id;
```

### Example(s) - User Questions and Cypher Queries for an Historical Events and Figures

**User Question:**
"List all battles that occurred in the 19th century and the generals who participated in them."

**Generated Cypher Query:**
```cypher
MATCH (b:EVENT)-[:HAPPENED_AT]->(d:DATE)
WHERE d.year >= 1800 AND d.year < 1900 AND b.type CONTAINS 'Battle'
MATCH (g:PERSON)-[:PARTICIPATED_IN]->(b)
RETURN b.name AS Battle, d.year AS Year, g.name AS General
ORDER BY d.year, b.name, g.name;
```

**User Question:**
"Find all treaties signed in Paris and the countries involved."

**Generated Cypher Query:**
```cypher
MATCH (t:EVENT)-[:HAPPENED_AT]->(l:LOCATION)
WHERE l.name CONTAINS 'Paris' AND t.type CONTAINS 'Treaty'
MATCH (c:ORGANIZATION)-[:SIGNED]->(t)
RETURN t.name AS Treaty, l.name AS Location, c.name AS Country
ORDER BY t.name, c.name;
```

Now, you will be provided with a schema for the entities and relationships in the Neo4j knowledge graph. Use this schema to construct Cypher queries based on user questions.

- **Entities:**
  - `ORGANIZATION` (e.g.: `COMPANY`, `SCHOOL`, `NON-PROFIT`, `OTHER`)
  - `COMPANY`
  - `LOCATION` (e.g.: `CITY`, `STATE`, `COUNTRY`, `OTHER`)
  - `DATE` (e.g.: `YEAR`, `MONTH`, `DAY`, `BATCH`, `OTHER`)
  - `QUANTITY`
  - `EVENT` (e.g.: `INCORPORATION`, `FUNDING_ROUND`, `ACQUISITION`, `LAUNCH`, `OTHER`)

- **Relationships:**
  - `FOUNDED_BY`
  - `HEADQUARTERED_IN`
  - `OPERATES_IN`
  - `RAISED`
  - `ACQUIRED_BY`
  - `HAS_EMPLOYEE_COUNT`
  - `GENERATED_REVENUE`
  - `LISTED_ON`
  - `INCORPORATED`
  - `HAS_DIVISION`
  - `ANNOUNCED`
  - `HAS_QUANTITY`

Use the referenced examples and schema to help you construct an appropriate Cypher query based on the following question:

**User Question:**
{input}

**Generated Cypher Query:**

input: str


template:
**System Message:**

You are an AI assistant capable of generating Cypher queries to interact with a Neo4j knowledge graph. The knowledge graph contains information about organizations, people, locations, and their relationships, such as founders of companies, locations of companies, and products associated with companies.

**Instructions:**

When a user asks a question, you will generate a Cypher query to retrieve the relevant information from the Neo4j knowledge graph. Later, you will be given a schema which specifies the available relationships to help you construct the query. First, review the examples provided to understand the expected format of the queries.

### Example(s) - User Questions and Cypher Queries for an Academic Knowledge Graph

**User Question:**
"List all courses available in the computer science department."

**Generated Cypher Query:**
```cypher
MATCH (c:COURSE)-[:OFFERED_BY]->(d:DEPARTMENT)
WHERE d.name CONTAINS 'Computer Science'
RETURN c.id AS Course, d.name AS Department
ORDER BY c.id;
```

**User Question:**
"Retrieve all courses taught by professors who have published research on natural language processing."

**Generated Cypher Query:**
```cypher
MATCH (pr:PERSON)-[:PUBLISHED]->(p:PAPER)
MATCH (p)-[:TOPIC]->(t:TOPIC)
WHERE t.name CONTAINS 'Natural Language Processing'
MATCH (c:COURSE)-[:TAUGHT_BY]->(pr)
RETURN DISTINCT c.id AS Course, pr.name AS Professor, t.name AS Topic
ORDER BY c.id;
```

### Example(s) - User Questions and Cypher Queries for an Historical Events and Figures

**User Question:**
"List all battles that occurred in the 19th century and the generals who participated in them."

**Generated Cypher Query:**
```cypher
MATCH (b:EVENT)-[:HAPPENED_AT]->(d:DATE)
WHERE d.year >= 1800 AND d.year < 1900 AND b.type CONTAINS 'Battle'
MATCH (g:PERSON)-[:PARTICIPATED_IN]->(b)
RETURN b.name AS Battle, d.year AS Year, g.name AS General
ORDER BY d.year, b.name, g.name;
```

**User Question:**
"Find all treaties signed in Paris and the countries involved."

**Generated Cypher Query:**
```cypher
MATCH (t:EVENT)-[:HAPPENED_AT]->(l:LOCATION)
WHERE l.name CONTAINS 'Paris' AND t.type CONTAINS 'Treaty'
MATCH (c:ORGANIZATION)-[:SIGNED]->(t)
RETURN t.name AS Treaty, l.name AS Location, c.name AS Country
ORDER BY t.name, c.name;
```

Now, you will be provided with a schema for the entities and relationships in the Neo4j knowledge graph. Use this schema to construct Cypher queries based on user questions.

- **Entities:**
{entity_types}

- **Relationships:**
{relations}

Use the referenced examples and schema to help you construct an appropriate Cypher query based on the following question:

**User Question:**
{input}

**Generated Cypher Query:**

input: str