File size: 475 Bytes
7be50ca
 
 
4a2adcb
7be50ca
4a2adcb
41d9b0f
4a2adcb
7be50ca
 
 
 
 
 
 
 
 
 
 
4a2adcb
 
41d9b0f
1b5101a
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 logging
import os

import gradio as gr
import openai


def greet(name):

  openai.api_key = os.getenv("OPENAI_API_KEY")
  result = openai.Completion.create(
    model="text-davinci-003",
    prompt="Say this is a test",
    max_tokens=7,
    temperature=0
  )
  logging.info(result)
  model_response = result["choices"][0]["text"]
  return "Hello " + name + "!!" + "\n\n" + model_response

iface = gr.Interface(fn=greet, inputs="text", outputs="text")

iface.launch()