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

OPENAI_API_KEY missing error when running the End-to-end example from Azure OpenAI docs #629

Open
yashworlikar opened this issue Dec 11, 2024 · 1 comment

Comments

@yashworlikar
Copy link

yashworlikar commented Dec 11, 2024

I encountered an error while running the End-to-end example from the Azure OpenAI documentation. The error indicates that the OPENAI_API_KEY is not set .

Error Message:


Traceback (most recent call last):
  File "C:\Applications\Application\autoLLM\demo.py", line 21, in <module>
    world_model = WorldModel()
                  ^^^^^^^^^^^^
  File "C:\Applications\Application\autoLLM\venv\Lib\site-packages\lavague\core\world_model.py", line 377, in __init__
    mm_llm = get_default_context().mm_llm
             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Applications\Application\autoLLM\venv\Lib\site-packages\lavague\core\context.py", line 35, in get_default_context
    return OpenaiContext()
           ^^^^^^^^^^^^^^^
  File "C:\Applications\Application\autoLLM\venv\Lib\site-packages\lavague\contexts\openai\base.py", line 23, in __init__
    raise ValueError("OPENAI_API_KEY is not set")
ValueError: OPENAI_API_KEY is not set

Steps to Reproduce:

  1. Follow the End-to-end example from the Azure OpenAI documentation.
  2. Fill in the required Azure configs
  3. Run the provided code snippet.

Code Snippet:

from lavague.core import WorldModel, ActionEngine
from lavague.core.agents import WebAgent
from lavague.drivers.selenium import SeleniumDriver
from lavague.contexts.openai import AzureOpenaiContext

# Initialize context with our custom elements
context = AzureOpenaiContext(
    api_key="your_api_key",
    deployment="deployment_name",
    llm="<model_name>",
    mm_llm="<model_name>",
    endpoint="<your_endpoint>",
    embedding="embedding_model_name",
    embedding_deployment="embedding_deployment_name"
)

selenium_driver = SeleniumDriver()

# Build Action Engine and World Model from Context
action_engine = ActionEngine.from_context(context=context, driver=selenium_driver)
world_model = WorldModel()

# Build agent & run query
agent = WebAgent(world_model, action_engine)
agent.get("https://huggingface.co/")
agent.run("What is this week's top Space of the week?")

Expected Behavior: The code should run without errors and perform the intended actions.

Actual Behavior: The code raises a ValueError indicating that the OPENAI_API_KEY is not set.

Passing the mm_llm from the context to the WorldModel when creating an instance of it fixes it.

world_model = WorldModel(mm_llm=context.mm_llm) 
@hi0001234d
Copy link

have you tried "export OPENAI_API_KEY=[your open ai key]" in the terminal

just wondering if that's the case

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