How to configure colab to use Azure OpenAI API
I am trying to run the colab found on the documentation. How to set the env variables to use Azure OpenAI API? I can't find the
~/.metagpt/config2.yaml
to update with Azure OpenAI API env variables.
可参考:#1690
Hello @seehi,
Thanks for the quick response. I used the following to set the env variables
metagpt.const.API_KEY = userdata.get('OPENAI_API_KEY')
metagpt.const.MODEL = userdata.get('MODEL_NAME')
metagpt.const.API_TYPE = userdata.get('OPENAI_API_TYPE')
metagpt.const.API_VERSION = userdata.get('OPENAI_API_VERSION')
metagpt.const.BASE_URL = userdata.get('AZURE_OPENAI_ENDPOINT')
But when I run the cell
import asyncio
from metagpt.roles import (
Architect,
Engineer,
ProductManager,
ProjectManager,
)
from metagpt.team import Team
I am getting error
RecursionError Traceback (most recent call last)
[<ipython-input-5-46a1bd52cacd>](https://localhost:8080/#) in <cell line: 0>()
1 import asyncio
2
----> 3 from metagpt.roles import (
4 Architect,
5 Engineer,
11 frames
... last 2 frames repeated, from the frame below ...
[/usr/local/lib/python3.11/dist-packages/metagpt/config.py](https://localhost:8080/#) in get_default_llm_provider_enum(self)
112 if provider is LLMProviderEnum.GEMINI and not require_python_version(req_version=(3, 10)):
113 warnings.warn("Use Gemini requires Python >= 3.10")
--> 114 model_name = self.get_model_name(provider=provider)
115 if model_name:
116 logger.info(f"{provider} Model: {model_name}")
RecursionError: maximum recursion depth exceeded while calling a Python object
Such as:
from pathlib import Path
import metagpt.const
# 1. Change CONFIG_ROOT
metagpt.const.CONFIG_ROOT = Path.cwd()
# 2. Create config2.yaml
content = '''llm:
api_type: "openai" # or azure / ollama / open_llm etc. Check LLMType for more options
model: "gpt-4-turbo-preview" # or gpt-3.5-turbo-1106 / gpt-4-1106-preview
base_url: "https://api.openai.com/v1" # or forward url / other llm url
api_key: "xxx"'''
with open('config2.yaml', 'w') as f:
f.write(content)
This issue has no activity in the past 30 days. Please comment on the issue if you have anything to add.
I will check the proposed solution and let you know.
Thanks
This issue has no activity in the past 30 days. Please comment on the issue if you have anything to add.