openai_analyzer
OpenAiAnalyzer
OpenAiAnalyzer(api_key: str, instruction: str, organization: str = None, pydantic_schema: Type[BaseModel] = None, model: str = 'gpt-4o-mini', max_content_size: int = 10000, max_workers: int = 3)
Bases: LlmAnalyzerBase
An analyzer that integrates the OpenAI API.
This analyzer makes asynchronous calls to the OpenAI API to obtain language model completions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
The API key for accessing the OpenAI API. |
required |
instruction
|
str
|
The instruction for guiding the language model's responses. |
required |
organization
|
str
|
The organization identifier for the OpenAI API. Defaults to None. |
None
|
pydantic_schema
|
Type[BaseModel]
|
A Pydantic model for validating the API response structure. Defaults to None. |
None
|
model
|
str
|
The model identifier to be used for generating completions. Defaults to "gpt-4o-mini". |
'gpt-4o-mini'
|
max_content_size
|
int
|
The maximum length of the content to analyze. Defaults to 10000. |
10000
|
max_workers
|
int
|
The maximum number of workers for concurrent analysis. Defaults to 3. |
3
|
query_llm
async
Asynchronously queries the OpenAI API using the provided content and instruction.
The method constructs a message list with a system instruction and user-provided content, sends the request to the OpenAI API, and extracts the resulting message content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
The user-provided content for analysis. |
required |
instruction
|
str
|
The system-level instruction for the language model. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The content of the response message generated by the language model. |