implemented the run function for the tool

This commit is contained in:
Minura Punchihewa
2025-01-03 00:32:24 +05:30
parent 55f669989b
commit 0b5f0841bf

View File

@@ -58,4 +58,20 @@ class AIMindTool(BaseTool):
name=name, datasources=datasources, replace=True
)
self.mind_name = mind.name
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