-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d81149
commit 0f27c94
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
docs/src/content/docs/classifiers/built-in/openai-classifier.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: OpenAI Classifier | ||
description: How to configure the OpenAI classifier | ||
--- | ||
|
||
The OpenAI Classifier is a built-in classifier for the Multi-Agent Orchestrator that leverages OpenAI's language models for intent classification. It provides robust classification capabilities using OpenAI's state-of-the-art models like GPT-4o. | ||
|
||
The OpenAI Classifier extends the abstract `Classifier` class and uses the OpenAI API client to process requests and classify user intents. | ||
|
||
## Features | ||
|
||
- Utilizes OpenAI's advanced models (e.g., GPT-4) for intent classification | ||
- Configurable model selection and inference parameters | ||
- Supports custom system prompts and variables | ||
- Handles conversation history for context-aware classification | ||
|
||
### Basic Usage | ||
|
||
To use the OpenAIClassifier, you need to create an instance with your OpenAI API key and pass it to the Multi-Agent Orchestrator: | ||
|
||
import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
|
||
<Tabs syncKey="runtime"> | ||
<TabItem label="TypeScript" icon="seti:typescript" color="blue"> | ||
```typescript | ||
import { OpenAIClassifier } from "multi-agent-orchestrator"; | ||
import { MultiAgentOrchestrator } from "multi-agent-orchestrator"; | ||
|
||
const openaiClassifier = new OpenAIClassifier({ | ||
apiKey: 'your-openai-api-key' | ||
}); | ||
|
||
const orchestrator = new MultiAgentOrchestrator({ classifier: openaiClassifier }); | ||
``` | ||
</TabItem> | ||
<TabItem label="Python" icon="seti:python"> | ||
```python | ||
from multi_agent_orchestrator.classifiers import OpenAIClassifier, OpenAIClassifierOptions | ||
from multi_agent_orchestrator.orchestrator import MultiAgentOrchestrator | ||
openai_classifier = OpenAIClassifier(OpenAIClassifierOptions( | ||
api_key='your-openai-api-key' | ||
)) | ||
orchestrator = MultiAgentOrchestrator(classifier=openai_classifier) | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
### Custom Configuration | ||
|
||
You can customize the OpenAIClassifier by providing additional options: | ||
|
||
<Tabs syncKey="runtime"> | ||
<TabItem label="TypeScript" icon="seti:typescript" color="blue"> | ||
```typescript | ||
const customOpenAIClassifier = new OpenAIClassifier({ | ||
apiKey: 'your-openai-api-key', | ||
modelId: 'gpt-4o', | ||
inferenceConfig: { | ||
maxTokens: 500, | ||
temperature: 0.7, | ||
topP: 0.9, | ||
stopSequences: [''] | ||
} | ||
}); | ||
const orchestrator = new MultiAgentOrchestrator({ classifier: customOpenAIClassifier }); | ||
``` | ||
</TabItem> | ||
<TabItem label="Python" icon="seti:python"> | ||
```python | ||
from multi_agent_orchestrator.classifiers import OpenAIClassifier, OpenAIClassifierOptions | ||
from multi_agent_orchestrator.orchestrator import MultiAgentOrchestrator | ||
custom_openai_classifier = OpenAIClassifier(OpenAIClassifierOptions( | ||
api_key='your-openai-api-key', | ||
model_id='gpt-4o', | ||
inference_config={ | ||
'max_tokens': 500, | ||
'temperature': 0.7, | ||
'top_p': 0.9, | ||
'stop_sequences': [''] | ||
} | ||
)) | ||
orchestrator = MultiAgentOrchestrator(classifier=custom_openai_classifier) | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
The OpenAIClassifier accepts the following configuration options: | ||
|
||
- `api_key` (required): Your OpenAI API key. | ||
- `model_id` (optional): The ID of the OpenAI model to use. Defaults to GPT-4 Turbo |