This file contains hidden or 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
| <html><body><p>Composio Google Drive eval fixture.</p></body></html> |
This file contains hidden or 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
| def _setup_routes(self): | |
| @self.app.websocket("/ws/voice-stream/{agent_type}") | |
| async def voice_stream_endpoint(websocket: WebSocket, agent_type: str): | |
| ... | |
| try: | |
| agent = self.agent_manager.get_agent(agent_type) | |
| headers = {} | |
| if self.key is not None: | |
| headers = { "api-key": self.key } | |
| # add params to the url without using urllib |
This file contains hidden or 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
| async def _receive_from_client(self, websocket: WebSocket, openai_ws: WebSocketClientProtocol) -> None: | |
| """Receive a message from the client.""" | |
| try: | |
| async for message in websocket.iter_json(): | |
| if message['event'] == 'media' and openai_ws.open: | |
| audio_append = { | |
| "type": "input_audio_buffer.append", | |
| "audio": message['media']['payload'] | |
| } | |
| await openai_ws.send(json.dumps(audio_append)) |
This file contains hidden or 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
| async def _send_to_client(openai_ws: WebSocketClientProtocol) -> None: | |
| """Send a message to the client.""" | |
| response_create = { | |
| "event_id": "event_234", | |
| "type": "response.create", | |
| "response": { | |
| "modalities": ["text"], | |
| "instructions": "Please assist the user.", | |
| "voice": "alloy", | |
| "output_audio_format": "pcm16", |
This file contains hidden or 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
| async def _receive_from_client(openai_ws: WebSocketClientProtocol) -> None: | |
| """Receive a message from the client.""" | |
| try: | |
| conversation_item = { | |
| "event_id": "event_345", | |
| "type": "conversation.item.create", | |
| "previous_item_id": None, | |
| "item": { | |
| "id": "msg_001", | |
| "type": "message", |
This file contains hidden or 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
| TOOLS = [ | |
| { | |
| "name": "chat_with_agent", | |
| "type": "function", | |
| "description": ( | |
| "Chat with an agent of a given type. ..." | |
| ), | |
| "parameters": { | |
| "type": "object", | |
| "properties": { |
This file contains hidden or 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
| async def _send_session_update(openai_ws: WebSocketClientProtocol) -> None: | |
| """Send the session update to the OpenAI WebSocket.""" | |
| session_update = {} | |
| print(f'Sending session update:', json.dumps(session_update)) | |
| await openai_ws.send(json.dumps(session_update)) |
This file contains hidden or 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
| async def setup_websocket(): | |
| headers = {} | |
| if key is not None: | |
| headers = { "api-key": key } | |
| # define the OpenAI Realtime API websocket URL. This is for the Azure deployment | |
| ws_url = f"{endpoint}/openai/realtime?api-version=2024-10-01-preview&deployment={deployment}" | |
| async with websockets.connect(ws_url, extra_headers=headers) as openai_ws: | |
| # send the session update first before starting the conversation | |
| resp = await _send_session_update(openai_ws) | |
| # start listening and sending requests to the OpenAI ws |
This file contains hidden or 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
| def send_email(): | |
| with DaprClient() as d: | |
| req_data = { | |
| 'metadata': { | |
| 'emailTo': emailTo, | |
| 'subject': subject | |
| }, | |
| 'data': data | |
| } |
This file contains hidden or 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
| @app.route('/getmsg', methods=['POST']) | |
| def subscriber(): | |
| print(request.json, flush=True) | |
| jsonRequest = request.json | |
| data = jsonRequest["data"]["data"]["message"] | |
| print(data, flush=True) | |
| send_email() |
NewerOlder