From cebadd81ab05e160378da11a0c282d1d729d0ad7 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Sat, 9 Nov 2024 22:51:00 +0900 Subject: [PATCH] fix: improve logging format for chat history and update prompt definition --- src/app/api/ai/inner/route.ts | 2 +- src/app/api/ai/surface/route.ts | 2 +- src/app/page.tsx | 8 +++++--- src/utils/langchain/chains/surface/prompt.ts | 8 +++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/app/api/ai/inner/route.ts b/src/app/api/ai/inner/route.ts index 24b48552..56afc8d2 100644 --- a/src/app/api/ai/inner/route.ts +++ b/src/app/api/ai/inner/route.ts @@ -23,7 +23,7 @@ export async function POST(request: Request) { console.log(""); console.log("chatHistoryLines:"); - console.log(chatHistoryLines); + console.log(chatHistoryLines.join("\n")); let llm: ChatOpenAI; let embeddings: OpenAIEmbeddings; diff --git a/src/app/api/ai/surface/route.ts b/src/app/api/ai/surface/route.ts index bdaa288e..8c0570c5 100644 --- a/src/app/api/ai/surface/route.ts +++ b/src/app/api/ai/surface/route.ts @@ -19,7 +19,7 @@ export async function POST(request: Request) { console.log(""); console.log("chatHistoryLines:"); - console.log(chatHistoryLines); + console.log(chatHistoryLines.join("\n")); let llm: ChatOpenAI; let embeddings: OpenAIEmbeddings; diff --git a/src/app/page.tsx b/src/app/page.tsx index 588897e1..7b98b22e 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -412,8 +412,10 @@ export default function Home() { }} /> )} - {(!responding && !mapping && dialogueList.length > 1) || - (ability && ["apology", "ask-more"].includes(ability) && ( + {!responding && + !mapping && + dialogueList.length > 1 && + !(ability && ["apology", "ask-more"].includes(ability)) && ( { @@ -424,7 +426,7 @@ export default function Home() { onSubmit(value); }} /> - ))} + )}
diff --git a/src/utils/langchain/chains/surface/prompt.ts b/src/utils/langchain/chains/surface/prompt.ts index bdabefc2..3f9638f6 100644 --- a/src/utils/langchain/chains/surface/prompt.ts +++ b/src/utils/langchain/chains/surface/prompt.ts @@ -74,9 +74,15 @@ Reply: 了解しました。OpenStreetMapのデータに基づいて台東区と }, ]; -const tridentSurfacePromptPrefix = `Your name is TRIDENT, You are an interactive web maps generating assistant. You interact with the human, asking step-by-step about the areas and concerns of the map they want to create. +const tridentSurfacePromptPrefix = `Your name is TRIDENT, You are an interactive web maps generating assistant. +You interact with the human, asking step-by-step about the areas and concerns of the map they want to create. + +### Definition of output format: ### +- Ability: Text that indicates required ability to generate maps. +- Reply: Text that indicates the response to the human. You will always reply according to the following rules: +- You MUST ALWAYS reply according to the output format. - You MUST ALWAYS reply IN THE LANGUAGE WHICH HUMAN IS WRITING. - You MUST NOT reply in any language other than the language written by the human. - You reply with the most accurate grammar possible.