pipecat icon indicating copy to clipboard operation
pipecat copied to clipboard

Issue with example

Open sadimoodi opened this issue 5 months ago • 1 comments

Hello, Thank you very much for the winderful library. I am reading this example from your Docs but the code is not running because you are using: daily_rest_helper = DailyRESTHelper( os.getenv("DAILY_API_KEY", ""), os.getenv("DAILY_API_URL", 'https://api.daily.co/v1'))

but DailyRESTHelper constructor takes an additional argument which is aiohttp_session of type aiohttp.ClientSession so your code isnt running using pipecat version 0.0.39 not 0.0.41

the below code uses FastAPI and receives http post requests so an aiohttp.ClientSession isnt available, how to run this code? thanks

MAX_SESSION_TIME = 5 * 60 # 5 minutes

List of require env vars our bot requires

REQUIRED_ENV_VARS = [ 'DAILY_API_KEY', 'OPENAI_API_KEY', 'ELEVENLABS_API_KEY', 'ELEVENLABS_VOICE_ID']

daily_rest_helper = DailyRESTHelper( os.getenv("DAILY_API_KEY", ""), os.getenv("DAILY_API_URL", 'https://api.daily.co/v1'))

----------------- API -----------------

app = FastAPI()

app.add_middleware( CORSMiddleware, allow_origins=[""], allow_credentials=True, allow_methods=[""], allow_headers=["*"] )

----------------- Main -----------------

@app.post("/start_bot") async def start_bot(request: Request) -> JSONResponse: try: # Grab any data included in the post request data = await request.json() except Exception as e: pass

# Create a new Daily WebRTC room for the session to take place in
try:
    params = DailyRoomParams(
        properties=DailyRoomProperties()
    )
    room: DailyRoomObject = daily_rest_helper.create_room(params=params)
except Exception as e:
    raise HTTPException(
        status_code=500,
        detail=f"Unable to provision room {e}")

sadimoodi avatar Sep 04 '24 09:09 sadimoodi