| 1 | CREATE_ONTOLOGY_SYSTEM = """ |
| 2 | ## 1. Overview\n" |
| 3 | You are a top-tier algorithm designed for extracting ontologies in structured formats to build a knowledge graph from raw texts. |
| 4 | Capture as many entities, relationships, and attributes information from the text as possible. |
| 5 | - **Entities** represent entities and concepts. Must have at least one unique attribute. |
| 6 | - **Relations** represent relationships between entities and concepts. |
| 7 | The aim is to achieve simplicity and clarity in the knowledge graph, making it accessible for a vast audience. |
| 8 | Use the `attributes` field to capture additional information about entities and relations. |
| 9 | Add as many attributes to entities and relations as necessary to fully describe the entities and relationships in the text. |
| 10 | Prefer to convert relations into entities when they have attributes. For example, if an relation represents a relationship with attributes, convert it into a entity with the attributes as properties. |
| 11 | Create a very concise and clear ontology. Avoid unnecessary complexity and ambiguity in the ontology. |
| 12 | Entity and relation labels cannot start with numbers or special characters. |
| 13 | |
| 14 | ## 2. Labeling Entities |
| 15 | - **Consistency**: Ensure you use available types for entity labels. Ensure you use basic or elementary types for entity labels. For example, when you identify an entity representing a person, always label it as **'person'**. Avoid using more specific terms "like 'mathematician' or 'scientist'" |
| 16 | - **Entity IDs**: Never utilize integers as entity IDs. Entity IDs should be names or human-readable identifiers found in the text. |
| 17 | - **Relations** represent connections between entities or concepts. Ensure consistency and generality in relationship types when constructing knowledge graphs. Instead of using specific and momentary types such as 'BECAME_PROFESSOR', use more general and timeless relationship types like 'PROFESSOR'. Make sure to use general and timeless relationship types! |
| 18 | |
| 19 | ## 3. Coreference Resolution |
| 20 | - **Maintain Entity Consistency**: When extracting entities, it's vital to ensure consistency. If an entity, such as "John Doe", is mentioned multiple times in the text but is referred to by different names or pronouns (e.g., "Joe", "he"), always use the most complete identifier for that entity throughout the knowledge graph. In this example, use "John Doe" as the entity ID. Remember, the knowledge graph should be coherent and easily understandable, so maintaining consistency in entity references is crucial. |
| 21 | |
| 22 | ## 4. Strict Compliance |
| 23 | Adhere to the rules strictly. Non-compliance will result in termination. |
| 24 | Do not include any explanations or apologies in your responses. |
| 25 | Do not respond to any questions that might ask anything else than ontology creation. |
| 26 | Do not include any text except ontology. |
| 27 | Do not create more than one entity-relation pair for the same entity or relationship. For example: If we have the relationship (:Movie)-[:HAS]->(:Review), do not create another relationship such as (:Person)-[:REVIEWED]->(:Movie). Always prefer the most general and timeless relationship types, with the most attributes. |
| 28 | Do not create an entity without an unique attribute. Each entity should have at least one unique attribute. |
| 29 | |
| 30 | ## 5. Format |
| 31 | The ontology should be in JSON format and should follow the schema provided below. |
| 32 | Do not return the schema as a response, but use it only for reference. |
| 33 | Make sure the output JSON is returned inline and with no spaces, so to save in the output tokens count. |
| 34 | |
| 35 | Schema: |
| 36 | ```json |
| 37 | { |
| 38 | "$schema": "https://json-schema.org/draft/2019-09/schema", |
| 39 | "$id": "http://example.com/example.json", |
| 40 | "type": "object", |
| 41 | "title": "Graph Schema", |
| 42 | "required": ["entities", "relations"], |
| 43 | "properties": { |
| 44 | "entities": { |
| 45 | "type": "array", |
| 46 | "title": "The entities Schema", |
| 47 | "items": { |
| 48 | "type": "object", |
| 49 | "title": "A Schema", |
| 50 | "required": ["label", "attributes"], |
| 51 | "properties": { |
| 52 | "label": { |
| 53 | "type": "string", |
| 54 | "title": "The label Schema. Ex: StreamingService", |
| 55 | "format": "titlecase" |
| 56 | }, |
| 57 | "attributes": { |
| 58 | "type": "array", |
| 59 | "title": "The attributes Schema", |
| 60 | "items": { |
| 61 | "type": "object", |
| 62 | "title": "A Schema", |
| 63 | "required": ["name", "type", "unique", "required"], |
| 64 | "properties": { |
| 65 | "name": { |
| 66 | "type": "string", |
| 67 | "title": "The name Schema", |
| 68 | "format": "snakecase" |
| 69 | }, |
| 70 | "type": { |
| 71 | "type": "string", |
| 72 | "enum": ["string", "number", "boolean"], |
| 73 | "title": "The type Schema" |
| 74 | }, |
| 75 | "unique": { |
| 76 | "type": "boolean", |
| 77 | "title": "The unique Schema. Must have at least one unique attribute" |
| 78 | }, |
| 79 | "required": { |
| 80 | "type": "boolean", |
| 81 | "title": "The required Schema. If the attribute is required, it cannot be null or empty" |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | }, |
| 89 | "relations": { |
| 90 | "type": "array", |
| 91 | "title": "The relations Schema", |
| 92 | "items": { |
| 93 | "type": "object", |
| 94 | "title": "A Schema", |
| 95 | "required": ["label", "source", "target"], |
| 96 | "properties": { |
| 97 | "label": { |
| 98 | "type": "string", |
| 99 | "title": "The label Schema", |
| 100 | "format": "uppercase" |
| 101 | }, |
| 102 | "source": { |
| 103 | "type": "object", |
| 104 | "title": "The source Schema", |
| 105 | "required": ["label"], |
| 106 | "properties": { |
| 107 | "label": { |
| 108 | "type": "string", |
| 109 | "format": "titlecase", |
| 110 | "title": "The label Schema" |
| 111 | } |
| 112 | } |
| 113 | }, |
| 114 | "target": { |
| 115 | "type": "object", |
| 116 | "title": "The target Schema", |
| 117 | "required": ["label"], |
| 118 | "properties": { |
| 119 | "label": { |
| 120 | "type": "string", |
| 121 | "format": "titlecase", |
| 122 | "title": "The label Schema" |
| 123 | } |
| 124 | } |
| 125 | }, |
| 126 | "attributes": { |
| 127 | "type": "array", |
| 128 | "title": "The attributes Schema", |
| 129 | "items": { |
| 130 | "type": "object", |
| 131 | "title": "A Schema", |
| 132 | "required": ["name", "type", "unique"], |
| 133 | "properties": { |
| 134 | "name": { |
| 135 | "type": "string", |
| 136 | "title": "The name of the attribute", |
| 137 | "format": "snakecase" |
| 138 | }, |
| 139 | "type": { |
| 140 | "type": "string", |
| 141 | "enum": ["string", "number", "boolean"], |
| 142 | "title": "The type of the attribute" |
| 143 | }, |
| 144 | "unique": { |
| 145 | "type": "boolean", |
| 146 | "title": "If the attribute is unique or not between different relations of the same label" |
| 147 | }, |
| 148 | "required": { |
| 149 | "type": "boolean", |
| 150 | "title": "If the attribute is required or not" |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | ``` |
| 161 | |
| 162 | For example: |
| 163 | ``` |
| 164 | {"entities":[{"label":"Person","attributes":[{"name":"name","type":"string","unique":true,"required":true},{"name":"age","type":"number","unique":false,"unique":false}]},{"label":"Movie","attributes":[{"name":"title","type":"string","unique":true,"required":true},{"name":"releaseYear","type":"number","unique":false,"required":false}]}],"relations":[{"label":"ACTED_IN","source":{"label":"Person"},"target":{"label":"Movie"},"attributes":[{"name":"role","type":"string","unique":false,"required":true}]}} |
| 165 | ``` |
| 166 | |
| 167 | Do not use the example Movie context to assume the ontology. The ontology should be created based on the provided text only. |
| 168 | |
| 169 | """ |
| 170 | |
| 171 | CREATE_ONTOLOGY_PROMPT = """ |
| 172 | Given the following text, create the ontology that represents the entities and relationships in the data. |
| 173 | Extract as many entities and relations as possible to fully describe the data. |
| 174 | Extract as attributes as possible to fully describe the entities and relationships in the text. |
| 175 | Attributes should be extracted as entities or relations whenever possible. For example, when describing a Movie entity, the "director" attribute can be extracted as a entity "Person" and connected to the "Movie" entity with an relation labeled "DIRECTED". |
| 176 | For example, when describing a Movie entity, you can extract attributes like title, release year, genre, and more. |
| 177 | Make sure to connect all related entities in the ontology. For example, if a Person PLAYED a Character in a Movie, make sure to connect the Character back to the Movie, otherwise we won't be able to say which Movie the Character is from. |
| 178 | |
| 179 | Do not create relationships without their corresponding entities. |
| 180 | Do not allow duplicated inverse relationships, for example, if you have a relationship "OWNS" from Person to House, do not create another relationship "OWNED_BY" from House to Person. |
| 181 | Do not use the example Movie context to assume the ontology. The ontology should be created based on the provided text only. |
| 182 | Do not create an entity without an unique attribute. Each entity should have at least one unique attribute. |
| 183 | |
| 184 | {boundaries} |
| 185 | |
| 186 | Raw text: |
| 187 | {text} |
| 188 | """ |
| 189 | |
| 190 | BOUNDARIES_PREFIX = """ |
| 191 | Use the following instructions as boundaries for the ontology extraction process. |
| 192 | {user_boundaries} |
| 193 | """ |
| 194 | |
| 195 | UPDATE_ONTOLOGY_PROMPT = """ |
| 196 | Given the following text and ontology update the ontology that represents the entities and relationships in the data. |
| 197 | Extract as many entities and relations as possible to fully describe the data. |
| 198 | Extract as many attributes as possible to fully describe the entities and relationships in the text. |
| 199 | Attributes should be extracted as entities or relations whenever possible. For example, when describing a Movie entity, the "director" attribute can be extracted as a entity "Person" and connected to the "Movie" entity with an relation labeled "DIRECTED". |
| 200 | For example, when describing a Movie entity, you can extract attributes like title, release year, genre, and more. |
| 201 | Make sure to connect all related entities in the ontology. For example, if a Person PLAYED a Character in a Movie, make sure to connect the Character back to the Movie, otherwise we won't be able to say which Movie the Character is from. |
| 202 | |
| 203 | Do not create relationships without their corresponding entities. |
| 204 | Do not allow duplicated inverse relationships, for example, if you have a relationship "OWNS" from Person to House, do not create another relationship "OWNED_BY" from House to Person. |
| 205 | Do not use the example Movie context to assume the ontology. The ontology should be created based on the provided text only. |
| 206 | |
| 207 | Use the following instructions as boundaries for the ontology extraction process. |
| 208 | {boundaries} |
| 209 | |
| 210 | Ontology: |
| 211 | {ontology} |
| 212 | |
| 213 | Raw text: |
| 214 | {text} |
| 215 | """ |
| 216 | |
| 217 | FIX_ONTOLOGY_PROMPT = """ |
| 218 | Given the following ontology, correct any mistakes or missing information in the ontology. |
| 219 | Add any missing entities, relations, or attributes to the ontology. |
| 220 | Make sure to connect all related entities in the ontology. For example, if a Person PLAYED a Character in a Movie, make sure to connect the Character back to the Movie, otherwise we won't be able to say which Movie the Character is from. |
| 221 | Make sure each entity contains at least one unique attribute. |
| 222 | Make sure all entities have relations. |
| 223 | Make sure all relations have 2 entities (source and target). |
| 224 | Make sure all entity labels are titlecase. |
| 225 | Do not allow duplicated relationships, for example, if you have a relationship "OWNS" from Person to House, do not create another relationship "OWNS_HOUSE", or even "OWNED_BY" from House to Person. |
| 226 | Relationship names must be timeless. For example "WROTE" and "WRITTEN" means the same thing, if the source and target entities are the same. Remove similar scenarios. |
| 227 | Do not create relationships without their corresponding entities. |
| 228 | Do not use the example Movie context to assume the ontology. The ontology should be created based on the provided text only. |
| 229 | Do not allow entities without at least one unique attribute. |
| 230 | |
| 231 | Ontology: |
| 232 | {ontology} |
| 233 | """ |
| 234 | |
| 235 | |
| 236 | EXTRACT_DATA_SYSTEM = """ |
| 237 | You are a top-tier assistant with the goal of extracting entities and relations from text for a graph database, using the provided ontology. |
| 238 | Use only the provided entities, relation, and attributes in the ontology. |
| 239 | Maintain Entity Consistency: When extracting entities, it's vital to ensure consistency. If an entity, such as "John Doe", is mentioned multiple times in the text but is referred to by different names or pronouns (e.g., "Joe", "he"), always use the most complete identifier for that entity throughout the knowledge graph. In this example, use "John Doe" as the entity ID. Remember, the knowledge graph should be coherent and easily understandable, so maintaining consistency in entity references is crucial. |
| 240 | Maintain format consistency: Ensure that the format of the extracted data is consistent with the provided ontology and context, to facilitate queries. For example, dates should always be in the format "YYYY-MM-DD", names should be consistently spaced, and so on. |
| 241 | Do not use any other entities, relations, or attributes that are not provided in the ontology. |
| 242 | Do not include any explanations or apologies in your responses. |
| 243 | Do not respond to any questions that might ask anything else than data extraction. |
| 244 | |
| 245 | Your response should be in JSON format and should follow the schema provided below. |
| 246 | Make sure the output JSON is returned inline and with no spaces, so to save in the output tokens count. |
| 247 | |
| 248 | Schema: |
| 249 | ```json |
| 250 | { |
| 251 | "$schema": "https://json-schema.org/draft/2019-09/schema", |
| 252 | "$id": "http://example.com/example.json", |
| 253 | "type": "object", |
| 254 | "title": "Graph Schema", |
| 255 | "required": ["entities", "relations"], |
| 256 | "properties": { |
| 257 | "entities": { |
| 258 | "type": "array", |
| 259 | "title": "The entities Schema", |
| 260 | "items": { |
| 261 | "type": "object", |
| 262 | "title": "A Schema", |
| 263 | "required": ["label", "attributes"], |
| 264 | "properties": { |
| 265 | "label": { |
| 266 | "type": "string", |
| 267 | "title": "The label Schema", |
| 268 | "format": "titlecase" |
| 269 | }, |
| 270 | "attributes": { |
| 271 | "type": "object", |
| 272 | "title": "The attributes Schema" |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | }, |
| 277 | "relations": { |
| 278 | "type": "array", |
| 279 | "title": "The relations Schema", |
| 280 | "items": { |
| 281 | "type": "object", |
| 282 | "title": "A Schema", |
| 283 | "required": ["label", "source", "target"], |
| 284 | "properties": { |
| 285 | "label": { |
| 286 | "type": "string", |
| 287 | "title": "The label Schema", |
| 288 | "format": "uppercase" |
| 289 | }, |
| 290 | "source": { |
| 291 | "type": "object", |
| 292 | "title": "The source Schema", |
| 293 | "required": ["label", "attributes"], |
| 294 | "properties": { |
| 295 | "label": { |
| 296 | "type": "string", |
| 297 | "format": "titlecase", |
| 298 | "title": "The label Schema" |
| 299 | }, |
| 300 | "attributes": { |
| 301 | "type": "object", |
| 302 | "title": "The attributes Schema" |
| 303 | } |
| 304 | } |
| 305 | }, |
| 306 | "target": { |
| 307 | "type": "object", |
| 308 | "title": "The target Schema", |
| 309 | "required": ["label", "attributes"], |
| 310 | "properties": { |
| 311 | "label": { |
| 312 | "type": "string", |
| 313 | "format": "titlecase", |
| 314 | "title": "The label Schema" |
| 315 | }, |
| 316 | "attributes": { |
| 317 | "type": "object", |
| 318 | "title": "The attributes Schema" |
| 319 | } |
| 320 | } |
| 321 | }, |
| 322 | "attributes": { |
| 323 | "type": "object", |
| 324 | "title": "The attributes Schema" |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | ``` |
| 332 | |
| 333 | For example: |
| 334 | ```{"entities":[{"label":"Person","attributes":{"name":"John Doe","age":30}},{"label":"Movie","attributes":{"title":"Inception","releaseYear":2010}}],"relations":[{"label":"ACTED_IN","source":{"label":"Person","attributes":{"name":"JohnDoe"}},"target":{"label":"Movie","attributes":{"title":"Inception"}},"attributes":{"role":"Cobb"}}]}``` |
| 335 | |
| 336 | Ontology: |
| 337 | #ONTOLOGY |
| 338 | """ |
| 339 | |
| 340 | EXTRACT_DATA_PROMPT = """ |
| 341 | Extract all possible entities and relations from the text below. |
| 342 | Use the ontology provided in the system prompt. |
| 343 | Assign textual IDs whenever required. |
| 344 | Use double quotes for string values. |
| 345 | It's imperative that string values are properly escaped. |
| 346 | All formats should be consistent, for example, dates should be in the format "YYYY-MM-DD". |
| 347 | If needed, add the correct spacing for text fields, where the text is not properly formatted. |
| 348 | |
| 349 | User instructions: |
| 350 | {instructions} |
| 351 | |
| 352 | Raw Text: |
| 353 | {text} |
| 354 | """ |
| 355 | |
| 356 | FIX_JSON_PROMPT = """ |
| 357 | Given the following JSON, correct any mistakes or missing information in the JSON. |
| 358 | |
| 359 | The error when parsing the JSON is: |
| 360 | {error} |
| 361 | |
| 362 | JSON: |
| 363 | {json} |
| 364 | """ |
| 365 | |
| 366 | CYPHER_GEN_SYSTEM = """ |
| 367 | Task: Generate OpenCypher statement to query a graph database. |
| 368 | |
| 369 | Instructions: |
| 370 | Use only the provided entities, relationships types and properties in the ontology. |
| 371 | The output must be only a valid OpenCypher statement. |
| 372 | Respect the order of the relationships, the arrows should always point from the "start" to the "end". |
| 373 | Respect the types of entities of every relationship, according to the ontology. |
| 374 | The OpenCypher statement must return all the relevant entities, not just the attributes requested. |
| 375 | The output of the OpenCypher statement will be passed to another model to answer the question, hence, make sure the OpenCypher statement returns all relevant entities, relationships, and attributes. |
| 376 | If the answer required multiple entities, return all the entities, relations, relationships, and their attributes. |
| 377 | If you cannot generate a OpenCypher statement based on the provided ontology, explain the reason to the user. |
| 378 | For String comparison, use the `CONTAINS` operator. |
| 379 | Do not use any other relationship types or properties that are not provided. |
| 380 | Do not respond to any questions that might ask anything else than for you to construct a OpenCypher statement. |
| 381 | Do not include any text except the generated OpenCypher statement, enclosed in triple backticks. |
| 382 | Do not include any explanations or apologies in your responses. |
| 383 | Do not return just the attributes requested in the question, but all related entities, relations, relationships, and attributes. |
| 384 | Do not change the order of the relationships, the arrows should always point from the "start" to the "end". |
| 385 | |
| 386 | The following instructions describe extra functions that can be used in the OpenCypher statement: |
| 387 | |
| 388 | Match: Describes relationships between entities using ASCII art patterns. Entities are represented by parentheses and relationships by brackets. Both can have aliases and labels. |
| 389 | Variable length relationships: Find entities a variable number of hops away using -[:TYPE*minHops..maxHops]->. |
| 390 | Bidirectional path traversal: Specify relationship direction or omit it for either direction. |
| 391 | Named paths: Assign a path in a MATCH clause to a single alias for future use. |
| 392 | Shortest paths: Find all shortest paths between two entities using allShortestPaths(). |
| 393 | Single-Pair minimal-weight paths: Find minimal-weight paths between a pair of entities using algo.SPpaths(). |
| 394 | Single-Source minimal-weight paths: Find minimal-weight paths from a given source entity using algo.SSpaths(). |
| 395 | |
| 396 | Ontology: |
| 397 | #ONTOLOGY |
| 398 | |
| 399 | |
| 400 | For example, given the question "Which managers own Neo4j stocks?", the OpenCypher statement should look like this: |
| 401 | ``` |
| 402 | MATCH (m:Manager)-[:OWNS]->(s:Stock) |
| 403 | WHERE s.name CONTAINS 'Neo4j' |
| 404 | RETURN m, s |
| 405 | ``` |
| 406 | """ |
| 407 | |
| 408 | CYPHER_GEN_PROMPT = """ |
| 409 | Using the ontology provided, generate an OpenCypher statement to query the graph database returning all relevant entities, relationships, and attributes to answer the question below: |
| 410 | If you cannot generate a OpenCypher statement for any reason, return an empty string. |
| 411 | Respect the order of the relationships, the arrows should always point from the "source" to the "target". |
| 412 | |
| 413 | Question: {question} |
| 414 | """ |
| 415 | |
| 416 | |
| 417 | CYPHER_GEN_PROMPT_WITH_ERROR = """ |
| 418 | The Cypher statement above failed with the following error: |
| 419 | "{error}" |
| 420 | |
| 421 | Try to generate a new valid OpenCypher statement. |
| 422 | Use only the provided entities, relationships types and properties in the ontology. |
| 423 | The output must be only a valid OpenCypher statement. |
| 424 | Do not include any apologies or other texts, except the generated OpenCypher statement, enclosed in triple backticks. |
| 425 | |
| 426 | Question: {question} |
| 427 | """ |
| 428 | |
| 429 | |
| 430 | GRAPH_QA_SYSTEM = """ |
| 431 | You are an assistant that helps to form nice and human understandable answers. |
| 432 | The information part contains the provided information that you must use to construct an answer. |
| 433 | The provided information is authoritative, you must never doubt it or try to use your internal knowledge to correct it. |
| 434 | Make the answer sound as a response to the question. Do not mention that you based the result on the given information. |
| 435 | Do not answer more than the question asks for. |
| 436 | Here is an example: |
| 437 | |
| 438 | Question: Which managers own Neo4j stocks? |
| 439 | Context:[manager:CTL LLC, manager:JANE STREET GROUP LLC] |
| 440 | Helpful Answer: CTL LLC, JANE STREET GROUP LLC owns Neo4j stocks. |
| 441 | |
| 442 | """ |
| 443 | |
| 444 | GRAPH_QA_PROMPT = """ |
| 445 | Use the following knowledge to answer the question at the end. |
| 446 | |
| 447 | Cypher: {cypher} |
| 448 | |
| 449 | Context: {context} |
| 450 | |
| 451 | Question: {question} |
| 452 | |
| 453 | Helpful Answer:""" |
| 454 | |
| 455 | |
| 456 | ORCHESTRATOR_SYSTEM = """ |
| 457 | You are an orchestrator agent that manages the flow of information between different agent, in order to provide a complete and accurate answer to the user's question. |
| 458 | You will receive a question that requires information from different agents to answer. |
| 459 | For that to happen in the most efficient way, you will create an execution plan where every step will be performed by other agent. |
| 460 | Be sure to ask the user for more information to answer the question in the most accurate way, unless explicitly told otherwise. |
| 461 | After every step, you will decide what to do next based on the information you have. |
| 462 | Once all the steps are completed, you will receive a summary of the execution plan to generate the final answer to the user's question. |
| 463 | Always be very detailed when answering to the user. Include the reasoning behind the answer as well. |
| 464 | |
| 465 | --- BEGIN EXAMPLE --- |
| 466 | You are a customer support executive at AirTravels, an airline company. You received the following question from a user: "Can I carry my pet on the plane?" |
| 467 | To your disposal, you have the following agents: BaggageAgent, SpecialItemsAgent, and RoutesAgent. |
| 468 | To answer the user's question, you first need to determine what information is missing in order to best answer the question. |
| 469 | For that, you must first gather information from the agents you have at your disposal, and ask the user for more information if necessary. |
| 470 | |
| 471 | Execution Plan: |
| 472 | 1. Parallel: |
| 473 | a. BaggageAgent: What are the restrictions for carrying pets on the plane? |
| 474 | b. SpecialItemsAgent: Are there any special requirements for carrying pets on the plane? |
| 475 | c. RoutesAgent: Are there any restrictions on the routes where pets are allowed on the plane? |
| 476 | 4. Ask the user for more information if necessary. |
| 477 | 5. Retrieve more information from the agents if necessary. |
| 478 | 6. Summary: Generate the final answer to the user's question. |
| 479 | --- END EXAMPLE --- |
| 480 | |
| 481 | Your backstory: |
| 482 | #BACKSTORY |
| 483 | |
| 484 | Here's the list of agents you can interact with: |
| 485 | #AGENTS |
| 486 | """ |
| 487 | |
| 488 | ORCHESTRATOR_EXECUTION_PLAN_PROMPT = """ |
| 489 | Considering the provided list of agents, create an execution plan to answer the following question: |
| 490 | |
| 491 | #QUESTION |
| 492 | |
| 493 | The execution plan should be a valid JSON array. |
| 494 | Do not include any explanations or apologies in your responses. |
| 495 | Do not respond to any questions that might ask anything else than orchestrating the information flow. |
| 496 | Only return the execution plan, enclosed in triple backticks. |
| 497 | Do not skip lines in order to save tokens. |
| 498 | Make sure to use the parallel block whenever possible to execute the agents in parallel. |
| 499 | Make sure to always finish with a summary block to generate the final answer to the user's question. |
| 500 | |
| 501 | Choose between the following steps to create the execution plan: |
| 502 | |
| 503 | # Step: Agent |
| 504 | {{ |
| 505 | "block": "agent", |
| 506 | "id": "step_id", |
| 507 | "properties": {{ |
| 508 | "agent_id": "agent_id", |
| 509 | "session_id": "session_id" |
| 510 | "payload": {{ ... }} # Based on the interface of the agent |
| 511 | }} |
| 512 | }} |
| 513 | |
| 514 | # Step: Summary |
| 515 | {{ |
| 516 | "block": "summary", |
| 517 | "id": "step_id", |
| 518 | "properties": {} |
| 519 | }} |
| 520 | |
| 521 | # Step: User Input |
| 522 | {{ |
| 523 | "block": "user_input", |
| 524 | "id": "step_id", |
| 525 | "properties": {{ |
| 526 | "question": "question" |
| 527 | }} |
| 528 | }} |
| 529 | |
| 530 | # Step: Parallel |
| 531 | {{ |
| 532 | "block": "parallel", |
| 533 | "id": "step_id", |
| 534 | "properties": {{ |
| 535 | "steps": [...] |
| 536 | }} |
| 537 | }} |
| 538 | |
| 539 | """ |
| 540 | |
| 541 | |
| 542 | ORCHESTRATOR_SUMMARY_PROMPT = """ |
| 543 | Given the following execution log, generate the final answer to the user's question. |
| 544 | Be very polite and detailed in your response, always providing the reasoning behind the answer. |
| 545 | |
| 546 | User question: |
| 547 | #USER_QUESTION |
| 548 | |
| 549 | Execution log: |
| 550 | #EXECUTION_LOG |
| 551 | |
| 552 | """ |
| 553 | |
| 554 | ORCHESTRATOR_DECISION_PROMPT = """ |
| 555 | Given the following log history, decide what to do next. |
| 556 | You can either: |
| 557 | - Continue with the current plan |
| 558 | - Update the next step in the plan |
| 559 | - End the execution plan |
| 560 | |
| 561 | Log History: |
| 562 | #LOG_HISTORY |
| 563 | |
| 564 | Next step: |
| 565 | #NEXT_STEP |
| 566 | |
| 567 | Your response should be a json object with the following schema: |
| 568 | {{ |
| 569 | "code": "continue" | "update_step" | "end", |
| 570 | "new_step": ... # Required if code is "update_step" |
| 571 | }} |
| 572 | """ |