import { getPromptFromRegistry } from '@langtrase/typescript-sdk'
import OpenAI from 'openai'
// Initialize OpenAI client
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY })
// Function to make the API call
async function makeToolCall (): Promise<void> {
const response = await getPromptFromRegistry('<Prompt Registry ID>')
const functionParams = JSON.parse(response.value)
const completion = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: 'You are a helpful assistant that can use various tools.'
},
{
role: 'user',
content: 'Place an order for 3 units of product 1234'
}
],
tool_choice: 'auto',
tools: [
{
type: 'function',
function: {
name: 'order_product',
description: 'Place an order for a product',
parameters: functionParams
}
}
]
})
console.log(JSON.stringify(completion.choices[0]
.message, null, 2))
}