OAIChatBot / main.py
asrafnoor's picture
Update main.py
bb43b4f verified
raw
history blame contribute delete
435 Bytes
from fastapi import FastAPI
import openai
app = FastAPI()
# Set up OpenAI API key
openai.api_key = ""
@app.post("/generate")
def generate_text(prompt: str):
response = openai.Completion.create(
engine="gpt-4", # Replace with the GPT-4 engine when available
prompt=prompt,
max_tokens=1024,
temperature=0.7,
)
return response.choices[0].text
# Run the app with `uvicorn main:app --reload`