-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Checklist
- I added a very descriptive title to this issue.
- I included a link to the documentation page I am referring to (if applicable).
Issue with current documentation:
When following the documentation, attempting to pass a FewShotChatMessagePromptTemplate
instance directly as an element in the array to ChatPromptTemplate.fromMessages
results in a type error. The fromMessages method expects each element to be either a string, a tuple of [role, content], or another compatible message template, but FewShotChatMessagePromptTemplate
is not directly accepted as a valid message input. This leads to confusion for users trying to compose prompts with few-shot examples as shown in the current guide.
Steps to reproduce:
- Create a FewShotChatMessagePromptTemplate instance (fewShotPrompt).
- Attempt to use it directly in ChatPromptTemplate.fromMessages, e.g.:
const finalPrompt = ChatPromptTemplate.fromMessages([
["system", "You are a wondrous wizard of math."],
fewShotPrompt,
["human", "{input}"],
]);
- Observe the following type error thrown by TypeScript:
error TS2322: Type 'FewShotChatMessagePromptTemplate<any, any>' is not assignable to type 'ChatPromptTemplate<InputValues, string> | BaseMessagePromptTemplateLike'.
Type 'FewShotChatMessagePromptTemplate<any, any>' is not assignable to type '{ type: MessageType | "user" | "assistant" | "placeholder"; } & BaseMessageFields & Record<string, unknown>'.
Property 'type' is missing in type 'FewShotChatMessagePromptTemplate<any, any>' but required in type '{ type: MessageType | "user" | "assistant" | "placeholder"; }'.
Expected behavior:
It should be clear in the documentation how to properly integrate few-shot examples into a chat prompt template, and the code examples should not result in type errors.
Actual behavior:
Passing FewShotChatMessagePromptTemplate
directly causes a type error, making it unclear how to compose few-shot prompts with other messages.
Suggested fix:
Update the documentation to show the correct way to combine few-shot examples with other prompt messages, ensuring all code examples are type-safe and runnable.
Idea or request for content:
No response