Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 29, 2025

Summary

Fixes GitHub issue #3995 where users couldn't configure the HuggingFace embedder with the documented configuration format (api_key, model, api_url).

The root cause was that HuggingFaceProvider was using ChromaDB's HuggingFaceEmbeddingServer (which requires a url parameter for custom embedding servers) instead of HuggingFaceEmbeddingFunction (which uses the HuggingFace Inference API with api_key and model_name).

Changes:

  • Switch from HuggingFaceEmbeddingServer to HuggingFaceEmbeddingFunction
  • Add api_key, model_name, and api_key_env_var fields with appropriate validation aliases
  • Accept api_url/url for compatibility with docs but exclude from model_dump (not used by Inference API)
  • Update HuggingFaceProviderConfig TypedDict with new fields
  • Add comprehensive tests

Review & Testing Checklist for Human

  • Verify the api_url being silently ignored is acceptable - The field is accepted for compatibility with the documented config but excluded from the underlying call. Users might expect it to configure a custom endpoint. Consider if a warning should be logged.
  • Check for breaking changes - The old provider required url and used HuggingFaceEmbeddingServer. Verify no existing users depend on that behavior (search for "provider": "huggingface" usage in production).
  • Review uv.lock changes - The lock file was regenerated due to corruption. Scan for any unexpected dependency version changes that could cause issues.
  • Test with real HuggingFace API - The automated tests don't call the actual API. Recommend testing with a real HF token:
    from crewai import Crew
    crew = Crew(
        agents=[...],
        tasks=[...],
        memory=True,
        embedder={
            "provider": "huggingface",
            "config": {
                "api_key": os.getenv("HF_TOKEN"),
                "model": "sentence-transformers/all-MiniLM-L6-v2"
            }
        }
    )

Notes

- Update HuggingFaceProvider to use HuggingFaceEmbeddingFunction instead of
  HuggingFaceEmbeddingServer for HuggingFace Inference API support
- Add api_key, model_name, and api_key_env_var fields to match documented config
- Accept api_url for compatibility but exclude from model_dump (not used by
  HuggingFace Inference API)
- Add validation aliases for model (maps to model_name) and environment variables
- Update HuggingFaceProviderConfig TypedDict with new fields
- Add comprehensive tests for HuggingFace provider configuration
- Regenerate uv.lock (was corrupted)

Fixes #3995

Co-Authored-By: João <[email protected]>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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