Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import openai
|
2 |
import os
|
3 |
|
@@ -7,7 +8,7 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
7 |
def generate_keyword_from_text(input_text):
|
8 |
try:
|
9 |
response = openai.Completion.create(
|
10 |
-
model="text-davinci-003", # GPT
|
11 |
prompt=f"Given the following text, generate a relevant English keyword for Pexels search: '{input_text}'",
|
12 |
temperature=0.5,
|
13 |
max_tokens=10,
|
@@ -21,16 +22,13 @@ def generate_keyword_from_text(input_text):
|
|
21 |
print(f"An error occurred: {e}")
|
22 |
return "Error generating keyword"
|
23 |
|
24 |
-
# Gradio ์ธํฐํ์ด์ค ์์
|
25 |
-
import gradio as gr
|
26 |
-
|
27 |
def gradio_interface(input_text):
|
28 |
keyword = generate_keyword_from_text(input_text)
|
29 |
return keyword
|
30 |
|
31 |
iface = gr.Interface(
|
32 |
fn=gradio_interface,
|
33 |
-
inputs=gr.
|
34 |
outputs="text",
|
35 |
title="Generate Pexels Search Keyword with GPT",
|
36 |
description="This tool generates a keyword for Pexels search based on the provided text input."
|
|
|
1 |
+
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
4 |
|
|
|
8 |
def generate_keyword_from_text(input_text):
|
9 |
try:
|
10 |
response = openai.Completion.create(
|
11 |
+
model="text-davinci-003", # ์ค์ ์ฌ์ฉ ๊ฐ๋ฅํ GPT ๋ชจ๋ธ๋ช
์ผ๋ก ์
๋ฐ์ดํธํ์ธ์.
|
12 |
prompt=f"Given the following text, generate a relevant English keyword for Pexels search: '{input_text}'",
|
13 |
temperature=0.5,
|
14 |
max_tokens=10,
|
|
|
22 |
print(f"An error occurred: {e}")
|
23 |
return "Error generating keyword"
|
24 |
|
|
|
|
|
|
|
25 |
def gradio_interface(input_text):
|
26 |
keyword = generate_keyword_from_text(input_text)
|
27 |
return keyword
|
28 |
|
29 |
iface = gr.Interface(
|
30 |
fn=gradio_interface,
|
31 |
+
inputs=gr.Textbox(lines=2, label="Enter Text"), # ์์ ๋ ๋ถ๋ถ
|
32 |
outputs="text",
|
33 |
title="Generate Pexels Search Keyword with GPT",
|
34 |
description="This tool generates a keyword for Pexels search based on the provided text input."
|