class_docstr: Unit tests for OpenAI Info Callback
class_docstr_tok: ["Unit","tests","for","OpenAI","Info","Callback"]
code: def test_openai_callback(self, mocker):
      df = pd.DataFrame([1, 2, 3])
      llm = OpenAI(api_token="test")
      llm_response = OpenAIObject(
          {
              "choices": [
                  {
                      "text": "```df.sum()```",
                      "index": 0,
                      "logprobs": None,
                      "finish_reason": "stop",
                      "start_text": "",
                  }
              ],
              "model": llm.model,
              "usage": OpenAIObject(
                  {
                      "prompt_tokens": 2,
                      "completion_tokens": 1,
                      "total_tokens": 3,
                  }
              ),
          }
      )
      mocker.patch.object(
          llm.client, "create", return_value=llm_response
      )
  
      sdf = SmartDataframe(
          df, config={"llm": llm, "enable_cache": False}
      )
      with get_openai_callback() as cb:
          sdf.chat("some question 1")
          assert cb.total_tokens == 3
          assert cb.prompt_tokens == 2
          assert cb.completion_tokens == 1
          assert cb.total_cost > 0
  
      total_tokens = cb.total_tokens
  
      with get_openai_callback() as cb:
          sdf.chat("some question 2")
          sdf.chat("some question 3")
  
      assert cb.total_tokens == total_tokens * 2
  
      with get_openai_callback() as cb:
          sdf.chat("some question 4")
          sdf.chat("some question 5")
          sdf.chat("some question 6")
  
      assert cb.total_tokens == total_tokens * 3
  
file_path: pandas-ai/tests/helpers/test_openai_info.py
imports: import pytest
  from pandasai import SmartDataframe
  from pandasai.helpers import OpenAICallbackHandler, get_openai_callback
  import pandas
  from pandasai.llm.openai import OpenAI
label_desc: Use image node_id 6 for calling the TestOpenAIInfo obj's underlying member method code with example usage: obj.test_openai_callback(mocker) without return types