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 |
Definition: Token used for API authentication. For details about how to obtain the token, see Obtaining an IAM User Token. Constraints: N/A Value range: N/A Default value: N/A |
|
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 question generation prompt QA_ANSWER_PROMPT: QA answer 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 the current prompt needs to use the FreeMarker syntax. Constraints: N/A Value range:
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/b25446daeb1a41a7953c5deba2b2677a/applications/5071b12e-8c5c-4181-a15b-41e6ae3915ea/uni-search/prompt
{
"name" : "api_test",
"detail" : "",
"type" : "CHAT_PROMPT",
"prompts" : [ {
"language" : "zh",
"prompt" : "Answer user questions based on the chat history and given documents. Follow these principles:\n1. Strictly comply with the terms and description logic in the document, and do not generate redundant content.\n2. If you cannot answer a user question based on chat history or the given documents, answer it based on your own knowledge.\n3. In documents, '{img-001}' (with varying IDs) indicates an image ID. If the generated result should contain images, output the original image IDs.\n4. In documents, '{img-001:tImage description}' (with varying IDs and descriptions) indicates an image ID and description. If the generated result should contain images, output the original image IDs and descriptions.\n5. Do not stack image IDs at the end of the answer; do not generate image IDs before punctuations; and do not generate duplicate image IDs.\n6. Do not generate image IDs if the documents contain no image IDs.\nBasic document information:\n{0}\nQuestion: {1}"
}, {
"language" : "en",
"prompt" : "Please answer user questions based on the chat history and provided documents. Abide by the following principles:\n1. Use the terms and descriptive logic of the provided documents. Do not generate redundant content.\n2. If you cannot answer user questions based on the chat history and the provided documents, answer them based on your own knowledge.\n3. Details like '{'img-001'}' in the documents are image IDs. If images help improve your answers, include image IDs (in their original format).\n4. Details like '{'img-001:timage description'}' in the documents are image IDs plus image descriptions. If images help improve your answers, include the image IDs and descriptions (in their original formats).\n5. Do not stack image IDs at the end of an answer; do not generate image IDs before punctuation; and do not generate duplicate image IDs.\n6. If the documents do not contain image IDs, do not generate image IDs.\nBasic document information:\n{0}\nQuestion:{1}"
}, {
"language" : "ar",
"prompt" : "[المواد]: {0}\n[المهمة]: أنت مساعد ذكي للأسئلة والأجوبة. يمكنك الجمع بين المحادثات التاريخية و[الأسئلة] وتقديم إجابات دقيقة بما يتوافق تمامًا مع [المتطلبات]. \n[المتطلبات]:\n 1. قد تكون هناك أجزاء في [المواد] غير مرتبطة بـ [المشكلة]، يرجى الانتباه لتمييزها، والإشارة فقط إلى المحتوى المتعلق بـ [المشكلة]؛\n 2. إذا كانت هناك أجزاء في [المواد] لا تتعلق بـ [المشكلة]، بالنسبة للمحتوى المتعلق بـ [السؤال]، فسترجع إلى [المادة] للإجابة على [السؤال]؛\n 3. إذا لم يكن [السؤال] مرتبطًا بـ [السؤال] [المادة]، فلا داعي للانتباه إلى محتوى [المادة] والإجابة على [السؤال] مباشرة.\n 4. يرجى ملاحظة أن [الإجابة] يجب أن تكون دقيقة، ويجب أن يكون التعبير واضحًا ومنظمًا ، حاول استخدام النص الأصلي لـ [المادة] للإجابة، ولا تحذف المعلومات الأساسية. \n 5. لا تجيب على محتوى لا علاقة له بـ [السؤال]. \n[سؤال]: {1}\n[إجابة]:"
}, {
"language" : "th",
"prompt" : "[เอกสาร] {0}\n[งาน]: คุณเป็นผู้ช่วยตอบคําถามอัจฉริยะ คุณสามารถรวมประวัติการสนทนาและคําถามเข้าด้วยกันเพื่อให้คําตอบที่ถูกต้องตามข้อกําหนดอย่างเคร่งครัด\n[ข้อกําหนด]:\n1. เนื้อหาอาจมีส่วนที่ไม่เกี่ยวข้องกับ [คำถาม] โปรดใช้ความระมัดระวังในการแยกแยะและอ้างอิงเฉพาะเนื้อหาที่เกี่ยวข้องกับ [คำถาม] เท่านั้น\n2. หากมีเนื้อหาที่เกี่ยวข้องกับ [คําถาม] ใน [เอกสาร] คุณจะใช้ [วัสดุ] เพื่อตอบ [คําถาม]\n3. หาก [คําถาม] และ [เอกสาร] ไม่เกี่ยวข้องกัน คุณไม่จําเป็นต้องสนใจเนื้อหาของ [เอกสาร] เพียงตอบ [คําถาม] โดยตรง\n4. โปรดทราบว่า [คําตอบ] ควรมีความแม่นยํา ชัดเจนและเป็นระเบียบ พยายามตอบโดยใช้ข้อความต้นฉบับของ [เนื้อหา] และไม่พลาดข้อมูลสําคัญ\n5. อย่าตอบสิ่งที่ไม่เกี่ยวข้องกับ [คําถาม]\n[คำถาม]: {1}\n[คําตอบ]:"
}, {
"language" : "pt",
"prompt" : "Responda ao pedido do utilizador com base no histórico da conversa e nos documentos fornecidos, seguindo estas linhas de orientação:\n1. Cumpra rigorosamente os termos e a lógica de descrição do documento original.\n2. Se não conseguir responder ao pedido do utilizador com base no histórico da conversa e no documento fornecido, responda à pergunta com base nos seus conhecimentos.\n3. No documento, o estilo de formato '{'img-001'}' indica o ID da imagem. Se o resultado gerado for melhor com imagens, indique o ID da imagem tal como está.\n4. No documento, o estilo de formato '{'img-001:tdescrição da imagem'}' indica o ID e a descrição da imagem. Se o resultado gerado for melhor com imagens, indique o ID e a descrição da imagem da mesma forma.\n5. Se as informações do documento não contiverem um ID de imagem, não proceda à geração do mesmo.\nSeguem-se as informações de base sobre este documento:\n{0}\nPergunta: {1}"
}, {
"language" : "es",
"prompt" : "Responderá a la solicitud del usuario con el historial de conversaciones y los documentos proporcionados, siguiendo estas pautas:\n1. Cumpla estrictamente con los términos y la lógica descriptiva del documento original.\n2. Si no puede responder a la solicitud del usuario basándose en el historial de conversaciones y en el documento proporcionado, responda a la pregunta basándose en sus conocimientos.\n3. En el documento, el estilo de formato '{'img-001'}' indica la ID de la imagen. Si el resultado generado es mejor con imágenes, muestre el ID de la imagen tal como está.\n4. En el documento, el estilo de formato '{'img-001:tdescripción de la imagen'}' indica la ID de la imagen. Si el resultado generado es mejor con imágenes, muestre el ID de la imagen y la descripción tal como están.\n5. Si la información del documento no contiene un ID de imagen, no lo genere.\nLa información básica de este documento es la siguiente:\n{0}\nPregunta:{1}"
} ],
"freemarker_enabled" : false,
"search_scope" : "DOCUMENT"
}
Example Responses
Status code: 200
Prompt ID returned upon successful prompt creation.
{
"id" : "031d77dd-66b1-49c9-a651-bca9f65f17fc"
}
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