Create Agent Prompt

To create an agent prompt follow the following steps:

  • On the Prompt Playground, start by clicking Add new and selecting an Agent task from the available tasks list.

  • Agent prompt consists of ReAct prompting instructions and the Agent tools. You can see the Tools tab enabled when creating an Agent prompt.

  • Here is an example of Agent prompt

// Answer the questions as best you can. You have access to the following tools:

{tools}

Use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
Thought: check if you can return the final answer.
... (this Thought/Action/Action Input/Observation can repeat 5 times)
Final Answer: the final answer.

Begin!

Question: {question}
Thought: {agent_scratchpad}

Special variables: Following variables are comsidered as special or predefined system variables for agent prompt.

  • tools: repository of tool objects available to the agent for taking actions.

  • tool_names: list of all the tool names

  • question: the user query to trigger agent processing

  • agent_scratchpad: used by agent to intermediate values/steps used in chain (linked-chain or functions).

Configuring Agent Tools

To configure an agent tool, go to the "Tools" tab on the prompt, and start by selecting a tool type. Currently, following tool types are supported:

Dataset (Vector Store)

Ingestion of your data into the vector store happens during recipe "run" phase when the data ingestion pipeline is executed. You can select from an existing dataset that has been ingested into the vector store.

  • Context Generation using Vector Search

You can select from the following retrieval options to obtain information from the vector store.

  1. Use embedding chunks

  2. Summarize chunks

  3. Use document text for matching embeddings

You can provide Top-K also enable reranking of retrieved embeddings. To enable reranking, you must configure the reranker LLM credentials in the Organization settings.

  • Advanced Query Reconstruction

Additionally, you can select advanced query reconstruction options to enable query rewrite for optimized and accurate search results. Refer to Dataset for details.

  1. Multi query rewrite: Enhance your search with multiple variations of your query to capture diverse perspectives and improve retrieval accuracy.

  2. Query expansion: Enriches query by automatically adding related terms or phrases to retrieve more comprehensive and relevant results. Expand your search query to include additional information that can assist in answering your query effectively.

Prompt (LLM)

Prompt tool enables an agent to perform actions using another LLM, with prompt instructions. You can select one of the existing prompts from the list, and configure it as a tool. The LLM associated with the prompt will be used to carry out the actions for the tool as per the prompt instructions.

  • Input Schema: For the selected prompt, an input schema is automatically generated. The LLM configured as Natural Language Assistant in the Organization setting is used for this schema generation. You have an option to edit the schema if necessary.

REST API

You can have an agent invoke a REST API as a tool. To configure this tool, you need to provide a REST API URL and method (POST, GET, PUT) .

  • REST URL: The REST URL is the endpoint address where the REST API is hosted. This URL specifies the exact location of the resource that you want to interact with via the API.

Example:

http://ec2-11-111-111-111.compute-1.amazonaws.com:8000/api/extensions/dummy_api
  • Method: This defines the type of HTTP request method to use when calling the API. supported methods include GET, POST and PUT.

  • Input Schema: This is the structure of the expected input data, often defined in a JSON format. It specifies the required fields and data types. You can input this value, or have it auto-generated using Setup Schema option.

Example:

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The full name of the individual or entity."
    }
  },
  "required": [
    "name"
  ]
}
  • Setup Schema: You have option to automatically generate the schema for the REST API using the test payload. The LLM configured as Natural Language Assistant in the Organization setting is used for this schema generation. You have an option to edit the schema if necessary.

  • Input Test Payload: This is a sample payload that adheres to the input schema and is used to test the API endpoint. It demonstrates the format and type of data that should be sent in a request.

Example

{"name":"John"}
  • URL Credentials: These are the authentication details required to access the API.

    • User name(optional)

    • User password

    • API Token

Lambda:

The Lambda tool in agent prompts allows you to configure and invoke AWS Lambda functions directly from the agent interface. This means you can invoke serverless functions seamlessly to perform agent actions as a tool.

  • Lambda ARN: Enter the Amazon Resource Name (ARN) of the Lambda function you want to invoke. This uniquely identifies the Lambda function within AWS.

  • Input Schema: Specify the JSON schema that outlines the structure of the input data your Lambda function expects. This includes defining the required fields and their data types. You can input this value, or have it auto-generated using Setup Schema option.

{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "email": {
            "type": "string",
            "description": "The user's email address."
        },
        "pii": {
            "type": "object",
            "properties": {
                "age": {
                    "type": "integer",
                    "description": "The user's age."
                },
                "location": {
                    "type": "string",
                    "description": "The user's current location."
                }
            },
            "required": [
                "age",
                "location"
            ],
            "description": "Personal Identifiable Information including age and location."
        },
        "taxes": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "year": {
                        "type": "integer",
                        "description": "The year the tax record pertains to."
                    }
                },
                "required": [
                    "year"
                ],
                "description": "An array of tax records by year."
            },
            "description": "A collection of tax information for different years."
        }
    },
    "required": [
        "email",
        "pii",
        "taxes"
    ],
    "description": "A schema for user information including email, personal details, and tax records."
}
  • Setup Schema: You have option to automatically generate the schema for the Lambda function using the test payload. The LLM configured as Natural Language Assistant in the Organization setting is used for this schema generation. You have an option to edit the schema if necessary.

Example:

{
  "email": "john@example.com",
  "pii": {
    "age": 30,
    "location": "California"
  },
  "taxes": [
    {
      "year": 2022
    }
  ]
}

  • Input Test Payload: This is a sample payload that will be used to test the Lambda function. This helps ensure the function behaves as expected with the provided input.

Example:

{
  "email": "john@example.com",
  "pii": {
    "age": 30,
    "location": "California"
  },
  "taxes": [
    {
      "year": 2022
    }
  ]
}

  • Overwrite Credentials: By default, the AWS credentials configured in Organization settings will be used to invoke AWS resource. However, if needed, you can provide alternate AWS credentials to invoke the Lambda function.

Last updated