File size: 940 Bytes
c91b5f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54c0786
8f5936f
 
c91b5f9
74f144a
c91b5f9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import openai
import os
import gradio as gr
import json
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())


openai.api_key  = os.getenv('OPENAI_API_KEY')

def get_completion(prompt, model="gpt-3.5-turbo"):
    messages = [{"role": "user", "content": prompt}]
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=0, # this is the degree of randomness of the model's output
    )
    return response.choices[0].message["content"]

def greet(company, solution, customer, problem, features):
    pitch = f"""My company, {company} is developing {solution} to help {target_customer} {problem} with {features}"""
    return json.dumps(pitch)

iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Company"), gr.Textbox(label="Solution"), gr.Textbox(label="Customer"), gr.Textbox(label="Problem"),  gr.Textbox(label="Feature")], outputs="json")
iface.launch()