Agents
Agents Mayele via @ziwako/ai — CRUD, génération et streaming de contenu, assistants produits et photo.
La ressource Agents gère les agents IA Mayele : création (avec instructions, tools,
modelId, memory, voice), lecture, suppression, génération et streaming de contenu,
ainsi que les agents intégrés à la plateforme (assistant produit, éditeur photo).
- Factory :
getAgents()(@ziwako/ai/axios) - Types :
Agent,AgentResponse,AgentListResponse,CreateAgentBody,GenerateContentBody,StreamContentBody,GenerateProductContentBody,EnsureProductAssistantBody,EnsurePhotoEditorBody,ListeAgentParams - Endpoints :
GET /agents,POST /agents,GET /agents/{id},DELETE /agents/{id},POST /agents/{id}/generate,POST /agents/{id}/stream,POST /ziwako/ensure-product-assistant,POST /ziwako/product-content,POST /ziwako/ensure-photo-editor
import { configure, getAgents } from '@ziwako/ai/axios';
configure({ accessToken: '...' });
const agents = getAgents();CRUD
listeAgent
Liste paginée des agents.
Signature : listeAgent(params?: ListeAgentParams) → Promise<AgentListResponse>
const list = await agents.listeAgent({ page: 1, limit: 20, filter: { ownerId: profilId } });
console.log(list.data?.docs);import { useListeAgent } from '@ziwako/ai/react-query';
const { data } = useListeAgent({ page: 1, limit: 20 }, { query: { enabled: true } });createAgent
Crée un agent. slug, name, instructions et ownerId sont requis ; modelId
(optionnel) sélectionne le modèle d'IA, tools liste les outils disponibles, workflowIds
et subAgentIds lient workflows et sous-agents.
Signature : createAgent(createAgentBody: CreateAgentBody) → Promise<AgentResponse>
const response = await agents.createAgent({
slug: 'support-agent',
name: 'Agent support client',
instructions: 'Tu réponds aux questions des clients sur nos produits, en français, avec un ton chaleureux.',
modelId: 'gpt-4o',
ownerId: profilId,
isPublic: false,
});
console.log(response.data?.id);import { useCreateAgent } from '@ziwako/ai/react-query';
const mutation = useCreateAgent({
mutation: { onSuccess: (r) => console.log('Agent créé:', r.data?.id) },
});
mutation.mutate({
data: {
slug: 'support-agent',
name: 'Agent support client',
instructions: 'Tu réponds aux questions des clients.',
ownerId: profilId,
},
});getAgent
Récupère un agent par son id.
Signature : getAgent(id: string) → Promise<AgentResponse>
const response = await agents.getAgent('64b8f2...');
console.log(response.data?.name, response.data?.instructions);import { useGetAgent } from '@ziwako/ai/react-query';
const { data } = useGetAgent(agentId, { query: { enabled: !!agentId } });deleteAgent
Supprime un agent.
Signature : deleteAgent(id: string) → Promise<DeleteAgent200>
await agents.deleteAgent(agentId);import { useDeleteAgent } from '@ziwako/ai/react-query';
const mutation = useDeleteAgent();
mutation.mutate({ id: agentId });Génération de contenu
generateContent
Génère du contenu avec un agent. Le corps est requis : prompt (+ éventuellement
context pour guider le modèle).
Signature : generateContent(id: string, generateContentBody: GenerateContentBody) → Promise<GenerateContent200>
const response = await agents.generateContent(agentId, {
prompt: 'Rédige 3 slogans pour une application de mise en relation.',
context: { tone: 'moderne', audience: 'professionnels' },
});
console.log(response.data?.text);import { useGenerateContent } from '@ziwako/ai/react-query';
const mutation = useGenerateContent({
mutation: { onSuccess: (r) => setResult(r.data?.text ?? '') },
});
mutation.mutate({
id: agentId,
data: { prompt: 'Rédige 3 slogans pour une application de mise en relation.' },
});streamContent
Génère du contenu en streaming (réception progressive des tokens).
Signature : streamContent(id: string, streamContentBody: StreamContentBody) → Promise<StreamContent200>
const stream = await agents.streamContent(agentId, {
prompt: 'Explique les avantages de la mise en relation locale.',
});
console.log(stream.data);import { useStreamContent } from '@ziwako/ai/react-query';
const mutation = useStreamContent();
mutation.mutate({ id: agentId, data: { prompt: 'Explique les avantages de la mise en relation locale.' } });Agents intégrés Ziwako
ensureProductAssistant
S'assure que l'utilisateur possède un assistant produit (création automatique si nécessaire).
Signature : ensureProductAssistant(ensureProductAssistantBody?: EnsureProductAssistantBody) → Promise<EnsureProductAssistant200>
const response = await agents.ensureProductAssistant({ ownerId: profilId });
console.log(response.data?.agentId);import { useEnsureProductAssistant } from '@ziwako/ai/react-query';
const mutation = useEnsureProductAssistant();
mutation.mutate({ data: { ownerId: profilId } });generateProductContent
Génère le contenu produit (titre, description, tags, meta description) à l'aide de l'IA.
Signature : generateProductContent(generateProductContentBody?: GenerateProductContentBody) → Promise<GenerateProductContent200>
const response = await agents.generateProductContent({
productName: 'Casque audio sans fil',
features: ['Réduction de bruit active', 'Autonomie 30h', 'Bluetooth 5.3'],
keywords: ['casque', 'bluetooth', 'audio'],
});
console.log(response.data?.title, response.data?.description, response.data?.tags);import { useGenerateProductContent } from '@ziwako/ai/react-query';
const mutation = useGenerateProductContent();
mutation.mutate({
data: { productName: 'Casque audio sans fil', features: ['Réduction de bruit active'], keywords: ['casque', 'bluetooth'] },
});ensurePhotoEditor
S'assure que l'utilisateur possède un éditeur photo IA (création automatique si nécessaire).
Signature : ensurePhotoEditor(ensurePhotoEditorBody?: EnsurePhotoEditorBody) → Promise<EnsurePhotoEditor200>
const response = await agents.ensurePhotoEditor({ ownerId: profilId });
console.log(response.data?.agentId);import { useEnsurePhotoEditor } from '@ziwako/ai/react-query';
const mutation = useEnsurePhotoEditor();
mutation.mutate({ data: { ownerId: profilId } });