Skip to content

[Cursor] fix: Correct reasoning_tokens access for o1 model #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/llm_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def query_llm(prompt: str, client=None, model=None, provider="openai", image_pat
prompt_tokens=response.usage.prompt_tokens,
completion_tokens=response.usage.completion_tokens,
total_tokens=response.usage.total_tokens,
reasoning_tokens=response.usage.completion_tokens_details.reasoning_tokens if model.lower().startswith("o") else None # Only checks if model starts with "o", e.g., o1, o1-preview, o1-mini, o3, etc. Can update this logic to specific models in the future.
reasoning_tokens=response.usage.reasoning_tokens if hasattr(response.usage, 'reasoning_tokens') and model.lower().startswith("o") else None
)

# Calculate cost
Expand Down