53 lines
3.6 KiB
Python
53 lines
3.6 KiB
Python
import os
|
|
from openai import OpenAI
|
|
|
|
|
|
# OpenAI API 키 설정
|
|
api_key = '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'
|
|
client = OpenAI(api_key=api_key)
|
|
|
|
def ask_model(question, model="gpt-4o-mini"):
|
|
try:
|
|
# API 호출을 통해 질문과 답변 생성
|
|
response = client.chat.completions.create(
|
|
model=model,
|
|
messages=[{"role": "user", "content": question}]
|
|
)
|
|
answer = response.choices[0].message.content
|
|
return answer
|
|
except Exception as e:
|
|
print("Error communicating with the model:", e)
|
|
return None
|
|
|
|
# 질문 예시
|
|
# question = "아래의 원본상품명의 상품을 대체 상품명으로 바꾸었을때 같은 용도로 사용할수 있는지 True와 False로 대답해줘. 원본 상품명 : 石墨烯宽条电热膜家用电暖炕速热瑜伽馆地暖电热板远红外安装包邮, 대체 상품명 : 전기난방기 강화 마루 판넬 접선벨트 X1.75m 섬유 2.6m 듀얼 컨테이너 탄소 컨트롤 "
|
|
|
|
# question ='아래의 네이버 상품명과 원본상품명이 같은 용도의 상품인지 True와 False로 대답해줘., 네이버 상품명 : 전기난방기 강화 마루 판넬 접선벨트 X1.75m 섬유 2.6m 듀얼 컨테이너 탄소 컨트롤, 원본 상품명 : 石墨烯宽条电热膜家用电暖炕速热瑜伽馆地暖电热板远红外安装包邮'
|
|
|
|
question = '''
|
|
Please process the following Chinese product options according to the instructions below, and ensure that all responses are in Korean.
|
|
|
|
#### Instructions:
|
|
1. **Remove Special Characters**: If there are any special characters in the option names, please remove them.
|
|
2. **Simplify Each Option**: Refer to the original product name, "Maxlaser M3手持雷达测速仪汽车 厂区叉车低速测速器正品特惠包邮", and simplify each option name by retaining only the key attributes that represent essential product specifications (such as size, weight, capacity, voltage, current, or product code).
|
|
3. **Translate to Korean**: Translate each simplified option name into concise and consistent Korean. Ensure that no Chinese characters are included in the translated options.
|
|
4. **Handle Duplicate Names**: If any translated option names are identical, please re-extract additional distinguishing features from the original option names and add them to the duplicates to ensure uniqueness. Make sure no Chinese characters remain.
|
|
5. **Delete Inquiry-based Options**: Remove any option names that prompt customers to contact support or inquire (e.g., "price inquiry," "contact customer service," "estimate inquiry," "deposit," or "prepayment").
|
|
6. **Use Shorter Terms Where Possible**: Replace any long words with shorter synonyms where the meaning is retained (e.g., "display" to "screen").
|
|
7. **Return the Response in JSON Format**: Format the final translated option names as follows:
|
|
- `"trans_option_1": "translated_option_1"`,
|
|
- `"trans_option_2": "translated_option_2"`,
|
|
- `"trans_option_3": "translated_option_3"`,
|
|
- `"trans_option_4": "translated_option_4"`.
|
|
|
|
Note: Please ensure that all responses, including explanations and final JSON outputs, are in Korean.
|
|
|
|
#### Original Data:
|
|
Original option names:
|
|
```json
|
|
{"origin_option_1": "标配", "origin_option_2": "标配含普票", "origin_option_3": "标配含增票"}
|
|
'''
|
|
|
|
answer = ask_model(question, model="gpt-4o-mini") # 또는 "gpt-4o-mini" 사용 가능
|
|
print("Model answer:", answer)
|