mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-01 11:56:24 +02:00
Merge pull request #25 from send18/feature-openai-settings
remove openai global settings
This commit is contained in:
commit
c4cf84aac7
1 changed files with 5 additions and 10 deletions
|
|
@ -77,21 +77,12 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter):
|
|||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.__init_openai(CONFIG)
|
||||
self.llm = openai
|
||||
self.model = CONFIG.openai_api_model
|
||||
self.auto_max_tokens = False
|
||||
self.rpm = int(CONFIG.get("RPM", 10))
|
||||
RateLimiter.__init__(self, rpm=self.rpm)
|
||||
|
||||
def __init_openai(self, config):
|
||||
openai.api_key = config.openai_api_key
|
||||
if config.openai_api_base:
|
||||
openai.api_base = config.openai_api_base
|
||||
if config.openai_api_type:
|
||||
openai.api_type = config.openai_api_type
|
||||
openai.api_version = config.openai_api_version
|
||||
self.rpm = int(config.get("RPM", 10))
|
||||
|
||||
async def _achat_completion_stream(self, messages: list[dict]) -> str:
|
||||
response = await self.async_retry_call(
|
||||
openai.ChatCompletion.acreate, **self._cons_kwargs(messages), stream=True
|
||||
|
|
@ -133,6 +124,10 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter):
|
|||
"temperature": 0.3,
|
||||
}
|
||||
kwargs["timeout"] = 3
|
||||
kwargs["api_base"] = CONFIG.openai_api_base
|
||||
kwargs["api_key"] = CONFIG.openai_api_key
|
||||
kwargs["api_type"] = CONFIG.openai_api_type
|
||||
kwargs["api_version"] = CONFIG.openai_api_version
|
||||
return kwargs
|
||||
|
||||
async def _achat_completion(self, messages: list[dict]) -> dict:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue