A customizable API AI Agent that supports configuring HTTP method types as GET and POST APIs. Supports multiple dialogue rounds, streaming and non-streaming modes.
The agent flow chart is as follows:
Configuration information for external API service provider
promptTemplate
object
Optional
-
Configuration information for Agent ReAct template
The configuration fields for llm are as follows:
Name
Data Type
Requirement
Default Value
Description
apiKey
string
Required
-
Token for authentication when accessing large model services.
serviceName
string
Required
-
Name of the large model service
servicePort
int
Required
-
Port of the large model service
domain
string
Required
-
Domain for accessing the large model service
path
string
Required
-
Path for accessing the large model service
model
string
Required
-
Model name for accessing the large model service
maxIterations
int
Required
15
Maximum steps before ending the execution loop
maxExecutionTime
int
Required
50000
Timeout for each request to the large model, in milliseconds
maxTokens
int
Required
1000
Token limit for each request to the large model
The configuration fields for apis are as follows:
Name
Data Type
Requirement
Default Value
Description
apiProvider
object
Required
-
Information about the external API service
api
string
Required
-
OpenAPI documentation of the tool
The configuration fields for apiProvider are as follows:
Name
Data Type
Requirement
Default Value
Description
apiKey
object
Optional
-
Token for authentication when accessing external API services.
maxExecutionTime
int
Optional
50000
Timeout for each request to the API, in milliseconds
serviceName
string
Required
-
Name of the external API service
servicePort
int
Required
-
Port of the external API service
domain
string
Required
-
Domain for accessing the external API
The configuration fields for apiKey are as follows:
Name
Data Type
Requirement
Default Value
Description
in
string
Optional
none
Whether the authentication token for accessing the external API service is in the header or in the query; If the API does not have a token, fill in none.
name
string
Optional
-
The name of the token for authentication when accessing the external API service.
value
string
Optional
-
The value of the token for authentication when accessing the external API service.
The configuration fields for promptTemplate are as follows:
Name
Data Type
Requirement
Default Value
Description
language
string
Optional
EN
Language type of the Agent ReAct template, including CH and EN.
chTemplate
object
Optional
-
Agent ReAct Chinese template
enTemplate
object
Optional
-
Agent ReAct English template
The configuration fields for chTemplate and enTemplate are as follows:
Name
Data Type
Requirement
Default Value
Description
question
string
Optional
-
The question part of the Agent ReAct template
thought1
string
Optional
-
The thought1 part of the Agent ReAct template
observation
string
Optional
-
The observation part of the Agent ReAct template
thought2
string
Optional
-
The thought2 part of the Agent ReAct template
Usage Example
Configuration Information
This example configures three services demonstrating both GET and POST types of tools. The GET type tools include Amap and XZWeather, while the POST type tool is the DeepL translation. All three services need to be properly configured in the Higress service with DNS domain names and should be healthy.
Amap provides two tools, one for obtaining the coordinates of a specified location and the other for searching for points of interest near the coordinates. Document: https://lbs.amap.com/api/webservice/guide/api-advanced/newpoisearch
XZWeather provides one tool to get real-time weather conditions for a specified city, supporting results in Chinese, English, and Japanese, as well as representations in Celsius and Fahrenheit. Document: https://seniverse.yuque.com/hyper_data/api_v3/nyiu3t
DeepL provides one tool for translating given sentences, supporting multiple languages. Document: https://developers.deepl.com/docs/v/zh/api-reference/translate?fallback=true
Below are test cases. For stability, it is recommended to maintain a stable version of the large model. The example used here is qwen-max-0403: Request Example