from fastapi import FastAPI, HTTPException from pydantic import BaseModel import openai import os # Initialize FastAPI app app = FastAPI() # Set your OpenAI API key openai.api_key = os.getenv("OPENAI_API_KEY") class ChatRequest(BaseModel): message: str user_id: str @app.post("/chat") async def chat_with_bot(request: ChatRequest): try: response = openai.ChatCompletion.create( model="gpt-4", messages=[{"role": "user", "content": request.message}] ) reply = response["choices"][0]["message"]["content"] return {"response": reply} except Exception as e: raise HTTPException(status_code=500, detail=str(e))
top of page

Online STEM Week

Wed, Jul 12

|

Online Event

I’m an event description. Click here to open up the Event Editor and change my text.

Registration is Closed
See other events

Time & Location

Jul 12, 2023, 6:00 PM

Online Event

About the Event

I’m an event description. Click here to open up the Event Editor and change my text. Simply click me, Manage Event and start editing your event. I’m a great place for you to say a little more about your upcoming event.

Share This Event

bottom of page