Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
# -*- coding: utf-8 -*-
|
| 2 |
-
"""VM-CopyAI.ipynb
|
| 3 |
-
|
| 4 |
-
Automatically generated by Colaboratory.
|
| 5 |
-
|
| 6 |
-
Original file is located at
|
| 7 |
-
https://colab.research.google.com/drive/1cSLog_zHJXpZfR6Nk75lY9LF_xJvI5dz
|
| 8 |
-
"""
|
| 9 |
-
|
| 10 |
-
import openai
|
| 11 |
-
import gradio as gr
|
| 12 |
-
|
| 13 |
-
openai.api_key = "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"
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
messages = [
|
| 18 |
-
{"role": "system", "content": "You are a helpful and kind AI Assistant."},
|
| 19 |
-
]
|
| 20 |
-
|
| 21 |
-
def chatbot(role,language,vernacular,product_name,product_type,platform,placement,country,objective, hashtag,emoji,line_break,remark,learn_model):
|
| 22 |
-
hashtag = "include" if hashtag else "exclude"
|
| 23 |
-
emoji = "include" if emoji else "exclude"
|
| 24 |
-
line_break = "include" if line_break else "exclude"
|
| 25 |
-
learn_model = "based on this story: " + learn_model if learn_model else ""
|
| 26 |
-
prompt = f"I want you to act as a {role},you are going to advertise a brand in language {language},using language formality level of {vernacular} out of 5,brand name is {product_name},type of brand is {product_type},you are going to advertise this on {platform},I want you to generate {placement},your target country is {country},the objective is to create {objective},{hashtag} hashtag,{emoji} emoji,{line_break} line break,{remark},{learn_model}"
|
| 27 |
-
|
| 28 |
-
messages.append({"role": "user", "content": prompt})
|
| 29 |
-
chat = openai.ChatCompletion.create(
|
| 30 |
-
model="gpt-4", messages=messages
|
| 31 |
-
)
|
| 32 |
-
reply = chat.choices[0].message.content
|
| 33 |
-
messages.append({"role": "assistant", "content": reply})
|
| 34 |
-
return reply
|
| 35 |
-
|
| 36 |
-
role = gr.Textbox(lines=1, label="Role",placeholder="Copywriter")
|
| 37 |
-
language = gr.Dropdown(["English","Chinese","Malay","Thai","Vietnamese"], label="Target Language",allow_custom_value=True)
|
| 38 |
-
vernacular = gr.Slider(0, 5, step=1, label="Formality Level", info="0 denotes maximum informality, 5 denotes maximum formality")
|
| 39 |
-
product_name = gr.Radio(["GOD55","Betsuper"],label="Brand Name")
|
| 40 |
-
product_type = gr.Radio(["Online Casino"],label="Brand Type")
|
| 41 |
-
platform = gr.Radio(["Facebook","Instagram"],label="Advertising Platform")
|
| 42 |
-
placement = gr.Dropdown(["Headline and Primary Text","Ads Image Text"], label="Copywriting Placement",allow_custom_value=True)
|
| 43 |
-
country = gr.Dropdown(["Malaysia","Singapore","Thailand","Vietnam"],label="Target Country", multiselect=True)
|
| 44 |
-
objective = gr.Radio(["Brand Attention","Brand Demand","Brand USP","Story Related"],label="Ads Objective")
|
| 45 |
-
hashtag = gr.Checkbox(value=True,label="Include Hashtag?")
|
| 46 |
-
emoji = gr.Checkbox(value=True,label="Include Emoji?")
|
| 47 |
-
line_break = gr.Checkbox(value=True,label="Allow Line Break?")
|
| 48 |
-
remark = gr.Textbox(lines=4, label="Additional Remark/Requirement")
|
| 49 |
-
learn_model=gr.Textbox(lines=4, label="Story Model", placeholder="Based on this story")
|
| 50 |
-
outputs = gr.Textbox(label="Result")
|
| 51 |
-
|
| 52 |
-
chat = gr.Interface(
|
| 53 |
-
fn=chatbot,
|
| 54 |
-
inputs=[role,language,vernacular,product_name,product_type,platform,placement,country,objective,hashtag,emoji,line_break,remark,learn_model],
|
| 55 |
-
outputs=outputs,
|
| 56 |
-
title = "AdVentive: Your AI Copy Solution"
|
| 57 |
-
|
| 58 |
-
)
|
| 59 |
-
chat.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|