Skip to content

(refactor) anthropic - move _process_response in transformation.py - #6834

Merged
ishaan-jaff merged 2 commits into
mainfrom
litellm_refactor_anthropic
Nov 21, 2024
Merged

(refactor) anthropic - move _process_response in transformation.py #6834
ishaan-jaff merged 2 commits into
mainfrom
litellm_refactor_anthropic

Conversation

@ishaan-jaff

@ishaan-jaff ishaan-jaff commented Nov 20, 2024

Copy link
Copy Markdown
Contributor

Title

Relevant issues

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

[REQUIRED] Testing - Attach a screenshot of any new tests passing locall

If UI changes, send a screenshot/GIF of working UI fixes

Description by Korbit AI

What change is being made?

Refactor the Anthropic module by moving the _process_response method and _convert_tool_response_to_message static method from handler.py to transformation.py.

Why are these changes being made?

These changes are made to improve code organization and modularity by relocating the response processing functionality to a more appropriate module, transformation.py. This refactoring supports better code maintenance and readability. The decision to move these methods was driven by their relevance to data transformation activities rather than direct request handling.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@korbit-ai

korbit-ai Bot commented Nov 20, 2024

Copy link
Copy Markdown

Hey there, my name is Korbit. I've joined the team as your AI code reviewer. I'll automatically scan your PRs and raise any issues I find. I can also help you write a PR description. As you work with me, I'll learn about your priorities and codebase and get smarter over time. My goal is to help improve your code quality and save time for the human reviewers on your team. Let's get started!

@vercel

vercel Bot commented Nov 20, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 20, 2024 8:08pm

@korbit-ai korbit-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary by Korbit AI

Code Health Comments

  • Add a log statement before raising AnthropicError to enhance debugging and provide exception context efficiently.
Files scanned
File Path Reviewed
litellm/llms/anthropic/chat/transformation.py
litellm/llms/anthropic/chat/handler.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Current Korbit Configuration

General Settings
Setting Value
Review Schedule Automatic excluding drafts
Max Issue Count 10
Automatic PR Descriptions
Issue Categories
Category Enabled
Naming
Database Operations
Documentation
Logging
Error Handling
Systems and Environment
Objects and Data Structures
Readability and Maintainability
Asynchronous Processing
Design Patterns
Third-Party Libraries
Performance
Security
Functionality

Feedback and Support

Comment on lines +586 to +594
except Exception as e:
response_headers = getattr(response, "headers", None)
raise AnthropicError(
message="Unable to get json response - {}, Original Response: {}".format(
str(e), response.text
),
status_code=response.status_code,
headers=response_headers,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Error Handling severity potentially major

Add a log statement before raising the AnthropicError.

Tell me more

Consider adding a log statement before raising the AnthropicError. This would help with debugging by providing more context about the exception. For example, you could add a line like logging.error(f"Error parsing JSON response: {str(e)}") before raising the exception.

Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.

@ghost

ghost commented Nov 21, 2024

Copy link
Copy Markdown

hey @ishaan-jaff can we rename this to transform_response? this will keep it consistent with naming convention in other configs

@ishaan-berri
ishaan-berri deleted the litellm_refactor_anthropic branch March 26, 2026 21:55
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…erriAI#6834)

* move _process_response in transformation

* fix AnthropicConfig test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant