Skip to content

Commit f8cefda

Browse files
authored
fix: ensure current date/time is loaded in system prompt (#54)
* fix: ensure current date/time is loaded in system prompt * chore: apply feedback
1 parent c9b11c0 commit f8cefda

12 files changed

Lines changed: 14 additions & 13 deletions

File tree

  • asynchronous-authorization
  • authenticate-users
    • langchain-next-js/src/lib
    • vercel-ai-next-js-starter/src/app/api/chat
    • vercel-ai-next-js/src/app/api/chat
  • authorization-for-rag
  • call-apis-on-users-behalf
    • others-api
    • your-api

asynchronous-authorization/langchain-next-js/src/lib/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You have access to a set of tools. When using tools, you MUST provide valid JSON
1515
For example, when calling shop_online tool, format like this:
1616
{"product": "iPhone", "qty": 1, "priceLimit": 1000}
1717
18-
Use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
18+
Use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1919

2020
const llm = new ChatOpenAI({
2121
model: 'gpt-4o',

asynchronous-authorization/vercel-ai-next-js/src/app/api/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. Yo
1616
You have access to a set of tools. When using tools, you MUST provide valid JSON arguments. Always format tool call arguments as proper JSON objects.
1717
For example, when calling shop_online tool, format like this:
1818
{"product": "iPhone", "qty": 1, "priceLimit": 1000}
19-
Use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
19+
Use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
2020

2121
export async function POST(req: NextRequest) {
2222
const { id, messages }: { id: string; messages: Array<UIMessage> } = await req.json();

authenticate-users/langchain-next-js/src/lib/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Calculator } from '@langchain/community/tools/calculator';
66

77
const date = new Date().toISOString();
88

9-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
9+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1010

1111
const llm = new ChatOpenAI({
1212
model: 'gpt-4o',

authenticate-users/vercel-ai-next-js-starter/src/app/api/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { setAIContext } from '@auth0/ai-vercel';
55

66
const date = new Date().toISOString();
77

8-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
8+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
99

1010
/**
1111
* This handler initializes and calls an tool calling agent.

authenticate-users/vercel-ai-next-js/src/app/api/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { setAIContext } from '@auth0/ai-vercel';
55

66
const date = new Date().toISOString();
77

8-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
8+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
99

1010
/**
1111
* This handler initializes and calls an tool calling agent.

authorization-for-rag/langchain-next-js/src/lib/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getContextDocumentsTool } from './tools/context-docs';
66

77
const date = new Date().toISOString();
88

9-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
9+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1010

1111
const llm = new ChatOpenAI({
1212
model: 'gpt-4o',

authorization-for-rag/vercel-ai-next-js/src/app/api/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getContextDocumentsTool } from '@/lib/tools/context-docs';
77

88
const date = new Date().toISOString();
99

10-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
10+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1111

1212
/**
1313
* This handler initializes and calls an tool calling agent.

call-apis-on-users-behalf/others-api/langchain-next-js/src/lib/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { gmailSearchTool } from './tools/gmail-search';
77

88
const date = new Date().toISOString();
99

10-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
10+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1111

1212
const llm = new ChatOpenAI({
1313
model: 'gpt-4o',
@@ -32,4 +32,4 @@ export const graph = createReactAgent({
3232
prompt: AGENT_SYSTEM_TEMPLATE,
3333
store,
3434
checkpointer,
35-
});
35+
});

call-apis-on-users-behalf/others-api/vercel-ai-next-js/src/app/api/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { errorSerializer, withInterruptions } from '@auth0/ai-vercel/interrupts'
1414

1515
const date = new Date().toISOString();
1616

17-
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. Today is ${date}.`;
17+
const AGENT_SYSTEM_TEMPLATE = `You are a personal assistant named Assistant0. You are a helpful assistant that can answer questions and help with tasks. You have access to a set of tools, use the tools as needed to answer the user's question. Render the email body as a markdown block, do not wrap it in code blocks. The current date and time is ${date}`;
1818

1919
/**
2020
* This handler initializes and calls an tool calling agent.

call-apis-on-users-behalf/others-api/vercel-react-spa-js/server/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const app = new Hono()
9898
// https://ai-sdk.dev/cookbook/api-servers/hono?utm_source=chatgpt.com#hono
9999

100100
const modelMessages = convertToModelMessages(requestMessages);
101+
const date = new Date().toISOString();
101102

102103
const stream = createUIMessageStream({
103104
originalMessages: requestMessages,
@@ -106,7 +107,7 @@ export const app = new Hono()
106107
const result = streamText({
107108
model: openai("gpt-4o-mini"),
108109
system:
109-
"You are a helpful calendar assistant! You can help users with their calendar events and schedules. Keep your responses concise and helpful. Always format your responses as plain text. Do not use markdown formatting like **bold**, ##headers, or -bullet points. Use simple text formatting with line breaks and indentation only.",
110+
`You are a helpful calendar assistant! You can help users with their calendar events and schedules. Keep your responses concise and helpful. Always format your responses as plain text. Do not use markdown formatting like **bold**, ##headers, or -bullet points. Use simple text formatting with line breaks and indentation only. The current date and time is ${date}`,
110111
messages: modelMessages,
111112
tools,
112113

0 commit comments

Comments
 (0)