You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't see a way to start the chat playground with an initial AI message. Use-case here is to explore conversations where the bot will initiate the conversation.
So if I have something like this as a full example:
importdatetimeasdtfromfastapiimportFastAPIfromlangserveimportadd_routesfromlangchain_core.prompts.chatimportChatPromptTemplate, MessagesPlaceholderfromlangchain.agentsimportAgentExecutor, create_tool_calling_agentfromlangchain_openaiimportChatOpenAIfromlangchain.toolsimporttoolfromlangchain.pydantic_v1importBaseModel, Fieldfromlangchain_core.messagesimportAIMessage, HumanMessage, SystemMessage@tooldefschedule_session(appointment_time: dt.datetime) ->str:
"""Schedule a session with the user."""return"ok"tools= [schedule_session]
gpt_35_turbo=ChatOpenAI(model="gpt-3.5-turbo")
prompt=ChatPromptTemplate.from_messages(
[
("system", "You are an empathetic bot reaching out to a friend"),
("ai", "Hey Jessica! Just wanted to check in on you. How are you doing?"),
MessagesPlaceholder("chat_history", optional=True),
("human", "{input} {agent_scratchpad}"),
]
)
agent=create_tool_calling_agent(llm=gpt_35_turbo, tools=tools, prompt=prompt)
agent_executor=AgentExecutor(agent=agent, tools=tools)
classChatInputWithHistory(BaseModel):
"""Input for the chat endpoint."""input: strchat_history: list[HumanMessage|AIMessage|SystemMessage] =Field(
...,
description="The chat messages representing the current conversation.",
)
playground_compatible_agent_executor= (
agent_executor| (lambdax: x["output"])
).with_types(input_type=ChatInputWithHistory, output_type=str)
app=FastAPI()
add_routes(
app,
playground_compatible_agent_executor,
path="/chat",
playground_type="chat",
)
if__name__=="__main__":
importuvicornuvicorn.run(app, host="0.0.0.0", port=8080)
Then I would expect my http://localhost:8080/nova/chat/playground/ to open like this:
Because I specified ("ai", "Hey Jessica! Just wanted to check in on you. How are you doing?") in my chat prompt.
The text was updated successfully, but these errors were encountered:
I don't see a way to start the chat playground with an initial AI message. Use-case here is to explore conversations where the bot will initiate the conversation.
So if I have something like this as a full example:
Then I would expect my
http://localhost:8080/nova/chat/playground/
to open like this:Because I specified
("ai", "Hey Jessica! Just wanted to check in on you. How are you doing?")
in my chat prompt.The text was updated successfully, but these errors were encountered: