-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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] dalle_tool demands OPEN_API_KEY setting when using Azure #1422
Comments
Fixed by writing a custom_dalle_tool.py: class ImagePromptSchema(BaseModel):
class MyCustomDallETool(BaseTool):
Can be used in a from crewai script: |
Description
I am trying to use the dalle-tool with an OpenAI implementation on Azure. The Crewai Agents in my script work well, WebsiteSearchTool works well but dalle-tool demands an OPEN_API_KEY setting in the environment (which does not work when I set it to my AzureOpenAI key, it will give invalid API key). I configured the dalle-tool like so:
dalle_tool = DallETool(
config = {
"embedder": {
"provider": "azure_openai",
"config": {
"api_key":os.environ.get("AZURE_OPENAI_KEY"),
"model": "dall-e-3",
},
}
}
)
The same type of config works well for the WebsiteSearchTool. I cannot find any documentation or examples on how to get this working Azure. Any help?
Steps to Reproduce
The Agent is configure like so:
illustrator = Agent(
role='Illustrator',
goal='Generate an image based on….,
verbose=True,
memory=True,
backstory=(
"You are an …."
),
tools=[dalle_tool],
llm=default_llm,
allow_delegation=False
)
When running my test script it fails with the error:
I encountered an error while trying to use the tool. This was the error: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: 696be861********************4a04. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}.
When I don't set any value in the environment variable OPEN_API_KEY it will give the error that the value is not set. Llm is configured using LiteLLM like so:
default_llm = LLM(
model="azure/gpt-4o",
api_key=os.environ.get("AZURE_OPENAI_KEY"),
base_url=os.environ.get("AZURE_OPENAI_ENDPOINT"),
)
The proper values are in the .env which is loaded by load_dotenv(). Agent functions work well, as well the WebsiteSearchTool
Expected behavior
I hoped the DallETool would to use the azure apenai implementation but I cannot get it to do that.
Screenshots/Code snippets
None
Operating System
macOS Sonoma
Python Version
3.11
crewAI Version
0.67.1
crewAI Tools Version
0.12.1
Virtual Environment
Venv
Evidence
I encountered an error while trying to use the tool. This was the error: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: 696be861********************4a04. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}.
Tool Dall-E Tool accepts these inputs: Dall-E Tool(image_description: 'string') - Generates images using OpenAI's Dall-E model.
Possible Solution
None
Additional context
None
The text was updated successfully, but these errors were encountered: