SQL AI Agent node#
SQL Agent ใช้ฐานข้อมูล SQL เป็นแหล่งข้อมูล มันสามารถเข้าใจคำถามภาษาธรรมชาติ แปลงเป็น SQL queries ดำเนินการ queries และนำเสนอผลลัพธ์ในรูปแบบที่ใช้งานง่าย Agent นี้มีประโยชน์สำหรับการสร้าง interfaces ภาษาธรรมชาติไปยังฐานข้อมูล
อ้างอิง AI Agent สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ AI Agent node เอง
Node parameters#
กำหนดค่า SQL Agent โดยใช้ parameters ต่อไปนี้
Data Source#
เลือกฐานข้อมูลที่จะใช้เป็นแหล่งข้อมูลสำหรับ node ตัวเลือก ได้แก่:
- MySQL: เลือกตัวเลือกนี้เพื่อใช้ฐานข้อมูล MySQL
- เลือก Credential for MySQL ด้วย
- SQLite: เลือกตัวเลือกนี้เพื่อใช้ฐานข้อมูล SQLite
- คุณต้องเพิ่ม Read/Write File From Disk node ก่อน Agent เพื่ออ่านไฟล์ SQLite ของคุณ
- ป้อนชื่อ Input Binary Field ของไฟล์ SQLite ของคุณที่มาจาก Read/Write File From Disk node ด้วย
- Postgres: เลือกตัวเลือกนี้เพื่อใช้ฐานข้อมูล Postgres
- เลือก Credential for Postgres ด้วย
Postgres and MySQL Agents
หากคุณใช้ Postgres หรือ MySQL agent นี้ไม่รองรับ credential tunnel options
Prompt#
Prompt (ข้อความแจ้ง)#
เลือกวิธีที่คุณต้องการให้ node สร้าง prompt (หรือที่เรียกว่า query ของผู้ใช้ หรือ input จากแชท)
เลือกจาก:
- Take from previous node automatically (รับจาก node ก่อนหน้าโดยอัตโนมัติ): หากคุณเลือกตัวเลือกนี้ node จะคาดหวัง input จาก node ก่อนหน้าชื่อ
chatInput
- Define below (กำหนดด้านล่าง): หากคุณเลือกตัวเลือกนี้ ให้ระบุข้อความคงที่หรือ expression สำหรับเนื้อหาแบบไดนามิกเพื่อใช้เป็น prompt ในฟิลด์ Prompt (User Message)
Node options#
ปรับแต่งพฤติกรรมของ SQL Agent node โดยใช้ options เหล่านี้:
Ignored Tables#
หากคุณต้องการให้ node ละเว้นตารางใดๆ จากฐานข้อมูล ให้ป้อนรายการตารางที่คั่นด้วยจุลภาคที่คุณต้องการให้ละเว้น
หากปล่อยว่างไว้ agent จะไม่ละเว้นตารางใดๆ
Include Sample Rows#
ป้อนจำนวนแถวตัวอย่างที่จะรวมไว้ใน prompt ที่ส่งไปยัง agent ค่าเริ่มต้นคือ 3
แถวตัวอย่างช่วยให้ agent เข้าใจ schema ของฐานข้อมูล แต่ก็เพิ่มจำนวน tokens ที่ใช้ด้วย
Included Tables#
หากคุณต้องการรวมเฉพาะตารางที่ระบุจากฐานข้อมูล ให้ป้อนรายการตารางที่คั่นด้วยจุลภาคที่จะรวม
หากปล่อยว่างไว้ agent จะรวมทุกตาราง
Prefix Prompt#
ป้อนข้อความที่คุณต้องการส่งไปยัง agent ก่อนข้อความ Prompt ข้อความเริ่มต้นนี้สามารถให้บริบทและคำแนะนำเพิ่มเติมแก่ agent เกี่ยวกับสิ่งที่สามารถทำได้และทำไม่ได้ และวิธีการจัดรูปแบบการตอบกลับ
n8n เติมฟิลด์นี้ด้วยตัวอย่าง
Suffix Prompt#
ป้อนข้อความที่คุณต้องการส่งไปยัง agent หลังจากข้อความ Prompt
LangChain expressions ที่มีอยู่:
{chatHistory}
: ประวัติข้อความในการสนทนานี้ มีประโยชน์สำหรับการรักษาบริบท{input}
: มี prompt ของผู้ใช้{agent_scratchpad}
: ข้อมูลที่ต้องจำสำหรับการวนซ้ำครั้งต่อไป
n8n เติมฟิลด์นี้ด้วยตัวอย่าง
Limit#
ป้อนจำนวนผลลัพธ์สูงสุดที่จะส่งคืน
ค่าเริ่มต้นคือ 10
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.