llama-index-llms-openai 0.1.28__py3-none-any.whl → 0.1.30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -604,18 +604,29 @@ class OpenAI(FunctionCallingLLM):
604
604
 
605
605
  def _get_response_token_counts(self, raw_response: Any) -> dict:
606
606
  """Get the token usage reported by the response."""
607
- if not isinstance(raw_response, dict):
608
- return {}
609
-
610
- usage = raw_response.get("usage", {})
611
- # NOTE: other model providers that use the OpenAI client may not report usage
612
- if usage is None:
607
+ if hasattr(raw_response, "usage"):
608
+ try:
609
+ prompt_tokens = raw_response.usage.prompt_tokens
610
+ completion_tokens = raw_response.usage.completion_tokens
611
+ total_tokens = raw_response.usage.total_tokens
612
+ except AttributeError:
613
+ return {}
614
+ elif isinstance(raw_response, dict):
615
+ usage = raw_response.get("usage", {})
616
+ # NOTE: other model providers that use the OpenAI client may not report usage
617
+ if usage is None:
618
+ return {}
619
+ # Backwards compatibility with old dict type
620
+ prompt_tokens = usage.get("prompt_tokens", 0)
621
+ completion_tokens = usage.get("completion_tokens", 0)
622
+ total_tokens = usage.get("total_tokens", 0)
623
+ else:
613
624
  return {}
614
625
 
615
626
  return {
616
- "prompt_tokens": usage.get("prompt_tokens", 0),
617
- "completion_tokens": usage.get("completion_tokens", 0),
618
- "total_tokens": usage.get("total_tokens", 0),
627
+ "prompt_tokens": prompt_tokens,
628
+ "completion_tokens": completion_tokens,
629
+ "total_tokens": total_tokens,
619
630
  }
620
631
 
621
632
  # ===== Async Endpoints =====
@@ -47,6 +47,7 @@ GPT4_MODELS: Dict[str, int] = {
47
47
  "gpt-4-turbo": 128000,
48
48
  "gpt-4o": 128000,
49
49
  "gpt-4o-2024-05-13": 128000,
50
+ "gpt-4o-2024-08-06": 128000,
50
51
  "gpt-4o-mini": 128000,
51
52
  "gpt-4o-mini-2024-07-18": 128000,
52
53
  # 0613 models (function calling):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: llama-index-llms-openai
3
- Version: 0.1.28
3
+ Version: 0.1.30
4
4
  Summary: llama-index llms openai integration
5
5
  License: MIT
6
6
  Author: llama-index
@@ -0,0 +1,6 @@
1
+ llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
+ llama_index/llms/openai/base.py,sha256=j-BiZ9E3pFG2RDSP8Vq75SHfZCId9XU5ymAddBF8x8I,33876
3
+ llama_index/llms/openai/utils.py,sha256=VuDXkLR_BGVqoZc9IJqiJlVloZwG9Z7s1nGPAhlbvWE,13079
4
+ llama_index_llms_openai-0.1.30.dist-info/METADATA,sha256=VnG5MXkR-ZUoxou8H9tUsy1uY8zGoC578GUG0Dx5Eoc,650
5
+ llama_index_llms_openai-0.1.30.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
+ llama_index_llms_openai-0.1.30.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- llama_index/llms/openai/__init__.py,sha256=vm3cIBSGkBFlE77GyfyN0EhpJcnJZN95QMhPN53EkbE,148
2
- llama_index/llms/openai/base.py,sha256=XX74bUlw8I20lqlMjGvlga6y565c2RUXFM5b-UQDZtQ,33338
3
- llama_index/llms/openai/utils.py,sha256=djxNH9V6ye93Mn9yI57pQ8ULHET2QqlVmpFsAcxJfdo,13046
4
- llama_index_llms_openai-0.1.28.dist-info/METADATA,sha256=ZAaKgeA6zLH50nOlJJ7U_f3fgVb40oYFxsM9QAjSNs0,650
5
- llama_index_llms_openai-0.1.28.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- llama_index_llms_openai-0.1.28.dist-info/RECORD,,