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

Azure Openai support in tool config #541

Open
deb007 opened this issue Apr 30, 2024 · 2 comments
Open

Azure Openai support in tool config #541

deb007 opened this issue Apr 30, 2024 · 2 comments

Comments

@deb007
Copy link

deb007 commented Apr 30, 2024

Hello, I am trying out the PDFSearchTool with Azure OpenAI. I see provider = azure_openai is a valid option but I am unable to get it working.
This is my current code:

mytool = PDFSearchTool(
    pdf="abcd.pdf",
    config=dict(
        llm=dict(
            provider="azure_openai",  # or google, openai, anthropic, llama2, ...
            config=dict(
                model="gpt4",
                azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT"),
                api_key=os.getenv("AZURE_OPENAI_KEY"),
                azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
                # top_p=1,
                # stream=true,
            ),
        ),
        embedder=dict(
            provider="azure_openai",
            config=dict(
                model="text-embedding-ada-002",
                deployment_name="text-embedding-ada-002",
                # title="Embeddings",
            ),
        ),
    ),
)

Getting error:

schema.SchemaError: Key 'llm' error:
Key 'config' error:
Wrong keys 'azure_deployment', 'azure_endpoint' in {... ... }

Any kind of help will be much appreciated.

@DavidGayda
Copy link

I am also having this issue, and have not yet found a resolution.

@DavidGayda
Copy link

I believe it is now working correctly for me. I had to do 2 things.

  1. Find the correct key names to use. I have model, deployment_name, and api_key set here from my environment variables.

tool = PDFSearchTool(
pdf='file.pdf',
config=dict(
llm=dict(
provider="azure_openai", # or google, openai, anthropic, llama2, ...
config=dict(
model=os.environ.get("MODEL"),
deployment_name=os.environ.get("DEPLOYMENT_NAME"),
api_key=os.environ.get("AZURE_OPENAI_KEY"),
),
),
embedder=dict(
provider="azure_openai", # or openai, ollama, ...
config=dict(
model="text-embedding-ada-002",
deployment_name="text-embedding-ada-002",
api_key=os.environ.get("AZURE_OPENAI_KEY"),
),
),
)
)

  1. I believe there may be an issue in the embed chain package that CrewAI uses. In the embedchain/embedder/openai.py file in that package Line 23 I updated to pass in the api_key and api_base

embeddings = AzureOpenAIEmbeddings(deployment=self.config.deployment_name, api_key=api_key, base_url=api_base)

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

No branches or pull requests

2 participants