Creating a Prompt
Function
Create a prompt.
If the prompt being created requires FreeMarker syntax, prompt detection needs to be performed first to avoid non-existent variables. FreeMarker manual: https://freemarker.apache.org/docs/ref.html
URI
POST /v1/{project_id}/applications/{application_id}/uni-search/prompt
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition: Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. Constraints: N/A Value range: The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter. Default value: N/A |
application_id |
Yes |
String |
Definition: Application ID. For details about how to obtain the application ID, see Obtaining an Application ID. Constraints: Character string Value range: The value can contain 1 to 64 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed. The value must start with a letter. Default value: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token(X-Auth-Token) |
Yes |
String |
Token used for API authentication. For details about how to obtain a token, see [Obtaining an IAM User Token] (https://support.huaweicloud.com/en-us/api-iam/iam_30_0001.html). |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Definition: Prompt name. Constraints: N/A Value range: The value can contain a maximum of 64 characters. It must start with a letter or digit and can contain letters, digits, and underscores (_). Default value: N/A |
detail |
No |
String |
Definition: Prompt description. Constraints: N/A Value range: Enter up to 100 characters. Default value: N/A |
type |
Yes |
String |
Definition: Prompt types DEFAULT_CHAT_PROMPT: default RAG prompt DEFAULT_QA_ANSWER_PROMPT: default QA answer generation prompt The DEFAULT_QA_QUESTION_PROMPT: default QA question generation prompt CHAT_PROMPT: RAG prompt QA_QUESTION_PROMPT: QA answer generation prompt QA_ANSWER_PROMPT: QA question generation prompt MLLM_PROMPT: multimodal model prompt. Value range:
|
prompts |
No |
Array of PromptItem objects |
Definition: Multi-language content of a prompt. Constraints: N/A Value range: N/A Default value: N/A |
freemarker_enabled |
No |
Boolean |
Definition: Whether FreeMarker syntax needs to be used for the current prompt. Constraints: N/A Value range: true/false Default value: false |
search_scope |
No |
String |
Definition: This parameter is required when freeMarkerEnabled is set to true. It is used to determine the reference document source of the current prompt. The options are DOCUMENT and WEB. Constraints: This parameter is required when freeMarkerEnabled is set to true. Value range:
Default value: DOCUMENT |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
language |
No |
String |
Definition: Language name. Constraints: N/A Value range:
Default value: N/A |
prompt |
No |
String |
Definition: Prompt. Constraints: N/A Value range: The value contains a maximum of 8,192 characters. Default value: N/A |
attention |
No |
String |
Definition: Notes. Constraints: N/A Value range: The maximum length is 65,535 characters. Default value: N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
id |
String |
Definition: Prompt ID. Value range: N/A |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Definition: Value range: N/A |
error_msg |
String |
Definition: Error message. Value range: N/A |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Definition: Value range: N/A |
error_msg |
String |
Definition: Error message. Value range: N/A |
Example Requests
Create a prompt.
/v1/{project_id}/applications/{application_id}/uni-search/prompt { "name" : "Prompt name", "detail" : "Prompt description", "type" : "chat_prompt", "prompts" : [ { "prompt" : "Chinese prompt", "language" : "zh" }, { "prompt" : "English prompt", "language" : "en" }, { "prompt" : "Arabic prompt", "language" : "ar" }, { "prompt" : "Thai prompt", "language" : "th" }, { "prompt" : "Spanish prompt", "language" : "es" }, { "prompt" : "Portuguese prompt", "language" : "pt" } ] }
Example Responses
None
Status Codes
Status Code |
Description |
---|---|
200 |
Prompt ID returned upon successful prompt creation. |
400 |
Incorrect request body parameter. |
500 |
Internal error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot