handshake-angleOpenAI Assistant

Crowe Assistant API Integration

The CroweAssistant class serves as a powerful abstraction over OpenAI's Assistants API, fully integrated into the Crowe multi-agent and tool orchestration framework. It streamlines the process of creating intelligent assistants, managing multi-turn conversations, and integrating custom tools/functions into automated workflows.


Overview

With CroweAssistant, you can:

  • Instantiate assistants with specific roles, skills, and capabilities.

  • Attach custom callable functions that can be invoked via OpenAI’s function calling system.

  • Manage persistent conversation threads for contextual continuity.

  • Handle tool calls and structured outputs effortlessly.

  • Seamlessly integrate assistants into Crowe’s multi-agent ecosystems.


Quick Start

from crowe import CroweAssistant

# Create a math tutor assistant
assistant = CroweAssistant(
    name="Math Tutor",
    instructions="You are a friendly and precise math tutor.",
    model="gpt-4o",
    tools=[{"type": "code_interpreter"}]
)

# Run a simple task
response = assistant.run("Solve the equation: 3x + 11 = 14")
print(response)

# Continue conversation in the same thread
follow_up = assistant.run("Now explain how you solved it")
print(follow_up)

Custom Function Integration

CroweAssistant supports dynamic tool/function registration, allowing the model to call your functions mid-conversation.

Now, the assistant can automatically invoke get_weather() when relevant to the conversation.


API Reference

Constructor

Parameter
Type
Default
Description

name

str

Required

Assistant name

instructions

str

None

Role/system prompt

model

str

"gpt-4o"

Model name

tools

list

None

Tool specifications

file_ids

list

None

Files available to the assistant

metadata

dict

None

Custom metadata

functions

list

None

Pre-defined callable functions


Core Methods

run(task: str) -> str

Executes a task within the assistant’s current conversation thread. Maintains conversational context between calls.


add_function(func, description, parameters)

Registers a callable function for the assistant to use. Functions should include clear schemas, error handling, and input validation.


add_message(content, file_ids=None)

Adds a message to the conversation manually, useful for injecting context or external data.


Error Handling

CroweAssistant includes enterprise-grade fault tolerance:

  • Automatic retries on rate-limit errors.

  • Structured error reporting for debugging.

  • Status monitoring for long-running assistant tasks.

  • Graceful fallbacks when tool execution fails.


Best Practices

Conversation Management

  • Reuse the same assistant instance for related tasks.

  • Create separate instances for unrelated workflows.

  • Monitor thread status to avoid stale contexts.

Function & Tool Design

  • Keep functions small, single-purpose, and well-documented.

  • Validate inputs rigorously before execution.

  • Test functions independently before integration.

Performance Optimization

  • Reuse assistant instances to save API calls.

  • Implement timeouts for potentially slow operations.

  • Respect API rate limits and consider batch processing for multiple queries.


Example: Multi-Agent Integration

CroweAssistant works seamlessly with Crowe Agents, allowing an assistant to be embedded in collaborative multi-agent workflows:


Conclusion

The CroweAssistant class bridges the gap between OpenAI’s Assistants API and Crowe’s agent orchestration capabilities. It empowers developers to:

  • Build role-specific, tool-enabled assistants.

  • Maintain rich, multi-turn conversations.

  • Seamlessly connect LLMs with external systems.

By combining function calling, tool integration, and Crowe’s multi-agent coordination, you can construct highly adaptive, enterprise-grade AI systems with minimal boilerplate.

Last updated