import os
from dotenv import load_dotenv
from toolhouse import Toolhouse
from openai import OpenAI
from typing import List
load_dotenv()
client = OpenAI()
tools = Toolhouse()
#Metadata to convert UTC time to your localtime
th.set_metadata("timezone", -7)
messages: List = [{
"role": "user",
"content": "What's the current time?"
}]
response = client.chat.completions.create(
model='gpt-4o',
messages=messages,
tools=tools.get_tools(),
tool_choice="auto"
)
messages += th.run_tools(response)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
tools=tools.get_tools(),
tool_choice="auto"
)
print(response.choices[0].message.content)
This produces the error:
th.set_metadata("timezone", -7)
^^
NameError: name 'th' is not defined
However, this should fix it
import os
from dotenv import load_dotenv
from toolhouse import Toolhouse
from openai import OpenAI
from typing import List
load_dotenv()
TH_TOKEN = os.getenv("TOOLHOUSE_BEARER_TOKEN")
client = OpenAI()
tools = Toolhouse()
th = Toolhouse(access_token=TH_TOKEN, provider="openai")
#Metadata to convert UTC time to your localtime
th.set_metadata("timezone", -7)
messages: List = [{
"role": "user",
"content": "What's the current time?"
}]
response = client.chat.completions.create(
model='gpt-4o',
messages=messages,
tools=tools.get_tools(),
tool_choice="auto"
)
messages += th.run_tools(response)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=messages,
tools=tools.get_tools(),
tool_choice="auto"
)
print(response.choices[0].message.content)
I believe there's a bug in the sample code.
This produces the error: th.set_metadata("timezone", -7) ^^ NameError: name 'th' is not defined
However, this should fix it