|
|
|
|
|
CONTEXT_EXTRACTION_DESC = "ContextExtraction is designed to extract necessary input data required to perform a specific action from a given context." |
|
|
|
|
|
CONTEXT_EXTRACTION_SYSTEM_PROMPT = "You are an expert in extracting data required to perform an action. \ |
|
|
Given the action's name, description, and input specifications, your role is to analyze the provided context \ |
|
|
and accurately extract the required information." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONTEXT_EXTRACTION_TEMPLATE = """ |
|
|
Given a context and action information, extract input data required to perform the action in the expected JSON format. |
|
|
|
|
|
### Instructions: |
|
|
1. **Understand Action Inputs**: Carefully read the input specification for the action, including input names, types, and descriptions. |
|
|
2. **Analyze Content Dictionaries**: The context consists of multiple messages, and each message's `Content` is a dictionary. Your task is to search across these dictionaries. You SHOULD focus on the **Content** field of each message and try to extract the input data from the content. |
|
|
3. **Match Semantics, Not Just Names**: For each action input, find the most semantically similar key in the dictionaries, even if the key name is different. Focus on meaning, not just exact name match. |
|
|
4. **Extract Full Value**: Once a matching key is found for an input, extract and use its **ENTIRE VALUE** as the value for that input. |
|
|
5. **Format Output**: Return the results strictly in the expected JSON format. |
|
|
|
|
|
### Notes: |
|
|
1. If no matching value is found for an input, set it to `null`. |
|
|
2. Required inputs must not be null unless they are truly missing. |
|
|
3. Optional inputs can be `null` if no suitable match is found. |
|
|
4. Do NOT include explanations or extra text — only output the JSON. |
|
|
5. Focus exclusively on the `content` field of each message (which is a dictionary), ignore other metadata like `type`, `agent`, etc. |
|
|
|
|
|
### Context: |
|
|
{context} |
|
|
|
|
|
### Action Details: |
|
|
Action Name: {action_name} |
|
|
Action Description: {action_description} |
|
|
Input Specifications: |
|
|
```json |
|
|
{action_inputs} |
|
|
``` |
|
|
|
|
|
The extracted input data is: |
|
|
""" |
|
|
|
|
|
CONTEXT_EXTRACTION = { |
|
|
"name": "ContextExtraction", |
|
|
"description": CONTEXT_EXTRACTION_DESC, |
|
|
"system_prompt": CONTEXT_EXTRACTION_SYSTEM_PROMPT, |
|
|
"prompt": CONTEXT_EXTRACTION_TEMPLATE |
|
|
} |