Skip to content

ReAct AI Agent node#

ReAct Agent node ใช้ตรรกะ ReAct ReAct (reasoning and acting) รวบรวมพลังการให้เหตุผลของ chain-of-thought prompting และการสร้างแผนปฏิบัติการเข้าด้วยกัน

ReAct Agent ให้เหตุผลเกี่ยวกับงานที่กำหนด กำหนดการดำเนินการที่จำเป็น แล้วจึงดำเนินการตามนั้น มันทำตามวงจรของการให้เหตุผลและการดำเนินการจนกว่าจะทำงานเสร็จ ReAct agent สามารถแบ่งงานที่ซับซ้อนออกเป็นงานย่อยๆ จัดลำดับความสำคัญ และดำเนินการทีละอย่าง

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

No memory

ReAct agent ไม่รองรับ memory sub-nodes ซึ่งหมายความว่ามันไม่สามารถจำ prompts ก่อนหน้าหรือจำลองการสนทนาที่ต่อเนื่องได้

Node parameters#

กำหนดค่า ReAct 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#

ใช้ options เพื่อสร้างข้อความที่จะส่งไปยัง agent ในตอนเริ่มต้นการสนทนา ประเภทข้อความขึ้นอยู่กับ model ที่คุณใช้:

  • Chat models: models เหล่านี้มีแนวคิดของสามองค์ประกอบที่โต้ตอบกัน (AI, system และ human) พวกเขาสามารถรับ system messages และ human messages (prompts)
  • Instruct models: models เหล่านี้ไม่มีแนวคิดขององค์ประกอบ AI, system และ human ที่แยกจากกัน พวกเขาได้รับข้อความเนื้อหาเดียวคือ instruct message

Human Message Template#

ใช้ option นี้เพื่อขยาย user prompt นี่เป็นวิธีที่ agent จะส่งข้อมูลจากการวนซ้ำหนึ่งไปยังอีกครั้งหนึ่ง

LangChain expressions ที่มีอยู่:

  • {input}: มี user prompt
  • {agent_scratchpad}: ข้อมูลที่ต้องจำสำหรับการวนซ้ำครั้งต่อไป

Prefix Message#

ป้อนข้อความเพื่อนำหน้า list ของ tools ในตอนเริ่มต้นการสนทนา คุณไม่จำเป็นต้องเพิ่ม list ของ tools LangChain จะเพิ่ม list ของ tools โดยอัตโนมัติ

Suffix Message for Chat Model#

เพิ่มข้อความเพื่อต่อท้าย list ของ tools ในตอนเริ่มต้นการสนทนาเมื่อ agent ใช้ chat model คุณไม่จำเป็นต้องเพิ่ม list ของ tools LangChain จะเพิ่ม list ของ tools โดยอัตโนมัติ

Suffix Message for Regular Model#

เพิ่มข้อความเพื่อต่อท้าย list ของ tools ในตอนเริ่มต้นการสนทนาเมื่อ agent ใช้ regular/instruct model คุณไม่จำเป็นต้องเพิ่ม list ของ tools LangChain จะเพิ่ม list ของ tools โดยอัตโนมัติ

Return Intermediate Steps#

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

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

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

อ้างอิงเอกสาร ReAct Agents ของ LangChain สำหรับข้อมูลเพิ่มเติม

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.