Team Ai
Apppublic

Damonho316/chatgpt-python

sourceHugging Facegpl-3.0updated 4y agoView on Hugging Face
0likes
app.py24 linesDownload Raw Back to root
1import openai2import gradio as gr3 4# Getting responses using the OpenAI API5def response_chatgpt(api_key, message):6  # OPENAI API KEY7  openai.api_key = api_key8  prompt = (f"{message}")9  response = openai.Completion.create(10      engine="text-davinci-003",11      prompt=prompt,12      max_tokens=102413  )14  # Displaying the answer on the screen15  result = response["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"]["text"]16  return result17      18# User input19chatbot = gr.Interface(20    fn=response_chatgpt, 21    inputs=["text", "text"],22    outputs="text",23)24chatbot.launch()