Lý thuyết
45 phút
Bài 9/15

Stack AI

Enterprise AI workflows với Stack AI platform

🏢 Stack AI

Stack AI - nền tảng enterprise cho AI workflows và agents.

Giới thiệu Stack AI

What is Stack AI?

Text
1Enterprise AI platform:
2- Visual workflow builder
3- LLM orchestration
4- Knowledge bases
5- Team collaboration
6- Enterprise security

Key Features

Text
1✅ Visual AI workflow builder
2✅ Multiple LLM support
3✅ Document processing
4✅ RAG (Retrieval Augmented Generation)
5✅ API endpoints
6✅ Team collaboration
7✅ Enterprise security
8✅ Pre-built templates

Use Cases

Text
1- Document Q&A systems
2- Customer support agents
3- Data analysis workflows
4- Content generation
5- Code assistance
6- Research automation

Getting Started

Account Setup

Text
11. Go to stack-ai.com
22. Sign up (free tier available)
33. Create workspace
44. Create first project

Interface Overview

Text
1┌────────────────────────────────────────────────────┐
2│ [Project] [Deploy] [Share] [Settings] │
3├──────────┬─────────────────────────────────────────┤
4│ Nodes │ │
5│ ──────── │ WORKFLOW CANVAS │
6│ Input │ │
7│ LLM │ ┌────┐ ┌────┐ ┌────┐ │
8│ Output │ │In │───▶│LLM │───▶│Out │ │
9│ Logic │ └────┘ └────┘ └────┘ │
10│ Data │ │
11│ Tools │ │
12└──────────┴─────────────────────────────────────────┘

Core Concepts

Nodes

Text
1Input Nodes:
2- Text Input: User query
3- File Input: Documents
4- API Input: External data
5
6Processing Nodes:
7- LLM: Generate responses
8- Vector DB: Search documents
9- Code: Custom logic
10- Condition: Branching
11
12Output Nodes:
13- Text Output: Responses
14- API Output: Send data
15- File Output: Generate files

Connections

Text
1Data flows through connections:
2- Drag from output port
3- Connect to input port
4- Data transforms between nodes

Variables

Text
1Pass data between nodes:
2- {{input.text}}: User input
3- {{llm.output}}: LLM response
4- {{search.results}}: Search results

Building Document Q&A

Step 1: Knowledge Base

Text
1Create knowledge base:
21. Go to Knowledge section
32. Click "New Knowledge Base"
43. Name it (e.g., "Company Docs")
54. Upload documents:
6 - PDF
7 - Word
8 - Text
9 - Web pages
105. Process documents

Step 2: Create Workflow

Text
1Workflow structure:
2Input → Search KB → LLM → Output
3
41. Add Text Input node
52. Add Knowledge Base Search node
63. Add LLM node
74. Add Text Output node
85. Connect nodes

Step 3: Configure Search

Text
1Knowledge Base Search node:
2- Select knowledge base
3- Query: {{input.text}}
4- Top K: 5 (number of results)
5- Threshold: 0.7 (relevance cutoff)

Step 4: Configure LLM

Text
1LLM node:
2Model: gpt-4o-mini (or preferred)
3
4System prompt:
5"You are a helpful assistant.
6Answer questions based on the provided context.
7If the answer isn't in the context, say so.
8
9Context:
10{{search.results}}"
11
12User prompt:
13"{{input.text}}"

Step 5: Test & Deploy

Text
1Test:
21. Click "Test" button
32. Enter sample question
43. Check response quality
54. Adjust parameters
6
7Deploy:
81. Click "Deploy"
92. Get API endpoint
103. Integrate into app

Advanced Workflows

Multi-Step Reasoning

Text
1Complex task breakdown:
2
3Input → Analyze Intent
4
5 ┌────┴────┐
6 ↓ ↓
7 Question Action
8 ↓ ↓
9 Search Execute
10 ↓ ↓
11 LLM Confirm
12 ↓ ↓
13 └────┬────┘
14
15 Output

Agent with Tools

Text
1Give LLM access to tools:
2
31. LLM decides what tool to use
42. Tool executes
53. Result back to LLM
64. LLM generates final response
7
8Tools:
9- Search knowledge base
10- Query database
11- Call external API
12- Calculate
13- Generate content

Conditional Logic

Text
1Condition node:
2If {{llm.confidence}} > 0.8
3 → Direct response
4Else
5 → Ask clarifying question
6
7If {{intent}} == "complaint"
8 → Escalation flow
9Else
10 → Standard flow

Document Processing

Upload & Process

Text
1Document pipeline:
21. Upload documents
32. Extract text (OCR if needed)
43. Chunk into sections
54. Generate embeddings
65. Store in vector DB

Document Types

Text
1Supported:
2- PDF (text & scanned)
3- Word documents
4- PowerPoint
5- Excel/CSV
6- HTML
7- Plain text
8- Images (with OCR)

Processing Options

Text
1Chunking:
2- Size: 500-1000 tokens
3- Overlap: 100-200 tokens
4- By paragraph/section
5
6Embedding:
7- OpenAI embeddings
8- Cohere
9- Custom models

API Integration

External APIs

Text
1HTTP Request node:
2- URL: API endpoint
3- Method: GET/POST
4- Headers: Authentication
5- Body: Request data
6
7Parse response:
8- JSON parsing
9- Extract fields
10- Error handling

Webhook Trigger

Text
1Start workflow from external event:
21. Add Webhook Input node
32. Get webhook URL
43. Configure in external system
54. Workflow triggers on webhook

API Output

Text
1Expose workflow as API:
21. Deploy workflow
32. Get API endpoint
43. Call from your app
5
6Request:
7POST /api/workflow/{id}
8{
9 "input": "User question here"
10}
11
12Response:
13{
14 "output": "Answer here"
15}

Team Collaboration

Workspaces

Text
1Organize:
2- Create workspaces per team
3- Invite members
4- Set permissions
5- Share workflows

Permissions

Text
1Roles:
2- Owner: Full access
3- Editor: Build & modify
4- Viewer: Run only
5- API: API access only

Enterprise Features

Security

Text
1Enterprise security:
2- SSO integration
3- SOC 2 compliance
4- Data encryption
5- Private cloud option
6- Audit logs

Custom Models

Text
1Bring your own:
2- Azure OpenAI
3- AWS Bedrock
4- Custom fine-tuned models
5- On-premise deployment

Best Practices

Stack AI Best Practices
Text
11. Start simple
2 - Basic workflow first
3 - Add complexity gradually
4
52. Test incrementally
6 - Test each node
7 - Verify data flow
8 - Check edge cases
9
103. Optimize prompts
11 - Clear instructions
12 - Relevant context
13 - Output format
14
154. Monitor usage
16 - Track API costs
17 - Review performance
18 - Optimize as needed
19
205. Version control
21 - Save versions
22 - Document changes
23 - Rollback capability

Common Patterns

RAG Pattern

Text
1Standard RAG:
21. User question
32. Search knowledge base
43. Retrieve relevant docs
54. Include in prompt
65. Generate answer
76. Cite sources

Agent Pattern

Text
1ReAct agent:
21. Receive task
32. Think: What do I need to do?
43. Act: Use appropriate tool
54. Observe: Review result
65. Repeat until complete
76. Return final answer

Chain Pattern

Text
1Sequential processing:
21. Summarize document
32. Extract key points
43. Generate action items
54. Format output
65. Send notification

Troubleshooting

Common Issues
Text
1Search returns no results:
2- Check document processing
3- Lower threshold
4- Review query format
5
6LLM response poor quality:
7- Improve prompt
8- Add more context
9- Check search results
10
11Workflow slow:
12- Reduce context size
13- Use smaller model
14- Optimize search
15- Cache results
16
17API errors:
18- Check authentication
19- Verify endpoints
20- Review rate limits

Bài Tập

Practice

Build Stack AI System:

  1. Create Stack AI account
  2. Upload company documents
  3. Build Q&A workflow
  4. Add conditional logic
  5. Deploy as API
  6. Test with various questions
  7. Optimize based on results

Tiếp theo: Bài 10 - Integrations