Response Suggestion¶
Response suggestion task for customer support interactions.
This module provides a predefined task for generating suggested responses to customer inquiries, helping support agents provide consistent, helpful, and professional communication.
Example
Basic usage with BatchResponses:
from openai import OpenAI
from openaivec.responses import BatchResponses
from openaivec.task import customer_support
client = OpenAI()
responder = BatchResponses.of_task(
client=client,
model_name="gpt-4o-mini",
task=customer_support.RESPONSE_SUGGESTION
)
inquiries = [
"I can't access my account. I've tried resetting my password but the email never arrives.",
"I'm really disappointed with your service. This is the third time I've had issues.",
"Thank you for your help yesterday! The problem is now resolved."
]
responses = responder.parse(inquiries)
for response in responses:
print(f"Suggested Response: {response.suggested_response}")
print(f"Tone: {response.tone}")
print(f"Priority: {response.priority}")
print(f"Follow-up: {response.follow_up_required}")
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 can't access my account. I've tried resetting my password but the email never arrives.",
"I'm really disappointed with your service. This is the third time I've had issues."
]})
df["response"] = df["inquiry"].ai.task(customer_support.RESPONSE_SUGGESTION)
# Extract response components
extracted_df = df.ai.extract("response")
print(extracted_df[["inquiry", "response_suggested_response", "response_tone", "response_priority"]])
Attributes:
Name | Type | Description |
---|---|---|
RESPONSE_SUGGESTION |
PreparedTask
|
A prepared task instance configured for response suggestion with temperature=0.0 and top_p=1.0 for deterministic output. |
response_suggestion(response_style='professional', company_name='our company', business_context='general customer support', temperature=0.0, top_p=1.0)
¶
Create a configurable response suggestion task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response_style
|
str
|
Style of response (professional, friendly, empathetic, formal). |
'professional'
|
company_name
|
str
|
Name of the company for personalization. |
'our company'
|
business_context
|
str
|
Business context for responses. |
'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 response suggestions. |
Source code in src/openaivec/task/customer_support/response_suggestion.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|