// AI function definition for creator coin purchases
export const ZORA_BUY_FUNCTION = {
type: 'function' as const,
function: {
name: 'buy_zora_coin',
description: 'Buy a Zora creator coin for a specific user handle and amount',
parameters: {
type: 'object',
properties: {
zoraHandle: {
type: 'string',
description: 'The Zora user handle or identifier to buy coins for',
},
amountUSD: {
type: 'number',
description: 'The amount in USD to spend on the creator coin',
},
},
required: ['zoraHandle', 'amountUSD'],
},
},
};
export async function generateChatResponse(
messages: ChatMessage[],
tools: any[] = [ZORA_BUY_FUNCTION]
) {
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: SYSTEM_PROMPT },
...messages,
],
tools,
tool_choice: 'auto',
max_completion_tokens: 1000,
});
return response;
}