Skip to content

Conversation

@senko
Copy link
Owner

@senko senko commented Aug 16, 2025

This will become the default backend in the future (replacing inhouse backends), so it's immediately required as a non-optional dep.

This will become the default backend in the future (replacing inhouse
backends), so it's immediately required as a non-optional dep.
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@senko senko requested a review from Copilot August 16, 2025 14:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for LiteLLM as a new backend provider, which will replace in-house backends in the future. LiteLLM provides a unified interface to 100+ LLM providers through an OpenAI-compatible API format.

  • Implements LiteLLMAdapter to convert between think's internal format and OpenAI-compatible format
  • Adds LiteLLMClient as the main entry point for LiteLLM functionality
  • Integrates LiteLLM into the existing provider system with registration and configuration

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
think/llm/litellm.py Complete implementation of LiteLLM adapter and client classes
think/llm/base.py Adds "litellm" to providers list and registers LiteLLMClient
tests/llm/test_litellm_adapter.py Comprehensive test suite for the LiteLLM adapter functionality
tests/conftest.py Adds LiteLLM model URL to test configuration when OpenAI API key is available
pyproject.toml Adds litellm>=1.75.7 as a required dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

arguments = tc.get("function", {}).get("arguments")
if arguments is None:
raise ValueError(
"Missing function arguments in assistant message: %r", tc
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The ValueError constructor is being called with two arguments, but the second argument tc is not formatted into the string. This should use string formatting like f"Missing tool call ID in assistant message: {tc!r}" or use a single string argument.

Suggested change
"Missing function arguments in assistant message: %r", tc
f"Missing tool call ID in assistant message: {tc!r}"
)
name = tc.get("function", {}).get("name")
if name is None:
raise ValueError(
f"Missing function name in assistant message: {tc!r}"
)
arguments = tc.get("function", {}).get("arguments")
if arguments is None:
raise ValueError(
f"Missing function arguments in assistant message: {tc!r}"

Copilot uses AI. Check for mistakes.
name = tc.get("function", {}).get("name")
if name is None:
raise ValueError(
"Missing function name in assistant message: %r", tc
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The ValueError constructor is being called with two arguments, but the second argument tc is not formatted into the string. This should use string formatting like f"Missing function name in assistant message: {tc!r}" or use a single string argument.

Suggested change
"Missing function name in assistant message: %r", tc
f"Missing function name in assistant message: {tc!r}"

Copilot uses AI. Check for mistakes.
arguments = tc.get("function", {}).get("arguments")
if arguments is None:
raise ValueError(
"Missing function arguments in assistant message: %r", tc
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The ValueError constructor is being called with two arguments, but the second argument tc is not formatted into the string. This should use string formatting like f"Missing function arguments in assistant message: {tc!r}" or use a single string argument.

Suggested change
"Missing function arguments in assistant message: %r", tc
f"Missing function arguments in assistant message: {tc!r}"

Copilot uses AI. Check for mistakes.
elif role == "user":
raw_content = message.get("content")
if raw_content is None:
raise ValueError("Missing content in user message: %r", message)
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The ValueError constructor is being called with two arguments, but the second argument message is not formatted into the string. This should use string formatting like f"Missing content in user message: {message!r}" or use a single string argument.

Suggested change
raise ValueError("Missing content in user message: %r", message)
raise ValueError(f"Missing content in user message: {message!r}")

Copilot uses AI. Check for mistakes.
parts.append(
ContentPart(
type=ContentType.text,
text=text or "",
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The expression text or "" is redundant since text is already guaranteed to be non-None and non-empty due to the if text: condition on line 220. The fallback to empty string is unnecessary here.

Suggested change
text=text or "",
text=text,

Copilot uses AI. Check for mistakes.
@senko senko merged commit 2f11e35 into main Aug 16, 2025
4 checks passed
@senko senko deleted the litellm branch August 16, 2025 14:25
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