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

Bugfix: azure llm manager #55

Merged
merged 2 commits into from
Oct 17, 2023
Merged

Bugfix: azure llm manager #55

merged 2 commits into from
Oct 17, 2023

Conversation

bx-h
Copy link
Contributor

@bx-h bx-h commented Oct 17, 2023

Environment

  • lida : 0.0.9

Problem

I'm an Azure OpenAI user and encountered an error when using the code snippet provided in the tutorial:

text_gen = llm(provider="openai", api_type="azure", api_base=os.environ["AZURE_OPENAI_BASE"], api_key=os.environ["AZURE_OPENAI_API_KEY"],    api_version="2023-07-01-preview") # for azure openai
lida = Manager(llm=text_gen)

Error: Manager.init() got an unexpected keyword argument 'llm'

When I change it to

lida = Manager(text_gen=text_gen)

Error: openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.chat_completion.ChatCompletion'>

Suggested Changes

Consider updating the snippet to (which works well for me):

from llmx.generators.text.openai_textgen import OpenAITextGenerator
from llmx.generators.text.textgen import sanitize_provider

provider = sanitize_provider("azureopenai")
models = {}

text_gen = OpenAITextGenerator(
    api_key=os.environ["AZURE_OPENAI_API_KEY"],
    api_base=os.environ["AZURE_OPENAI_BASE"],
    provider=provider,
    models=models
)
lida = Manager(text_gen=text_gen)

@victordibia
Copy link
Collaborator

Thanks for catching this.

@victordibia victordibia merged commit 69ecbe9 into microsoft:main Oct 17, 2023
@bx-h bx-h deleted the bugfix-azure-llm-manager branch January 8, 2024 11:25
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