How can I track if a Tool has been used in my run step?

Hi! I’m using the assistants API and I want to know if the retrieval tool I’m defining with some pre-uploaded documentas actually retrieves the information I needed. Which information and even if the run is actually using the retrieval tool.

Is there any direct access that tracks all the information when a tool is used?

For now I’ve seen in docs that this can be track from making a request to the API putting the run.id and the thread.id but by replyting this into python code I dont have any clear response if the tools has been used or not.

#How do we know if the API just call the retrieval tool? 
#Let's see the run steps
import requests

# Replace 'your_api_key' with your actual OpenAI API key, or set up an environment variable as per your security practices
headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json',
    'OpenAI-Beta': 'assistants=v1'
}

thread_id = thread.id
run_id = run.id

response = requests.get(f'https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps', headers=headers)
response
#the following is what response displays
[{'id': 'step_hqrVeEDKvrRfOymjoyCIKXfn',
  'object': 'thread.run.step',
  'created_at': 1699378814,
  'run_id': 'run_PXNycVs6s584tyViDq0dIDHC',
  'assistant_id': 'asst_Eemf92UW7zt0zxUO9Z39eUZr',
  'thread_id': 'thread_JsNdq1YUIlWL0M9GPbN6UDRr',
  'type': 'message_creation',
  'status': 'completed',
  'cancelled_at': None,
  'completed_at': 1699078821,
  'expires_at': None,
  'failed_at': None,
  'last_error': None,
  'step_details': {'type': 'message_creation',
   'message_creation': {'message_id': 'msg_lbiCnaic8usmhsiyaijgJ2Cl'}}}]
1 Like