google-agents-cli-scaffold
Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.
mistral-migration-deep-dive
Execute Mistral AI major migrations and re-architecture strategies. Use when migrating to Mistral AI from another provider, performing major refactoring, or re-platforming existing AI integrations to Mistral AI. Trigger with phrases like "migrate to mistral", "mistral migration", "switch to mistr...
Full skill instructions
Comprehensive guide for migrating to Mistral AI from other providers or major version upgrades.
| Type | Complexity | Duration | Risk |
|---|---|---|---|
| Fresh install | Low | Days | Low |
| OpenAI to Mistral | Medium | Weeks | Medium |
| Multi-provider | Medium | Weeks | Medium |
| Full replatform | High | Months | High |
# Document current implementation
echo "=== Pre-Migration Assessment ==="
# Find all AI-related code
find . -name "*.ts" -o -name "*.py" | xargs grep -l "openai\|anthropic\|ai" > ai-files.txt
echo "Files with AI code: $(wc -l < ai-files.txt)"
# Count integration points
grep -r "chat.completions\|createChatCompletion" src/ --include="*.ts" | wc -l
# Check current SDK versions
npm list openai @anthropic-ai/sdk 2>/dev/null || echo "No existing AI SDKs"
// scripts/assess-migration.ts
interface MigrationAssessment {
currentProvider: string;
integrationPoints: number;
features: string[];
estimatedEffort: 'low' | 'medium' | 'high';
risks: string[];
}
async function assessMigration(): Promise<MigrationAssessment> {
const files = await glob('src/**/*.{ts,js}');
const features = new Set<string>();
let integrationPoints = 0;
for (const file of files) {
const content = await fs.readFile(file, 'utf-8');
// Detect features
if (/chat\.completions|createChatCompletion/i.test(content)) {
features.add('chat');
integrationPoints++;
}
if (/embeddings\.create|createEmbedding/i.test(content)) {
features.add('embeddings');
integrationPoints++;
}
if (/function_call|tools/i.test(content)) {
features.add('function_calling');
integrationPoints++;
}
if (/stream/i.test(content)) {
features.add('streaming');
integrationPoints++;
}
}
return {
currentProvider: detectProvider(files),
integrationPoints,
features: Array.from(features),
estimatedEffort: integrationPoints > 10 ? 'high' : integrationPoints > 3 ? 'medium' : 'low',
risks: identifyRisks(features),
};
}
// src/ai/adapter.ts
// Provider-agnostic interface
export interface Message {
role: 'system' | 'user' | 'assistant';
content: string;
}
export interface ChatOptions {
model?: string;
temperature?: number;
maxTokens?: number;
stream?: boolean;
}
export interface ChatResponse {
content: string;
usage?: {
inputTokens: number;
outputTokens: number;
};
}
export interface AIAdapter {
chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<string>;
embed(text: string | string[]): Promise<number[][]>;
}
// src/ai/adapters/openai.ts
import OpenAI from 'openai';
import { AIAdapter, Message, ChatOptions, ChatResponse } from '../adapter';
export class OpenAIAdapter implements AIAdapter {
private client: OpenAI;
constructor() {
this.client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
}
async chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse> {
const response = await this.client.chat.completions.create({
model: options?.model || 'gpt-3.5-turbo',
messages,
temperature: options?.temperature,
max_tokens: options?.maxTokens,
});
return {
content: response.choices[0]?.message?.content || '',
usage: response.usage ? {
inputTokens: response.usage.prompt_tokens,
outputTokens: response.usage.completion_tokens,
} : undefined,
};
}
async *chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<string> {
const stream = await this.client.chat.completions.create({
model: options?.model || 'gpt-3.5-turbo',
messages,
stream: true,
});
for await (const chunk of stream) {
const content = chunk.choices[0]?.delta?.content;
if (content) yield content;
}
}
async embed(text: string | string[]): Promise<number[][]> {
const input = Array.isArray(text) ? text : [text];
const response = await this.client.embeddings.create({
model: 'text-embedding-ada-002',
input,
});
return response.data.map(d => d.embedding);
}
}
// src/ai/adapters/mistral.ts
import Mistral from '@mistralai/mistralai';
import { AIAdapter, Message, ChatOptions, ChatResponse } from '../adapter';
export class MistralAdapter implements AIAdapter {
private client: Mistral;
constructor() {
this.client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
}
async chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse> {
const response = await this.client.chat.complete({
model: options?.model || 'mistral-small-latest',
messages,
temperature: options?.temperature,
maxTokens: options?.maxTokens,
});
return {
content: response.choices?.[0]?.message?.content || '',
usage: response.usage ? {
inputTokens: response.usage.promptTokens || 0,
outputTokens: response.usage.completionTokens || 0,
} : undefined,
};
}
async *chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<string> {
const stream = await this.client.chat.stream({
model: options?.model || 'mistral-small-latest',
messages,
temperature: options?.temperature,
maxTokens: options?.maxTokens,
});
for await (const event of stream) {
const content = event.data?.choices?.[0]?.delta?.content;
if (content) yield content;
}
}
async embed(text: string | string[]): Promise<number[][]> {
const input = Array.isArray(text) ? text : [text];
const response = await this.client.embeddings.create({
model: 'mistral-embed',
inputs: input,
});
return response.data.map(d => d.embedding);
}
}
// src/ai/factory.ts
import { AIAdapter } from './adapter';
import { OpenAIAdapter } from './adapters/openai';
import { MistralAdapter } from './adapters/mistral';
type Provider = 'openai' | 'mistral';
function getAIProvider(): Provider {
// Feature flag based migration
const mistralPercentage = parseInt(process.env.MISTRAL_ROLLOUT_PERCENT || '0');
const random = Math.random() * 100;
if (random < mistralPercentage) {
return 'mistral';
}
return 'openai';
}
export function createAIAdapter(): AIAdapter {
const provider = getAIProvider();
switch (provider) {
case 'mistral':
console.log('[AI] Using Mistral adapter');
return new MistralAdapter();
case 'openai':
default:
console.log('[AI] Using OpenAI adapter');
return new OpenAIAdapter();
}
}
# Phase 1: 0% Mistral (validation)
export MISTRAL_ROLLOUT_PERCENT=0
# Run tests, verify adapter works
# Phase 2: 5% Mistral (canary)
export MISTRAL_ROLLOUT_PERCENT=5
# Monitor for errors, compare latency
# Phase 3: 25% Mistral
export MISTRAL_ROLLOUT_PERCENT=25
# Monitor for 24-48 hours
# Phase 4: 50% Mistral
export MISTRAL_ROLLOUT_PERCENT=50
# Monitor for 24-48 hours
# Phase 5: 100% Mistral
export MISTRAL_ROLLOUT_PERCENT=100
# Full migration complete
// src/ai/model-mapping.ts
interface ModelMapping {
openai: string;
mistral: string;
notes: string;
}
const MODEL_MAPPINGS: ModelMapping[] = [
{
openai: 'gpt-3.5-turbo',
mistral: 'mistral-small-latest',
notes: 'Fast, cost-effective',
},
{
openai: 'gpt-4',
mistral: 'mistral-large-latest',
notes: 'Complex reasoning',
},
{
openai: 'gpt-4-turbo',
mistral: 'mistral-large-latest',
notes: 'Best available',
},
{
openai: 'text-embedding-ada-002',
mistral: 'mistral-embed',
notes: '1024 dimensions',
},
];
export function mapModel(openaiModel: string): string {
const mapping = MODEL_MAPPINGS.find(m => m.openai === openaiModel);
return mapping?.mistral || 'mistral-small-latest';
}
// tests/migration/compare-outputs.test.ts
import { describe, it, expect } from 'vitest';
import { OpenAIAdapter } from '../../src/ai/adapters/openai';
import { MistralAdapter } from '../../src/ai/adapters/mistral';
describe('Migration Validation', () => {
const openai = new OpenAIAdapter();
const mistral = new MistralAdapter();
const testCases = [
{ name: 'Simple greeting', messages: [{ role: 'user', content: 'Hello' }] },
{ name: 'Math question', messages: [{ role: 'user', content: 'What is 2+2?' }] },
{ name: 'Code generation', messages: [{ role: 'user', content: 'Write hello world in Python' }] },
];
for (const testCase of testCases) {
it(`should produce similar output: ${testCase.name}`, async () => {
const [openaiResult, mistralResult] = await Promise.all([
openai.chat(testCase.messages, { temperature: 0 }),
mistral.chat(testCase.messages, { temperature: 0 }),
]);
// Both should return non-empty content
expect(openaiResult.content.length).toBeGreaterThan(0);
expect(mistralResult.content.length).toBeGreaterThan(0);
// Log for manual review
console.log(`[${testCase.name}]`);
console.log('OpenAI:', openaiResult.content);
console.log('Mistral:', mistralResult.content);
});
}
});
#!/bin/bash
# rollback-to-openai.sh
echo "=== Rolling back to OpenAI ==="
# 1. Set rollout percentage to 0
kubectl set env deployment/ai-service MISTRAL_ROLLOUT_PERCENT=0
# 2. Verify rollback
kubectl rollout status deployment/ai-service
# 3. Check health
curl -sf https://api.yourapp.com/health | jq '.services.ai'
# 4. Alert team
echo "Rollback complete. Mistral disabled."
| Issue | Cause | Solution |
|---|---|---|
| Different output format | API differences | Normalize in adapter |
| Missing feature | Not supported | Implement fallback |
| Performance difference | Model characteristics | Adjust timeouts |
| Cost increase | Token differences | Monitor and optimize |
const [openaiResponse, mistralResponse] = await Promise.all([
openaiAdapter.chat(messages, { temperature: 0 }),
mistralAdapter.chat(messages, { temperature: 0 }),
]);
console.log('OpenAI tokens:', openaiResponse.usage);
console.log('Mistral tokens:', mistralResponse.usage);
Congratulations! You've completed the Mistral AI skill pack. For ongoing support, visit docs.mistral.ai.
Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.
Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.
Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.
Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.
Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.
Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.
Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.
Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.
Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".
Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.
Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".
Opus.ai: Revolutionize Your Web Experience
Build a no-code AI app in minutes.
An IDE for code migration from legacy to modern frameworks through coding agents.
Automate CGI animation in live-action scenes
Branded artistic QR-code concepts
Launch a website in seconds with AI.
Streamline Your Coding Experience with AI Code Helper
Convert any screenshot or design to clean code.