Spaces:
Running
Running
import streamlit as st | |
from langchain_openai import ChatOpenAI | |
from langchain_core.prompts import ChatPromptTemplate | |
from langchain.schema import StrOutputParser | |
chat_llm = ChatOpenAI( | |
openai_api_key=st.secrets["OPENAI_API_KEY"], | |
model=st.secrets["OPENAI_MODEL"], | |
) | |
prompt = ChatPromptTemplate.from_messages( | |
[ | |
( | |
"system", | |
"You are a instagram post writer and you writing captions for posts for company that make hiking and bicycle backpacks. " | |
"Responde with 2 sentence max, use context as example. ", | |
), | |
( "system", "{example}" ), | |
( "human", "{question}" ), | |
] | |
) | |
chat_chain = prompt | chat_llm | StrOutputParser() | |