- 챗봇 설정 함수
def set_chat(messages, model):
stream = ollama.chat(
model = model,
messages = messages,
stream = True,
)
for chunk in stream:
print(chunk['message']['content'], end='', flush=True)
- 질의 및 정보 입력
prompt = "You are a helpful AI assistant. Summarize the text entered by the user and reply in Korean."
# content 내용 자유롭게 입력하기
content = '''
{원본 내용}
'''
instruction = "입력한 정보를 요약해줘"
- 메시지 format 지정
messages_format1 = [
{"role": "system", "content": f"{prompt}"},
{"role": "user", "content": f"{content}"},
{"role": "user", "content": f"{instruction}"}
]
- 질의 실행
set_chat(messages_format1, llama_model)