from upsonic.uel import ChatPromptTemplate, RunnableParallel, RunnableLambda, StrOutputParser
from upsonic.models import infer_model
model = infer_model("openai/gpt-4o")
parser = StrOutputParser()
# Create a complex chain
chain = (
{
"joke": ChatPromptTemplate.from_template("Joke about {topic}") | model | parser,
"fact": ChatPromptTemplate.from_template("Fact about {topic}") | model | parser
}
| ChatPromptTemplate.from_template("Combine:\nJoke: {joke}\nFact: {fact}")
| model
| parser
)
# Visualize
graph = chain.get_graph()
graph.print_ascii()