Intent Analysis¶
Intent analysis task for customer support interactions.
This module provides a predefined task for analyzing customer intent to understand what the customer is trying to achieve and how to best assist them.
Example
Basic usage with BatchResponses:
from openai import OpenAI
from openaivec.responses import BatchResponses
from openaivec.task import customer_support
client = OpenAI()
analyzer = BatchResponses.of_task(
client=client,
model_name="gpt-4o-mini",
task=customer_support.INTENT_ANALYSIS
)
inquiries = [
"I want to upgrade my plan to get more storage",
"How do I delete my account? I'm not satisfied with the service",
"Can you walk me through setting up the mobile app?"
]
intents = analyzer.parse(inquiries)
for intent in intents:
print(f"Primary Intent: {intent.primary_intent}")
print(f"Action Required: {intent.action_required}")
print(f"Success Likelihood: {intent.success_likelihood}")
print(f"Next Steps: {intent.next_steps}")
With pandas integration:
import pandas as pd
from openaivec import pandas_ext # Required for .ai accessor
from openaivec.task import customer_support
df = pd.DataFrame({"inquiry": [
"I want to upgrade my plan to get more storage",
"How do I delete my account? I'm not satisfied with the service",
"Can you walk me through setting up the mobile app?"
]})
df["intent"] = df["inquiry"].ai.task(customer_support.INTENT_ANALYSIS)
# Extract intent components
extracted_df = df.ai.extract("intent")
print(extracted_df[["inquiry", "intent_primary_intent", "intent_action_required", "intent_success_likelihood"]])
Attributes:
Name | Type | Description |
---|---|---|
INTENT_ANALYSIS |
PreparedTask
|
A prepared task instance configured for intent analysis with temperature=0.0 and top_p=1.0 for deterministic output. |
intent_analysis(business_context='general customer support', temperature=0.0, top_p=1.0)
¶
Create a configurable intent analysis task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
business_context
|
str
|
Business context for intent analysis. |
'general customer support'
|
temperature
|
float
|
Sampling temperature (0.0-1.0). |
0.0
|
top_p
|
float
|
Nucleus sampling parameter (0.0-1.0). |
1.0
|
Returns:
Type | Description |
---|---|
PreparedTask
|
PreparedTask configured for intent analysis. |