From 20021f712a87cdf9bd1039a5cad544346b87eb07 Mon Sep 17 00:00:00 2001 From: Zack Date: Wed, 15 Nov 2023 09:49:38 -0600 Subject: [PATCH] fix: Refactor open ai api Former-commit-id: ff72f3416fb605f612b4b929f7afde1e2a0cc16e --- example.py | 4 ++-- swarms/models/__init__.py | 18 +++++++++--------- swarms/models/openai_models.py | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/example.py b/example.py index 5e5943ed..c66c5454 100644 --- a/example.py +++ b/example.py @@ -12,7 +12,7 @@ api_key = os.environ.get("OPENAI_API_KEY") # Initialize the language model, this model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC llm = OpenAI( # model_name="gpt-4" - # openai_api_key=api_key, + openai_api_key=api_key, temperature=0.5, # max_tokens=100, ) @@ -23,7 +23,7 @@ flow = Flow( llm=llm, max_loops=2, dashboard=True, - # tools=[search_api] + # tools = [search_api, slack, ] # stopping_condition=None, # You can define a stopping condition as needed. # loop_interval=1, # retry_attempts=3, diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index e946bffd..bdaea689 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -5,15 +5,15 @@ import sys # LLMs -from swarms.models.anthropic import Anthropic # noqa: E402 -from swarms.models.petals import Petals # noqa: E402 -from swarms.models.mistral import Mistral # noqa: E402 -from swarms.models.openai_models import OpenAI, AzureOpenAI, OpenAIChat # noqa: E402 -from swarms.models.zephyr import Zephyr # noqa: E402 -from swarms.models.biogpt import BioGPT # noqa: E402 -from swarms.models.huggingface import HuggingfaceLLM # noqa: E402 -from swarms.models.wizard_storytelling import WizardLLMStoryTeller # noqa: E402 -from swarms.models.mpt import MPT7B # noqa: E402 +from swarms.models.anthropic import Anthropic +from swarms.models.petals import Petals +from swarms.models.mistral import Mistral +from swarms.models.openai_models import OpenAIChat, AzureOpenAI, OpenAI +from swarms.models.zephyr import Zephyr +from swarms.models.biogpt import BioGPT +from swarms.models.huggingface import HuggingfaceLLM +from swarms.models.wizard_storytelling import WizardLLMStoryTeller +from swarms.models.mpt import MPT7B # MultiModal Models from swarms.models.idefics import Idefics # noqa: E402 diff --git a/swarms/models/openai_models.py b/swarms/models/openai_models.py index f420173a..f6db1c46 100644 --- a/swarms/models/openai_models.py +++ b/swarms/models/openai_models.py @@ -1,5 +1,6 @@ from __future__ import annotations +"""OpenAI chat wrapper.""" import logging import os import sys