Skip to content

Instantly share code, notes, and snippets.

View wjayesh's full-sized avatar
👋

Jayesh Sharma wjayesh

👋
View GitHub Profile
<html><body><p>Composio Google Drive eval fixture.</p></body></html>
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
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))
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",
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",
TOOLS = [
{
"name": "chat_with_agent",
"type": "function",
"description": (
"Chat with an agent of a given type. ..."
),
"parameters": {
"type": "object",
"properties": {
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))
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
def send_email():
with DaprClient() as d:
req_data = {
'metadata': {
'emailTo': emailTo,
'subject': subject
},
'data': data
}
@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()