import { GraphyAiSdk } from '@graphysdk/ai';
import type { GraphConfig } from '@graphysdk/core';
const ai = new GraphyAiSdk({
apiKey: process.env.GRAPHY_API_KEY,
baseUrl: 'https://agents.graphy.dev',
});
const config: GraphConfig = {
type: 'column',
data: {
columns: [
{ key: 'month', label: 'Month' },
{ key: 'sales', label: 'Sales' },
],
rows: [
{ month: 'Jan', sales: 100 },
{ month: 'Feb', sales: 120 },
{ month: 'Mar', sales: 115 },
],
},
};
const result = await ai.generateGraph({
config,
userPrompt: 'Change this to a bar chart and sort by sales descending',
});
console.log(result.config); // Updated GraphConfig
console.log(result.response.message); // Explanation