import json
from openai import OpenAI
from langtrace_python_sdk import get_prompt_from_registry
# Initialize OpenAI client
openai = OpenAI(api_key='sk-<YOUR_API_KEY>')
# Function to make the API call
def make_tool_call():
response = get_prompt_from_registry('<Prompt Registry ID>')
function_params = json.loads(response['value'])
completion = 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'
}
],
functions=[
{
'name': 'order_product',
'description': 'Place an order for a product',
'parameters': function_params
}
]
)
print(completion)