From bad6990c431961867295f5e22ef7261bf9344639 Mon Sep 17 00:00:00 2001 From: Kye Date: Sat, 23 Sep 2023 23:18:37 -0400 Subject: [PATCH] worker documentation Former-commit-id: cb640a79839fd7ed27f22ae5d0f4390e63468b9e --- swarms/workers/worker.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/swarms/workers/worker.py b/swarms/workers/worker.py index 7a098e50..ba2ccbf4 100644 --- a/swarms/workers/worker.py +++ b/swarms/workers/worker.py @@ -32,22 +32,30 @@ class Worker: ai_role="Worker in a swarm", external_tools = None, human_in_the_loop=False, - temperature=0.5 + temperature=0.5, + llm=None, + openai: bool = True, ): self.openai_api_key = openai_api_key self.temperature = temperature self.human_in_the_loop = human_in_the_loop - try: - self.llm = ChatOpenAI( + if self.openai is True: + try: + self.llm = ChatOpenAI( + model_name=model_name, + openai_api_key=self.openai_api_key, + temperature=self.temperature + ) + except Exception as error: + raise RuntimeError(f"Error Initializing ChatOpenAI: {error}") + else: + self.llm = llm( model_name=model_name, - openai_api_key=self.openai_api_key, temperature=self.temperature ) - except Exception as error: - raise RuntimeError(f"Error Initializing ChatOpenAI: {error}") - + self.ai_name = ai_name self.ai_role = ai_role