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

Fix the logic for creating LLM adapters. #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kompfner
Copy link
Contributor

As it was implemented, it was requiring devs to specify as pip requirements all optional LLM dependencies—google, anthropic, openai—regardless of which subset the dev actually needed.

The reason was that attempts to import from pipecat.services.<llm> would actually result in a different exception raised (Exception(f"Missing module: {e}")) than the one that was being handled (ImportError).

But something else was amiss here. By even attempting to import from an LLM service module we didn't need—say, pipecat.services.anthropic—we would inadvertently trigger some scary logger errors saying that the module and corresponding API key were missing, even though they're not needed.

It's worth noting there's no safety-related reason to import any LLM service modules here: if the dev has forgotten to install the appropriate dependency, they'll hit the error when trying to create the LLM service—e.g. AnthropicLLMService—in the first place.

Copy link

vercel bot commented Feb 20, 2025

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

Name Status Preview Updated (UTC)
pipecat-flows ✅ Ready (Inspect) Visit Preview Feb 20, 2025 8:15pm

As it was implemented, it was requiring devs to specify as pip requirements *all* optional LLM dependencies—google, anthropic, openai—regardless of which subset the dev actually needed.

The reason was that attempts to `import` from `pipecat.services.<llm>` would actually result in a different exception raised (`Exception(f"Missing module: {e}")`) than the one that was being handled (`ImportError`).

But something else was amiss here. By even *attempting* to `import` from an LLM service module we didn't need—say, `pipecat.services.anthropic`—we would inadvertently trigger some scary logger errors saying that the module and corresponding API key were missing, even though they're not needed.

It's worth noting there's no safety-related reason to import any LLM service modules here: if the dev has forgotten to install the appropriate dependency, they'll hit the error when trying to create the LLM service—e.g. `AnthropicLLMService`—in the first place.
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.

1 participant