Hello! My code runs when in a single file but when putting the funtion definitions into another file, the LLM can’t seem to use the functions defined. The functions are in the “decoder_functions.py” file. Here is my code: import os
from dotenv import load_dotenv
import json
from openai import OpenAI
import streamlit as st
import decoder_tools
import decoder_functions
Load environment variables
load_dotenv()
deployment_name = "gpt-4o"
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY"),
base_url=os.getenv("OPENAI_BASE_URL"),
)
def generate_text_with_conversation(messages):
response = client.chat.completions.create(
model=deployment,
messages=messages,
tools=decoder_tools.tools,
tool_choice="auto"
)
return response.choices[0].message
available_tools = {
"decode_base64": decoder_functions.decode_base64,
"decode_base32": decoder_functions.decode_base32,
"decode_url": decoder_functions.decode_url,
}
BASE_SYSTEM_PROMPT = "Base Prompt Here"
messages = []
turn_count = 1
max_turns = 6
while turn_count < max_turns:
response = generate_text_with_conversation(messages)
messages.append(response)
tool_calls = response.tool_calls
if tool_calls:
for tool_call in tool_calls:
tool_name = tool_call.function.name
tool_id = tool_call.id
arguments = json.loads(tool_call.function.arguments)
# Call the function
action_function = available_tools[tool_name]
result = action_function(**arguments)
messages.append({
"role": "tool",
"content": result,
"tool_call_id": tool_id,
})
continue
else:
print(response.content)
break