Skip to content

Conversational AI Agent node#

Conversational Agent มีการสนทนาที่เหมือนมนุษย์ มันสามารถรักษาบริบท เข้าใจเจตนาของผู้ใช้ และให้คำตอบที่เกี่ยวข้อง Agent นี้มักใช้สำหรับการสร้าง chatbots, virtual assistants และระบบสนับสนุนลูกค้า

Conversational Agent อธิบาย tools ใน system prompt และแยกวิเคราะห์ JSON responses สำหรับการเรียก tool หาก AI model ที่คุณต้องการไม่รองรับการเรียก tool หรือคุณกำลังจัดการกับการโต้ตอบที่ง่ายกว่า agent นี้เป็นตัวเลือกทั่วไปที่ดี มันมีความยืดหยุ่นมากกว่า แต่อาจมีความแม่นยำน้อยกว่า Tools Agent

อ้างอิง AI Agent สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ AI Agent node เอง

คุณสามารถใช้ agent นี้กับ Chat Trigger node ได้ เชื่อมต่อ memory sub-node เพื่อให้ผู้ใช้สามารถสนทนาต่อเนื่องด้วยคำถามหลายๆ ครั้งได้ Memory จะไม่คงอยู่ระหว่าง session

Node parameters#

กำหนดค่า Conversational Agent โดยใช้ parameters ต่อไปนี้

Prompt#

Prompt (ข้อความแจ้ง)#

เลือกวิธีที่คุณต้องการให้ node สร้าง prompt (หรือที่เรียกว่า query ของผู้ใช้ หรือ input จากแชท)

เลือกจาก:

  • Take from previous node automatically (รับจาก node ก่อนหน้าโดยอัตโนมัติ): หากคุณเลือกตัวเลือกนี้ node จะคาดหวัง input จาก node ก่อนหน้าชื่อ chatInput
  • Define below (กำหนดด้านล่าง): หากคุณเลือกตัวเลือกนี้ ให้ระบุข้อความคงที่หรือ expression สำหรับเนื้อหาแบบไดนามิกเพื่อใช้เป็น prompt ในฟิลด์ Prompt (User Message)

Require Specific Output Format#

Output Format (รูปแบบ Output)#

พารามิเตอร์นี้ควบคุมว่าคุณต้องการให้ node กำหนดรูปแบบ output ที่เฉพาะเจาะจงหรือไม่ เมื่อเปิดใช้งาน n8n จะแจ้งให้คุณเชื่อมต่อ output parser หนึ่งในรายการต่อไปนี้เข้ากับ node:

Node options#

ปรับแต่งพฤติกรรมของ Conversational Agent node โดยใช้ options เหล่านี้:

Human Message#

บอก agent เกี่ยวกับ tools ที่สามารถใช้และเพิ่มบริบทให้กับ input ของผู้ใช้

คุณต้องรวม expressions และ variable เหล่านี้:

  • {tools}: LangChain expression ที่ให้สตริงของ tools ที่คุณเชื่อมต่อกับ Agent ให้บริบทหรือคำอธิบายเกี่ยวกับว่าใครควรใช้ tools และควรใช้อย่างไร
  • {format_instructions}: LangChain expression ที่ให้ schema หรือ format จาก output parser node ที่คุณเชื่อมต่อ เนื่องจาก instructions เองเป็นบริบท คุณไม่จำเป็นต้องให้บริบทสำหรับ expression นี้
  • {{input}}: LangChain variable ที่มี prompt ของผู้ใช้ variable นี้จะเติมค่าด้วยค่าของ parameter Prompt ให้บริบทว่านี่คือ input ของผู้ใช้

นี่คือตัวอย่างวิธีที่คุณอาจใช้สตริงเหล่านี้:

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
TOOLS
------
Assistant can ask the user to use tools to look up information that may be helpful in answering the user's original question. The tools the human can use are:

{tools}

{format_instructions}

USER'S INPUT
--------------------
Here is the user's input (remember to respond with a markdown code snippet of a JSON blob with a single action, and NOTHING else):

{{input}}

System Message#

System Message (ข้อความระบบ)#

หากคุณต้องการส่งข้อความไปยัง agent ก่อนเริ่มการสนทนา ให้ป้อนข้อความที่คุณต้องการส่ง

ใช้ตัวเลือกนี้เพื่อชี้นำการตัดสินใจของ agent

Max Iterations#

Max Iterations (จำนวนรอบสูงสุด)#

ป้อนจำนวนครั้งที่โมเดลควรทำงานเพื่อพยายามสร้างคำตอบที่ดีจาก prompt ของผู้ใช้

ค่าเริ่มต้นคือ 10

Return Intermediate Steps#

Return Intermediate Steps (ส่งคืนขั้นตอนกลาง)#

เลือกว่าจะรวมขั้นตอนกลางที่ agent ใช้ในการประมวลผลไว้ใน output สุดท้ายหรือไม่ (เปิด) หรือไม่รวม (ปิด)

สิ่งนี้อาจมีประโยชน์สำหรับการปรับแต่งพฤติกรรมของ agent เพิ่มเติมโดยอิงตามขั้นตอนที่ดำเนินการ

Templates and examples#

อ้างอิงส่วน Templates and examples ของ AI Agent node หลัก

Common issues#

สำหรับคำถามหรือปัญหาทั่วไปและแนวทางแก้ไขที่แนะนำ โปรดดูที่ Common issues

AI glossary#

  • completion: Completions are the responses generated by a model like GPT.
  • hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
  • vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
  • vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.