🛠️Getting set up

Step1: Import the Package

First, import the necessary classes from the maccaw package.

from maccaw import OpenaiLLM, ClaudeLLM, MistralAILLM
from maccaw import BaseTool
Step 2: Initialize the LLM

Create an instance of one of the supported LLMs by providing your API key and any optional parameters.

openai_llm = OpenaiLLM(api_key="your_openai_api_key")
claude_llm = ClaudeLLM(api_key="your_claude_api_key")
mistral_llm = MistralAILLM(api_key="your_mistral_api_key")
Step 3: Define a Tool

Create a custom tool by subclassing BaseTool and implementing the _run method.

class MyTool(BaseTool):
    def _run(self, *args, **kwargs):
        # Implement the logic for your tool here
        return "Tool output"

my_tool = MyTool(name="MyTool", description="A custom tool")
Step 4: Get Completions

Use the LLM instance to get completions based on the defined tool and messages.

messages = [{"role": "user", "content": "Hello, how are you?"}]
tools = [my_tool]

response = openai_llm.ava_llm_completions(messages=messages, tools=tools)
print(response)

Last updated