Commit
·
d5ac15d
1
Parent(s):
433f429
Update app_scribble.py
Browse files- app_scribble.py +15 -11
app_scribble.py
CHANGED
@@ -9,16 +9,19 @@ from utils import randomize_seed_fn
|
|
9 |
|
10 |
def magic_prompt(prompt):
|
11 |
openai.api_key = "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"
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
22 |
return mag_prompt
|
23 |
|
24 |
|
@@ -80,7 +83,8 @@ def create_demo(process):
|
|
80 |
)
|
81 |
with gr.Column():
|
82 |
result = gr.Gallery(label='Output',
|
83 |
-
show_label=
|
|
|
84 |
columns=2,
|
85 |
object_fit='scale-down')
|
86 |
inputs = [
|
|
|
9 |
|
10 |
def magic_prompt(prompt):
|
11 |
openai.api_key = "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"
|
12 |
+
mag_prompt=""
|
13 |
+
if(prompt==""):
|
14 |
+
mag_prompt = "Please write a prompt first ✍️"
|
15 |
+
else:
|
16 |
+
completion = openai.ChatCompletion.create(
|
17 |
+
model="gpt-3.5-turbo",
|
18 |
+
messages=[
|
19 |
+
{"role": "system", "content": "You are a rephraser."},
|
20 |
+
{"role": "user", "content": "You will be rephrasing the given details (details will be given in triple backticks) about an object/product. For example if “gray metal moka pot with black holder on wooden surface” is the given details, it should be rephrased as “moka pot, gray metal body, black holder, on wooden surface”. Output should be in coma separated form. Don’t add any comment and additional feature. Just give 1 output at a time. The given details “””{prompt}”””".format(prompt=prompt)}
|
21 |
+
]
|
22 |
+
)
|
23 |
+
|
24 |
+
mag_prompt = str(completion.choices[0].message.content)
|
25 |
return mag_prompt
|
26 |
|
27 |
|
|
|
83 |
)
|
84 |
with gr.Column():
|
85 |
result = gr.Gallery(label='Output',
|
86 |
+
show_label=True,
|
87 |
+
preview=True,
|
88 |
columns=2,
|
89 |
object_fit='scale-down')
|
90 |
inputs = [
|