code: def annotate(prediction_set, caption_files, output_dir):
      """
      Evaluates question and answer pairs using GPT-3 and
      returns a score for detailed orientation.
      """
      for file in caption_files:
          key = file[:-5]  # Strip file extension
          qa_set = prediction_set[key]
          question = qa_set["q"]
          answer = qa_set["a"]
          pred = qa_set["pred"]
          try:
              print(key, "query")
              # Compute the detailed-orientation score
              completion = openai.ChatCompletion.create(
                  model="gpt-3.5-turbo",
                  messages=[
                      {
                          "role": "system",
                          "content": "You are an intelligent chatbot designed for evaluating the detail orientation of generative outputs for video-based question-answer pairs. "
                          "Your task is to compare the predicted answer with the correct answer and determine its level of detail, considering both completeness and specificity. Here's how you can accomplish the task:"
                          "------"
                          "##INSTRUCTIONS: "
                          "- Check if the predicted answer covers all major points from the video. The response should not leave out any key aspects.\n"
                          "- Evaluate whether the predicted answer includes specific details rather than just generic points. It should provide comprehensive information that is tied to specific elements of the video.\n"
                          "- Consider synonyms or paraphrases as valid matches.\n"
                          "- Provide a single evaluation score that reflects the level of detail orientation of the prediction, considering both completeness and specificity.",
                      },
                      {
                          "role": "user",
                          "content": "Please evaluate the following video-based question-answer pair:\n\n"
                          f"Question: {question}\n"
                          f"Correct Answer: {answer}\n"
                          f"Predicted Answer: {pred}\n\n"
                          "Provide your evaluation only as a detail orientation score where the detail orientation score is an integer value between 0 and 5, with 5 indicating the highest level of detail orientation. "
                          "Please generate the response in the form of a Python dictionary string with keys 'score', where its value is the detail orientation score in INTEGER, not STRING."
                          "DO NOT PROVIDE ANY OTHER OUTPUT TEXT OR EXPLANATION. Only provide the Python dictionary string. "
                          "For example, your response should look like this: {''score': 4.8}.",
                      },
                  ],
              )
              # Convert response to a Python dictionary.
              response_message = completion["choices"][0]["message"][
                  "content"
              ]
              response_dict = ast.literal_eval(response_message)
              result_qa_pair = [response_dict, qa_set]
  
              print(key, "done")
  
              # Save the question-answer pairs to a json file.
              with open(f"{output_dir}/{key}.json", "w") as f:
                  json.dump(result_qa_pair, f, indent=4)
  
          except Exception as e:
              print(f"Error processing file '{key}': {e}")
  
file_path: llama-vid/llamavid/eval/evaluate_benchmark_2_detailed_orientation.py
imports: import openai
  import os
  import argparse
  import json
  import ast
  from multiprocessing.pool import Pool
label_desc: Use image node_id 2 for calling a global function with example usage: annotate(prediction_set, caption_files, output_dir) without return types