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

[BUG] Unable to change project id when using vertexai embedding configuartion. #2020

Open
iam1492 opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@iam1492
Copy link

iam1492 commented Jan 31, 2025

Description

In my crew.py source code, I want use custom embedder as google vertexai like bellow.
So I try to add configuration with my project_id to embedding_config dictionary.

embedding_config={
  "provider": "vertexai",
  "config": {
    "project_id": project_id,
    "model": "text-multilingual-embedding-002",
    "region": "us-central1",
    "api_key": access_token,
  }
}
return Crew(
  agents=self.agents,
  tasks=self.tasks,
  process=Process.sequential,
  verbose=True,
  knowledge_sources=[self.date_source],
  memory=True,
  embedder=embedding_config,
)

But unfortunately, In embedding_configurator.py in crewai.utilities package do not allow to change the project_id and region.
This make chromadb use default value.
project_id: str = "cloud-large-language-models",
region: str = "us-central1",
And of course, this default value is not my project id and api call not work as expected.

@staticmethod
    def _configure_vertexai(config, model_name):
        from chromadb.utils.embedding_functions.google_embedding_function import (
            GoogleVertexEmbeddingFunction,
        )

        return GoogleVertexEmbeddingFunction(
            model_name=model_name,
            api_key=config.get("api_key"),
        )

Steps to Reproduce

  1. Using google vertex ai as a custom embedder.

Expected behavior

Can use vertex ai with my own project_id

Screenshots/Code snippets

embedding_config={
  "provider": "vertexai",
  "config": {
    "project_id": project_id,
    "model": "text-multilingual-embedding-002",
    "region": "us-central1",
    "api_key": access_token,
  }
}
return Crew(
  agents=self.agents,
  tasks=self.tasks,
  process=Process.sequential,
  verbose=True,
  knowledge_sources=[self.date_source],
  memory=True,
  embedder=embedding_config,
)

Operating System

Ubuntu 20.04

Python Version

3.10

crewAI Version

0.100.0

crewAI Tools Version

0.33.0

Virtual Environment

Venv

Evidence

[2025-01-31 08:49:25][ERROR]: Failed to upsert documents: Expected Embedings to be non-empty list or numpy array, got in upsert.
[2025-01-31 08:49:25][WARNING]: Failed to init knowledge: Expected Embedings to be non-empty list or numpy array, got in upsert.
ERROR:root:Error during short_term search: Expected Embedings to be non-empty list or numpy array, got in query.
ERROR:root:Error during entities search: Expected Embedings to be non-empty list or numpy array, got in query

Possible Solution

Make GoogleVertexEmbeddingFunction allow to set project_id and region as well.

Additional context

No

@iam1492 iam1492 added the bug Something isn't working label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant