mistral-core-workflow-b
БесплатноБез исполняемых скриптовНе проверенExecute Mistral AI secondary workflows: Embeddings and Function Calling. Use when implementing semantic search, RAG applications, or tool-augmented LLM…
от majiayu000★ 31 звезда на GitHubОб этом скилле
Mistral AI Core Workflow B: Embeddings & Function Calling
Overview
Secondary workflows for Mistral AI: Text embeddings for semantic search and function calling for tool use.
Prerequisites
- Completed
mistral-install-authsetup - Familiarity with
mistral-core-workflow-a - Valid API credentials configured
Embeddings
Step 1: Generate Text Embeddings
import Mistral from '@mistralai/mistralai';
const client = new Mistral({
apiKey: process.env.MISTRAL_API_KEY,
});
async function getEmbedding(text: string): Promise<number[]> {
const response = await client.embeddings.create({
model: 'mistral-embed',
inputs: [text],
});
return response.data[0].embedding;
}
// Usage
const embedding = await getEmbedding('Machine learning is fascinating.');
console.log(`Embedding dimensions: ${embedding.length}`); // 1024
Step 2: Batch Embeddings
async function getBatchEmbeddings(texts: string[]): Promise<number[][]> {
const response = await client.embeddings.create({
model: 'mistral-embed',
inputs: texts,
});
return response.data.map(d => d.embedding);
}
// Usage
const documents = [
'Python is a programming language.',
'JavaScript runs in browsers.',
'Rust is memory safe.',
];
const embeddings = await getBatchEmbeddings(documents);
Step 3: Semantic Search Implementation
function cosineSimilarity(a: number[], b: number[]): number {
let dotProduct = 0;
let normA = 0;
let normB = 0;
for (let i = 0; i < a.length; i++) {
dotProduct += a[i] * b[i];
normA += a[i] * a[i];
normB += b[i] * b[i];
}
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
}
interface Document {
id: string;
text: string;
embedding?: number[];
}
class SemanticSearch {
private documents: Document[] = [];
private client: Mistral;
constructor() {
this.client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
}
async indexDocuments(docs: Omit<Document, 'embedding'>[]): Promise<void> {
const texts = docs.map(d => d.text);
const response = await this.client.embeddings.create({
model: 'mistral-embed',
inputs: texts,
});
this.documents = docs.map((doc, i) => ({
...doc,
embedding: response.data[i].embedding,
}));
}
async search(query: string, topK = 5): Promise<Array<Document & { score: number }>> {
const queryEmbedding = await this.getEmbedding(query);
const results = this.documents
.map(doc => ({
...doc,
score: cosineSimilarity(queryEmbedding, doc.embedding!),
}))
.sort((a, b) => b.score - a.score)
.slice(0, topK);
return results;
}
private async getEmbedding(text: string): Promise<number[]> {
const response = await this.client.embeddings.create({
model: 'mistral-embed',
inputs: [text],
});
return response.data[0].embedding;
}
}
// Usage
const search = new SemanticSearch();
await search.indexDocuments([
{ id: '1', text: 'How to bake chocolate chip cookies' },
{ id: '2', text: 'Machine learning fundamentals' },
{ id: '3', text: 'Best practices for React development' },
]);
const results = await search.search('AI tutorials', 2);
// Returns documents sorted by semantic similarity
Function Calling
Step 4: Define Tools
interface Tool {
type: 'function';
function: {
name: string;
description: string;
parameters: {
type: 'object';
properties: Record<string, { type: string; description: string }>;
required: string[];
};
};
}
const tools: Tool[] = [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get the current weather for a location',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'City and country, e.g., "London, UK"',
},
unit: {
type: 'string',
description: 'Temperature unit: "celsius" or "fahrenheit"',
},
},
required: ['location'],
},
},
},
{
type: 'function',
function: {
name: 'search_web',
description: 'Search the web for information',
parameters: {
type: 'object',
properties: {
query: {
type: 'string',
description: 'The search query',
},
},
required: ['query'],
},
},
},
];
Step 5: Implement Function Calling Loop
import Mistral from '@mistralai/mistralai';
const client = new Mistral({
apiKey: process.env.MISTRAL_API_KEY,
});
// Tool implementations
const toolFunctions: Record<string, (args: any) => Promise<string>> = {
get_weather: async ({ location, unit = 'celsius' }) => {
// Simulated weather API call
return JSON.stringify({
location,
temperature: unit === 'celsius' ? 22 : 72,
unit,
condition:
Установить mistral-core-workflow-b в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBash(npm:*)GrepВложенные файлы
FAQ
Что делает скилл mistral-core-workflow-b?
Execute Mistral AI secondary workflows: Embeddings and Function Calling. Use when implementing semantic search, RAG applications, or tool-augmented LLM interactions. Trigger with phrases like "mistral embeddings", "mistral function calling", "mistral tools", "mistral RAG", "mistral semantic search".
Как установить скилл mistral-core-workflow-b?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mistral-core-workflow-b запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub