Spaces:
Qrstud
/
Runtime error

File size: 591 Bytes
67fcf0c
 
 
 
 
 
3c35089
67fcf0c
 
 
 
6214e15
67fcf0c
 
 
 
 
 
 
 
cf196d2
67fcf0c
 
3c35089
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import openai
import gradio as gr

# Getting responses using the OpenAI API
def response_chatgpt(api_key, message):
  # OPENAI API KEY
  openai.api_key = "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"
  prompt = (f"{message}")
  response = openai.Completion.create(
      engine="text-davinci-003",
      prompt=prompt,
      max_tokens=3524
  )
  # Displaying the answer on the screen
  result = response["choices"][0]["text"]
  return result
      
# User input
chatbot = gr.Interface(
    fn=response_chatgpt, 
    inputs=["text", "text"],
    outputs="text",
)
chatbot.launch()