from promptify import OpenAI, Prompter# OpenAI 모델 설정model = OpenAI(api_key="your-api-key")nlp_prompter = Prompter(model)# NER (개체명 인식)sentence = "Barack Obama was born in Hawaii and was the 44th president of the United States."result = nlp_prompter.fit( 'ner.jinja', domain='General', text_input=sentence, labels=['Person', 'Location', 'Organization'])print(result)# [{"E": "Barack Obama", "T": "Person"}, {"E": "Hawaii", "T": "Location"}, ...]# 감정 분석result = nlp_prompter.fit( 'sentiment.jinja', text_input="I love this product! Amazing quality.", labels=['Positive', 'Negative', 'Neutral'])# 텍스트 분류result = nlp_prompter.fit( 'classification.jinja', text_input="주식 시장이 오늘 큰 폭으로 하락했습니다.", labels=['Finance', 'Sports', 'Technology', 'Politics'])
커스텀 템플릿 (Jinja2)
{# custom_ner.jinja #}You are an expert Named Entity Recognition system.Extract entities from the following text and return as JSON array.Labels: {{ labels | join(', ') }}Text: {{ text_input }}Return format:[{"entity": "entity_name", "type": "entity_type"}]
result = nlp_prompter.fit( 'custom_ner.jinja', text_input="삼성전자가 새로운 AI 칩을 발표했습니다.", labels=['Company', 'Product', 'Technology'])