seawolf2357 commited on
Commit
077e44e
ยท
verified ยท
1 Parent(s): 79eed57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
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-4 ๋ชจ๋ธ๋ช…์„ ์ ์ ˆํžˆ ์„ ํƒํ•˜์„ธ์š”
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.inputs.Textbox(lines=2, label="Enter Text"),
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."