Spaces:
Running
Running
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) | |