@@ -15,50 +15,6 @@ public function __construct(ApiKeyService $apiKeyService)
1515 $ this ->apiKeyService = $ apiKeyService ;
1616 }
1717
18- /**
19- * Create a relay connection to OpenAI Realtime API
20- * This will return WebSocket connection details for the frontend
21- */
22- public function createSession (Request $ request )
23- {
24- try {
25- $ apiKey = $ this ->apiKeyService ->getApiKey ();
26-
27- if (!$ apiKey ) {
28- return response ()->json ([
29- 'status ' => 'error ' ,
30- 'message ' => 'OpenAI API key not configured ' ,
31- ], 422 );
32- }
33-
34- // For now, we'll return connection info that the frontend can use
35- // In production, you'd want to create a proper WebSocket proxy
36- return response ()->json ([
37- 'status ' => 'success ' ,
38- 'session ' => [
39- 'id ' => uniqid ('session_ ' ),
40- 'model ' => 'gpt-4o-realtime-preview-2024-12-17 ' ,
41- 'instructions ' => $ request ->input ('instructions ' , 'You are an expert sales coach providing real-time guidance. ' ),
42- 'voice ' => $ request ->input ('voice ' , 'alloy ' ),
43- 'turn_detection ' => [
44- 'type ' => 'server_vad ' ,
45- 'threshold ' => 0.5 ,
46- 'prefix_padding_ms ' => 300 ,
47- 'silence_duration_ms ' => 500 ,
48- ],
49- 'tools ' => $ this ->getSalesTools (),
50- ],
51- ]);
52- } catch (\Exception $ e ) {
53- Log::error ('Failed to create realtime session: ' .$ e ->getMessage ());
54-
55- return response ()->json ([
56- 'status ' => 'error ' ,
57- 'message ' => 'Failed to create session ' ,
58- ], 500 );
59- }
60- }
61-
6218 /**
6319 * Generate ephemeral key for secure browser usage
6420 */
@@ -92,158 +48,4 @@ public function generateEphemeralKey(Request $request)
9248 ], 500 );
9349 }
9450 }
95-
96- /**
97- * Get the sales-specific tools for the AI
98- */
99- private function getSalesTools ()
100- {
101- return [
102- [
103- 'type ' => 'function ' ,
104- 'name ' => 'show_teleprompter_script ' ,
105- 'description ' => 'Display a script for the salesperson to read ' ,
106- 'parameters ' => [
107- 'type ' => 'object ' ,
108- 'properties ' => [
109- 'text ' => [
110- 'type ' => 'string ' ,
111- 'description ' => 'The complete script text to display ' ,
112- ],
113- 'priority ' => [
114- 'type ' => 'string ' ,
115- 'enum ' => ['high ' , 'normal ' , 'low ' ],
116- 'description ' => 'Priority level of the script ' ,
117- ],
118- 'context ' => [
119- 'type ' => 'string ' ,
120- 'description ' => 'Brief context about when to use this script ' ,
121- ],
122- ],
123- 'required ' => ['text ' , 'priority ' , 'context ' ],
124- ],
125- ],
126- [
127- 'type ' => 'function ' ,
128- 'name ' => 'update_sales_metrics ' ,
129- 'description ' => 'Update real-time sales metrics display ' ,
130- 'parameters ' => [
131- 'type ' => 'object ' ,
132- 'properties ' => [
133- 'talkRatio ' => [
134- 'type ' => 'number ' ,
135- 'description ' => 'Percentage of time salesperson is talking (0-100) ' ,
136- ],
137- 'sentiment ' => [
138- 'type ' => 'string ' ,
139- 'enum ' => ['positive ' , 'negative ' , 'neutral ' ],
140- 'description ' => 'Current conversation sentiment ' ,
141- ],
142- 'topics ' => [
143- 'type ' => 'array ' ,
144- 'items ' => ['type ' => 'string ' ],
145- 'description ' => 'Key topics discussed ' ,
146- ],
147- 'buyingSignals ' => [
148- 'type ' => 'number ' ,
149- 'description ' => 'Number of buying signals detected ' ,
150- ],
151- ],
152- 'required ' => ['talkRatio ' , 'sentiment ' ],
153- ],
154- ],
155- [
156- 'type ' => 'function ' ,
157- 'name ' => 'highlight_opportunity ' ,
158- 'description ' => 'Highlight a sales opportunity or important moment ' ,
159- 'parameters ' => [
160- 'type ' => 'object ' ,
161- 'properties ' => [
162- 'type ' => [
163- 'type ' => 'string ' ,
164- 'enum ' => ['buying_signal ' , 'objection ' , 'question ' , 'closing_opportunity ' ],
165- 'description ' => 'Type of opportunity ' ,
166- ],
167- 'confidence ' => [
168- 'type ' => 'number ' ,
169- 'description ' => 'Confidence level (0-1) ' ,
170- ],
171- 'suggestion ' => [
172- 'type ' => 'string ' ,
173- 'description ' => 'Suggested action to take ' ,
174- ],
175- 'urgency ' => [
176- 'type ' => 'string ' ,
177- 'enum ' => ['immediate ' , 'soon ' , 'low ' ],
178- 'description ' => 'How urgent is this opportunity ' ,
179- ],
180- ],
181- 'required ' => ['type ' , 'confidence ' , 'suggestion ' ],
182- ],
183- ],
184- [
185- 'type ' => 'function ' ,
186- 'name ' => 'show_battle_card ' ,
187- 'description ' => 'Display competitive information or product details ' ,
188- 'parameters ' => [
189- 'type ' => 'object ' ,
190- 'properties ' => [
191- 'topic ' => [
192- 'type ' => 'string ' ,
193- 'description ' => 'Topic of the battle card ' ,
194- ],
195- 'content ' => [
196- 'type ' => 'object ' ,
197- 'properties ' => [
198- 'keyPoints ' => [
199- 'type ' => 'array ' ,
200- 'items ' => ['type ' => 'string ' ],
201- 'description ' => 'Key talking points ' ,
202- ],
203- 'advantages ' => [
204- 'type ' => 'array ' ,
205- 'items ' => ['type ' => 'string ' ],
206- 'description ' => 'Our advantages ' ,
207- ],
208- 'statistics ' => [
209- 'type ' => 'array ' ,
210- 'items ' => ['type ' => 'string ' ],
211- 'description ' => 'Relevant statistics ' ,
212- ],
213- ],
214- ],
215- ],
216- 'required ' => ['topic ' , 'content ' ],
217- ],
218- ],
219- [
220- 'type ' => 'function ' ,
221- 'name ' => 'calculate_roi ' ,
222- 'description ' => 'Calculate and display ROI for the customer ' ,
223- 'parameters ' => [
224- 'type ' => 'object ' ,
225- 'properties ' => [
226- 'investment ' => [
227- 'type ' => 'number ' ,
228- 'description ' => 'Initial investment amount ' ,
229- ],
230- 'savings ' => [
231- 'type ' => 'number ' ,
232- 'description ' => 'Monthly or annual savings ' ,
233- ],
234- 'timeframe ' => [
235- 'type ' => 'string ' ,
236- 'description ' => 'Timeframe for ROI calculation ' ,
237- ],
238- 'additionalBenefits ' => [
239- 'type ' => 'array ' ,
240- 'items ' => ['type ' => 'string ' ],
241- 'description ' => 'Non-monetary benefits ' ,
242- ],
243- ],
244- 'required ' => ['investment ' , 'savings ' , 'timeframe ' ],
245- ],
246- ],
247- ];
248- }
24951}
0 commit comments