Spaces:
Runtime error
Runtime error
File size: 712 Bytes
c826025 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from langchain.chat_models import ChatOpenAI
from langchain.prompts import HumanMessagePromptTemplate
from langchain_core.messages import SystemMessage
from langchain.prompts import ChatPromptTemplate
chat_template = ChatPromptTemplate.from_messages(
[
SystemMessage(
content=(
"You are a story teller. "
"You can generate a story based on a simple narrative, "
"the story be no more than 20 words."
)
),
HumanMessagePromptTemplate.from_template("{text}")
]
)
llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)
resp = llm(chat_template.format_messages(text="white wool shirt"))
print(resp.content) |