Skip to content
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

feat: Add new model provider Novita AI #1508

Merged
merged 5 commits into from
Jan 11, 2025
Merged

Conversation

jasonhp
Copy link
Contributor

@jasonhp jasonhp commented Jan 7, 2025

  1. Add new model provider Novita AI
  2. Add try-catch on calling litellm.completion_cost. Will set the cost to 0 if model information from LiteLLM is missing.

Important

Adds Novita AI as a new model provider and implements error handling for missing model information in cost calculation.

  • Behavior:
    • Adds Novita AI as a new model provider with multiple models in config_registry.py.
    • Adds error handling in api_handler_factory.py for litellm.completion_cost to set cost to 0 if model info is missing.
  • Configuration:
    • Updates .env.example and config.py to include Novita AI settings.
    • Modifies setup.sh to configure Novita AI during setup.
  • Documentation:
    • Updates README.md to list Novita AI as a supported provider.

This description was created by Ellipsis for 2d35731. It will automatically update as commits are pushed.

@jasonhp jasonhp mentioned this pull request Jan 7, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 2d35731 in 1 minute and 46 seconds

More details
  • Looked at 263 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skyvern/forge/sdk/api/llm/api_handler_factory.py:148
  • Draft comment:
    The logging statement uses an incorrect keyword argument error. Use exc_info=True to log the exception details.
LOG.error("Failed to calculate LLM cost", exc_info=True)
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The try-except block for calculating LLM cost is correctly implemented, but the logging statement uses an incorrect keyword argument 'error'.
2. skyvern/forge/sdk/api/llm/api_handler_factory.py:287
  • Draft comment:
    The logging statement uses an incorrect keyword argument error. Use exc_info=True to log the exception details.
LOG.error("Failed to calculate LLM cost", exc_info=True)
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The try-except block for calculating LLM cost is correctly implemented, but the logging statement uses an incorrect keyword argument 'error'.

Workflow ID: wflow_y5grCcWYZoI2ySC8


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -142,7 +142,11 @@ async def llm_api_handler_with_router_and_fallback(
observer_thought=observer_thought,
)
if step:
llm_cost = litellm.completion_cost(completion_response=response)
try:
llm_cost = litellm.completion_cost(completion_response=response)
Copy link
Contributor

Choose a reason for hiding this comment

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

This error handling block is duplicated. Consider extracting this into a helper function to avoid code duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I fix this? The origin code is duplicated, too.

Copy link
Contributor

Choose a reason for hiding this comment

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

no it's OK

try:
llm_cost = litellm.completion_cost(completion_response=response)
except Exception as e:
LOG.error("Failed to calculate LLM cost", error=str(e))
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use LOG.exception here instead as that will log the stacktrace automatically

try:
llm_cost = litellm.completion_cost(completion_response=response)
except Exception as e:
LOG.error("Failed to calculate LLM cost", error=str(e))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("Failed to calculate LLM cost", error=str(e))
LOG.exception("Failed to calculate LLM cost", error=str(e))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

try:
llm_cost = litellm.completion_cost(completion_response=response)
except Exception as e:
LOG.error("Failed to calculate LLM cost", error=str(e))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("Failed to calculate LLM cost", error=str(e))
LOG.exception("Failed to calculate LLM cost", error=str(e))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@suchintan suchintan left a comment

Choose a reason for hiding this comment

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

This is great

@suchintan
Copy link
Contributor

@jasonhp are you open to fixing the mypy + ruff errors?

@suchintan
Copy link
Contributor

I'll get this merged right after :) it's in a really good state

@jasonhp
Copy link
Contributor Author

jasonhp commented Jan 10, 2025

@jasonhp are you open to fixing the mypy + ruff errors?

Ruff error fixed

@suchintan suchintan merged commit e54977e into Skyvern-AI:main Jan 11, 2025
2 checks passed
@suchintan
Copy link
Contributor

Thank you for your first commit!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants