karrio-cli 2025.5rc3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- karrio_cli/__init__.py +0 -0
- karrio_cli/__main__.py +105 -0
- karrio_cli/ai/README.md +335 -0
- karrio_cli/ai/__init__.py +0 -0
- karrio_cli/ai/commands.py +102 -0
- karrio_cli/ai/karrio_ai/__init__.py +1 -0
- karrio_cli/ai/karrio_ai/agent.py +972 -0
- karrio_cli/ai/karrio_ai/architecture/INTEGRATION_AGENT_PROMPT.md +497 -0
- karrio_cli/ai/karrio_ai/architecture/MAPPING_AGENT_PROMPT.md +355 -0
- karrio_cli/ai/karrio_ai/architecture/REAL_WORLD_TESTING.md +305 -0
- karrio_cli/ai/karrio_ai/architecture/SCHEMA_AGENT_PROMPT.md +183 -0
- karrio_cli/ai/karrio_ai/architecture/TESTING_AGENT_PROMPT.md +448 -0
- karrio_cli/ai/karrio_ai/architecture/TESTING_GUIDE.md +271 -0
- karrio_cli/ai/karrio_ai/enhanced_tools.py +943 -0
- karrio_cli/ai/karrio_ai/rag_system.py +503 -0
- karrio_cli/ai/karrio_ai/tests/test_agent.py +350 -0
- karrio_cli/ai/karrio_ai/tests/test_real_integration.py +360 -0
- karrio_cli/ai/karrio_ai/tests/test_real_world_scenarios.py +513 -0
- karrio_cli/commands/__init__.py +0 -0
- karrio_cli/commands/codegen.py +336 -0
- karrio_cli/commands/login.py +139 -0
- karrio_cli/commands/plugins.py +168 -0
- karrio_cli/commands/sdk.py +870 -0
- karrio_cli/common/queries.py +101 -0
- karrio_cli/common/utils.py +368 -0
- karrio_cli/resources/__init__.py +0 -0
- karrio_cli/resources/carriers.py +91 -0
- karrio_cli/resources/connections.py +207 -0
- karrio_cli/resources/events.py +151 -0
- karrio_cli/resources/logs.py +151 -0
- karrio_cli/resources/orders.py +144 -0
- karrio_cli/resources/shipments.py +210 -0
- karrio_cli/resources/trackers.py +287 -0
- karrio_cli/templates/__init__.py +9 -0
- karrio_cli/templates/__pycache__/__init__.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/__init__.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/address.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/address.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/docs.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/docs.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/documents.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/documents.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/manifest.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/manifest.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/pickup.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/pickup.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/rates.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/rates.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/sdk.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/sdk.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/shipments.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/shipments.cpython-312.pyc +0 -0
- karrio_cli/templates/__pycache__/tracking.cpython-311.pyc +0 -0
- karrio_cli/templates/__pycache__/tracking.cpython-312.pyc +0 -0
- karrio_cli/templates/address.py +308 -0
- karrio_cli/templates/docs.py +150 -0
- karrio_cli/templates/documents.py +428 -0
- karrio_cli/templates/manifest.py +396 -0
- karrio_cli/templates/pickup.py +839 -0
- karrio_cli/templates/rates.py +638 -0
- karrio_cli/templates/sdk.py +947 -0
- karrio_cli/templates/shipments.py +892 -0
- karrio_cli/templates/tracking.py +437 -0
- karrio_cli-2025.5rc3.dist-info/METADATA +165 -0
- karrio_cli-2025.5rc3.dist-info/RECORD +68 -0
- karrio_cli-2025.5rc3.dist-info/WHEEL +5 -0
- karrio_cli-2025.5rc3.dist-info/entry_points.txt +2 -0
- karrio_cli-2025.5rc3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,271 @@
|
|
1
|
+
# Testing Karrio ADK Agent with Real-World Carriers
|
2
|
+
|
3
|
+
This guide shows you how to test the Karrio ADK (Application Development Kit) agent with real shipping carriers using the web interface.
|
4
|
+
|
5
|
+
## Prerequisites
|
6
|
+
|
7
|
+
### 1. Environment Setup
|
8
|
+
|
9
|
+
First, make sure you have the development environment activated:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
# From the karrio root directory
|
13
|
+
source ./bin/activate-env
|
14
|
+
```
|
15
|
+
|
16
|
+
### 2. Google API Key
|
17
|
+
|
18
|
+
You need a Google API key to use the Gemini AI model:
|
19
|
+
|
20
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/apis/credentials)
|
21
|
+
2. Create a new API key or use an existing one
|
22
|
+
3. Enable the "Generative Language API" for your project
|
23
|
+
|
24
|
+
### 3. Environment Configuration
|
25
|
+
|
26
|
+
1. Copy the environment sample file:
|
27
|
+
```bash
|
28
|
+
cd modules/cli/karrio_cli/ai
|
29
|
+
cp .env.sample .env
|
30
|
+
```
|
31
|
+
|
32
|
+
2. Edit the `.env` file and replace `YOUR_GOOGLE_API_KEY_HERE` with your actual API key:
|
33
|
+
```bash
|
34
|
+
GOOGLE_API_KEY=your_actual_api_key_here
|
35
|
+
```
|
36
|
+
|
37
|
+
## Starting the ADK Web Interface
|
38
|
+
|
39
|
+
### Method 1: Using CLI Command (Recommended)
|
40
|
+
|
41
|
+
```bash
|
42
|
+
# From the karrio root directory
|
43
|
+
python -m karrio_cli agent web
|
44
|
+
```
|
45
|
+
|
46
|
+
### Method 2: Direct ADK Command
|
47
|
+
|
48
|
+
```bash
|
49
|
+
# From the karrio root directory
|
50
|
+
cd modules/cli/karrio_cli/ai
|
51
|
+
adk web karrio_ai
|
52
|
+
```
|
53
|
+
|
54
|
+
The web interface will start on `http://localhost:8080` (or the port specified in your .env file).
|
55
|
+
|
56
|
+
## Testing with Real Carriers
|
57
|
+
|
58
|
+
### Scenario 1: Building a New Carrier Integration
|
59
|
+
|
60
|
+
Let's test building an integration for a hypothetical carrier called "SwiftShip":
|
61
|
+
|
62
|
+
1. **Open the web interface** at `http://localhost:8080`
|
63
|
+
|
64
|
+
2. **Start a conversation** with the agent:
|
65
|
+
```
|
66
|
+
I want to build a new carrier integration for SwiftShip. They have a REST API with:
|
67
|
+
- Rates endpoint: https://api.swiftship.com/v1/rates
|
68
|
+
- Shipments endpoint: https://api.swiftship.com/v1/shipments
|
69
|
+
- Tracking endpoint: https://api.swiftship.com/v1/tracking
|
70
|
+
- Authentication: API key in header
|
71
|
+
```
|
72
|
+
|
73
|
+
3. **Ask for analysis** of similar carriers:
|
74
|
+
```
|
75
|
+
What existing carriers are most similar to SwiftShip?
|
76
|
+
Can you analyze UPS, FedEx, and DHL Express to find patterns?
|
77
|
+
```
|
78
|
+
|
79
|
+
4. **Request schema generation**:
|
80
|
+
```
|
81
|
+
Generate Python schemas for SwiftShip based on this API documentation:
|
82
|
+
{
|
83
|
+
"rate_response": {
|
84
|
+
"rates": [
|
85
|
+
{
|
86
|
+
"service_code": "GROUND",
|
87
|
+
"service_name": "Ground Service",
|
88
|
+
"total_cost": 15.99,
|
89
|
+
"currency": "USD",
|
90
|
+
"delivery_days": 3
|
91
|
+
}
|
92
|
+
]
|
93
|
+
}
|
94
|
+
}
|
95
|
+
```
|
96
|
+
|
97
|
+
5. **Ask for complete integration**:
|
98
|
+
```
|
99
|
+
Generate a complete SwiftShip integration with all components:
|
100
|
+
- Schemas
|
101
|
+
- Mappings
|
102
|
+
- Tests
|
103
|
+
- Configuration files
|
104
|
+
```
|
105
|
+
|
106
|
+
### Scenario 2: Analyzing Existing Carriers
|
107
|
+
|
108
|
+
Test the agent's analysis capabilities:
|
109
|
+
|
110
|
+
1. **Analyze a complex carrier**:
|
111
|
+
```
|
112
|
+
Analyze the FedEx connector and show me:
|
113
|
+
- Authentication patterns
|
114
|
+
- Rate mapping examples
|
115
|
+
- Error handling approaches
|
116
|
+
- Test structure
|
117
|
+
```
|
118
|
+
|
119
|
+
2. **Compare multiple carriers**:
|
120
|
+
```
|
121
|
+
Compare the authentication methods used by UPS, FedEx, and DHL Express.
|
122
|
+
What are the common patterns and best practices?
|
123
|
+
```
|
124
|
+
|
125
|
+
3. **Extract specific patterns**:
|
126
|
+
```
|
127
|
+
Extract the rate calculation patterns from all North American carriers.
|
128
|
+
Show me code examples of how they handle package dimensions.
|
129
|
+
```
|
130
|
+
|
131
|
+
### Scenario 3: Testing Edge Cases
|
132
|
+
|
133
|
+
Test the agent's robustness:
|
134
|
+
|
135
|
+
1. **Complex API structures**:
|
136
|
+
```
|
137
|
+
How would you handle a carrier with XML-only APIs and SOAP authentication?
|
138
|
+
Show me an example integration approach.
|
139
|
+
```
|
140
|
+
|
141
|
+
2. **International requirements**:
|
142
|
+
```
|
143
|
+
Build an integration for a European carrier that requires:
|
144
|
+
- Customs documentation
|
145
|
+
- VAT calculations
|
146
|
+
- Multi-language support
|
147
|
+
```
|
148
|
+
|
149
|
+
3. **Performance optimization**:
|
150
|
+
```
|
151
|
+
How would you optimize the rate calculation for a carrier that
|
152
|
+
requires separate API calls for each service type?
|
153
|
+
```
|
154
|
+
|
155
|
+
## Expected Agent Capabilities
|
156
|
+
|
157
|
+
When testing, the agent should demonstrate:
|
158
|
+
|
159
|
+
### ✅ Analysis Capabilities
|
160
|
+
- [ ] Analyze 100+ existing carrier files
|
161
|
+
- [ ] Extract 25,000+ code patterns
|
162
|
+
- [ ] Identify similar carriers based on API characteristics
|
163
|
+
- [ ] Generate best practice recommendations
|
164
|
+
|
165
|
+
### ✅ Generation Capabilities
|
166
|
+
- [ ] Generate complete Python schemas with proper typing
|
167
|
+
- [ ] Create request/response mappings for all operations
|
168
|
+
- [ ] Build comprehensive test suites
|
169
|
+
- [ ] Assemble complete project structure
|
170
|
+
|
171
|
+
### ✅ Integration Features
|
172
|
+
- [ ] Multi-agent coordination (Schema, Mapping, Integration, Testing agents)
|
173
|
+
- [ ] RAG system with semantic search
|
174
|
+
- [ ] Pattern-based code generation
|
175
|
+
- [ ] Quality assurance and validation
|
176
|
+
|
177
|
+
## Monitoring Agent Performance
|
178
|
+
|
179
|
+
### Real-time Feedback
|
180
|
+
|
181
|
+
The web interface should show:
|
182
|
+
- **Agent thinking process**: Sub-agent coordination
|
183
|
+
- **RAG system queries**: Pattern searches and code examples
|
184
|
+
- **Generation progress**: Schema → Mappings → Tests → Assembly
|
185
|
+
- **Quality metrics**: Completion percentage and confidence scores
|
186
|
+
|
187
|
+
### Performance Metrics
|
188
|
+
|
189
|
+
Monitor these key indicators:
|
190
|
+
- **Response time**: < 30 seconds for complex integrations
|
191
|
+
- **Accuracy**: Generated code should compile and follow Karrio conventions
|
192
|
+
- **Completeness**: Should achieve 95%+ completion rate
|
193
|
+
- **Pattern quality**: High-confidence (>0.7) pattern matches
|
194
|
+
|
195
|
+
## Troubleshooting
|
196
|
+
|
197
|
+
### Common Issues
|
198
|
+
|
199
|
+
1. **"ADK command not found"**
|
200
|
+
```bash
|
201
|
+
pip install google-cloud-aiplatform[dev]
|
202
|
+
```
|
203
|
+
|
204
|
+
2. **"Google API key not set"**
|
205
|
+
- Check your `.env` file
|
206
|
+
- Verify the API key is correct
|
207
|
+
- Ensure Generative Language API is enabled
|
208
|
+
|
209
|
+
3. **"RAG system shows 0 patterns"**
|
210
|
+
- Verify workspace path is correct
|
211
|
+
- Check that connector files exist
|
212
|
+
- Run the basic test: `python test_agent.py`
|
213
|
+
|
214
|
+
4. **"Agent responses are slow"**
|
215
|
+
- Check internet connection
|
216
|
+
- Verify API quota hasn't been exceeded
|
217
|
+
- Consider using a more powerful model tier
|
218
|
+
|
219
|
+
### Debug Mode
|
220
|
+
|
221
|
+
Enable debug logging by setting in your `.env`:
|
222
|
+
```bash
|
223
|
+
DEBUG=TRUE
|
224
|
+
LOG_LEVEL=DEBUG
|
225
|
+
```
|
226
|
+
|
227
|
+
## Advanced Testing Scenarios
|
228
|
+
|
229
|
+
### Custom Scenario Templates
|
230
|
+
|
231
|
+
1. **High-Volume Carrier**:
|
232
|
+
```
|
233
|
+
Test integration for a carrier handling 10,000+ shipments/day
|
234
|
+
with rate limiting and batch processing requirements.
|
235
|
+
```
|
236
|
+
|
237
|
+
2. **Multi-Modal Carrier**:
|
238
|
+
```
|
239
|
+
Build integration for carrier supporting air, ground, and ocean freight
|
240
|
+
with different API endpoints and authentication for each mode.
|
241
|
+
```
|
242
|
+
|
243
|
+
3. **White-Label Integration**:
|
244
|
+
```
|
245
|
+
Create a flexible integration that can be configured for multiple
|
246
|
+
white-label carriers sharing the same API platform.
|
247
|
+
```
|
248
|
+
|
249
|
+
## Success Criteria
|
250
|
+
|
251
|
+
A successful test should result in:
|
252
|
+
|
253
|
+
- [ ] **98%+ completion rate** for integration generation
|
254
|
+
- [ ] **Production-ready code** that follows Karrio conventions
|
255
|
+
- [ ] **Comprehensive test coverage** with unit and integration tests
|
256
|
+
- [ ] **Proper error handling** for all failure scenarios
|
257
|
+
- [ ] **Complete documentation** with usage examples
|
258
|
+
|
259
|
+
## Next Steps
|
260
|
+
|
261
|
+
After successful testing:
|
262
|
+
|
263
|
+
1. **Code Review**: Review generated integration code
|
264
|
+
2. **Real API Testing**: Test with actual carrier sandbox APIs
|
265
|
+
3. **Performance Testing**: Load test the generated integration
|
266
|
+
4. **Production Deployment**: Deploy to staging environment
|
267
|
+
5. **Documentation**: Update carrier-specific documentation
|
268
|
+
|
269
|
+
---
|
270
|
+
|
271
|
+
**Note**: Remember that this is an AI-powered tool. Always review generated code before production use and test thoroughly with real carrier APIs in sandbox mode first.
|