fix: finish hooking up accommodations flow
This commit is contained in:
@@ -46,10 +46,13 @@ If they do NOT change their request details (or they never specified them), plea
|
||||
|
||||
const humanMessage = `Here is the entire conversation so far:\n${formatMessages(state.messages)}`;
|
||||
|
||||
const response = await model.invoke([
|
||||
{ role: "system", content: prompt },
|
||||
{ role: "human", content: humanMessage },
|
||||
]);
|
||||
const response = await model.invoke(
|
||||
[
|
||||
{ role: "system", content: prompt },
|
||||
{ role: "human", content: humanMessage },
|
||||
],
|
||||
{ tags: ["langsmith:nostream"] },
|
||||
);
|
||||
|
||||
const classificationDetails = response.tool_calls?.[0]?.args as
|
||||
| z.infer<typeof schema>
|
||||
|
||||
@@ -114,10 +114,9 @@ Extract only what is specified by the user. It is okay to leave fields blank if
|
||||
const extractionDetailsWithDefaults: TripDetails = {
|
||||
startDate,
|
||||
endDate,
|
||||
numberOfGuests:
|
||||
extractedDetails.numberOfGuests !== undefined
|
||||
? extractedDetails.numberOfGuests
|
||||
: 2,
|
||||
numberOfGuests: extractedDetails.numberOfGuests
|
||||
? extractedDetails.numberOfGuests
|
||||
: 2,
|
||||
location: extractedDetails.location,
|
||||
};
|
||||
|
||||
|
||||
@@ -81,15 +81,16 @@ export async function callTools(
|
||||
const tripPlan = response.tool_calls?.[0]?.args as
|
||||
| z.infer<typeof schema>
|
||||
| undefined;
|
||||
if (!tripPlan) {
|
||||
const toolCallId = response.tool_calls?.[0]?.id;
|
||||
if (!tripPlan || !toolCallId) {
|
||||
throw new Error("No trip plan found");
|
||||
}
|
||||
|
||||
if (tripPlan.listAccommodations) {
|
||||
ui.write(
|
||||
"accommodations-list",
|
||||
getAccommodationsListProps(state.tripDetails),
|
||||
);
|
||||
ui.write("accommodations-list", {
|
||||
toolCallId,
|
||||
...getAccommodationsListProps(state.tripDetails),
|
||||
});
|
||||
}
|
||||
if (tripPlan.bookAccommodation && tripPlan.accommodationName) {
|
||||
ui.write("book-accommodation", {
|
||||
|
||||
Reference in New Issue
Block a user