From 0b5f0841bf235eb029e4d24c19efd00c90bbeccd Mon Sep 17 00:00:00 2001 From: Minura Punchihewa Date: Fri, 3 Jan 2025 00:32:24 +0530 Subject: [PATCH] implemented the run function for the tool --- .../tools/ai_minds_tool/ai_minds_tool.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py b/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py index 411daf209..915ed1ca0 100644 --- a/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py +++ b/src/crewai_tools/tools/ai_minds_tool/ai_minds_tool.py @@ -58,4 +58,20 @@ class AIMindTool(BaseTool): name=name, datasources=datasources, replace=True ) - self.mind_name = mind.name \ No newline at end of file + self.mind_name = mind.name + + def _run( + self, + query: Text + ): + # Run the query on the AI-Mind. + # The Minds API is OpenAI compatible and therefore, the OpenAI client can be used. + openai_client = OpenAI(base_url="https://mdb.ai/", api_key=self.api_key) + + completion = openai_client.create( + model=self.mind_name, + messages=[{"role": "user", "content": query}], + stream=False, + ) + + return completion.choices[0].message.content \ No newline at end of file