seawolf2357 commited on
Commit
5a6859f
Β·
verified Β·
1 Parent(s): 956f695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -7,14 +7,14 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  def generate_keyword_from_text(input_text):
9
  try:
10
- # μ΅œμ‹  OpenAI APIλ₯Ό μ‚¬μš©ν•˜μ—¬ ν…μŠ€νŠΈ 생성 μš”μ²­
11
- response = openai.Completion.create(
12
- model="text-davinci-004", # μ‚¬μš© κ°€λŠ₯ν•œ μ΅œμ‹  GPT λͺ¨λΈ μ‚¬μš©
13
- prompt=f"λ‹€μŒ ν…μŠ€νŠΈμ— λŒ€ν•œ Pexels 검색을 μœ„ν•œ 영문 ν‚€μ›Œλ“œ 생성: '{input_text}'",
14
- temperature=0.5,
15
- max_tokens=10
16
  )
17
- keyword = response.choices[0].text.strip()
18
  return keyword
19
  except Exception as e:
20
  print(f"μ—λŸ¬ λ°œμƒ: {e}")
 
7
 
8
  def generate_keyword_from_text(input_text):
9
  try:
10
+ # OpenAI ChatCompletion 을 μ‚¬μš©ν•˜μ—¬ μ±— λͺ¨λΈ μš”μ²­
11
+ response = openai.ChatCompletion.create(
12
+ model="gpt-3.5-turbo",
13
+ messages=[
14
+ {"role": "user", "content": f"λ‹€μŒ ν…μŠ€νŠΈμ— λŒ€ν•œ Pexels 검색을 μœ„ν•œ 영문 ν‚€μ›Œλ“œ 생성: '{input_text}'"}
15
+ ]
16
  )
17
+ keyword = response['choices'][0]['message']['content']
18
  return keyword
19
  except Exception as e:
20
  print(f"μ—λŸ¬ λ°œμƒ: {e}")