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

Closed
deb007 opened this issue Apr 30, 2024 · 12 comments
Closed

Azure Openai support in tool config #541

deb007 opened this issue Apr 30, 2024 · 12 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)

@theholymath
Copy link

theholymath commented Jun 17, 2024

This solution executes (the parameters are accepted) but it's not constructing a RAG DB for me. Weirdly, when I use the code with openAI (not AzureopenAI) it creates the Chroma DB as normal. Then, if I use my code as @DavidGayda outlines above with AzureOpenAI it adds the new text to that existing DB.

Copy link

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@ecocarlisle
Copy link

Hello, following up on this issue. Is there a fix available for using PDFSearchTool and Azure OpenAI?

@PiXOT97
Copy link

PiXOT97 commented Aug 29, 2024

Same question, anyone figure out this?

@theCyberTech
Copy link
Collaborator

Same question, anyone figure out this?

#541 (comment)

Copy link

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@sorin-costea
Copy link

I have no idea what's to be done to get Azure OpenAI working. Not even the very basic initial program generated by crewai init works. LiteLLM mentions setting three env variables, they still don't work. I assume some people are able to do it as the above comments are already advanced, but apparently nobody left a written trace of the basics...

@henkbb36org
Copy link

default_llm = LLM(
model="azure/gpt-4o",
api_key=os.environ.get("AZURE_OPENAI_KEY"),
base_url=os.environ.get("AZURE_OPENAI_ENDPOINT"),
)

researcher = Agent(
role='your role',
goal='your goal',
verbose=True,
memory=False,
backstory=(
"Your prompt"
),
llm=default_llm,
allow_delegation=True
)

Copy link

github-actions bot commented Nov 9, 2024

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants