Spaces:
Running
Running
File size: 890 Bytes
b59f0da 5b0e95f a0b6e16 b59f0da b8bab42 b59f0da 3bdb854 b59f0da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import openai
import os
# OpenAI API ν€ μ€μ
openai.api_key = os.getenv("OPENAI_API_KEY") # νκ²½ λ³μμμ API ν€λ₯Ό λΆλ¬μ΅λλ€.
def generate_keywords_with_gpt(scene_descriptions):
responses = []
for description in scene_descriptions:
response = openai.Completion.create(
engine="text-davinci-003", # νΉμ λ€λ₯Έ GPT λͺ¨λΈμ μ νν μ μμ΅λλ€.
prompt=f"Generate a representative keyword for the following scene description: {description}",
max_tokens=60, # νμν ν ν° μλ₯Ό μ‘°μ ν μ μμ΅λλ€.
temperature=0.7
)
responses.append(response.choices[0].text.strip())
return responses
# μ¬μ© μμ
scene_descriptions = ["Enter description for Scene 1", "Enter description for Scene 2"]
keywords = generate_keywords_with_gpt(scene_descriptions)
print(keywords)
|