gpt-tokenizer icon indicating copy to clipboard operation
gpt-tokenizer copied to clipboard

ChatMessage[] TypeScript warning

Open thdoan opened this issue 8 months ago • 2 comments

I tried to follow sample usage, but the line encodeChat(messages) is returning this warning in VS Code:

[{
        ...
	"message": "Argument of type '{ role: string; content: string; }[]' is not assignable to parameter of type 'readonly ChatMessage[]'.\n  Type '{ role: string; content: string; }' is not assignable to type 'ChatMessage'.\n    Types of property 'role' are incompatible.\n      Type 'string' is not assignable to type '\"system\" | \"user\" | \"assistant\" | undefined'.",
        ...
}]

How do I make this work without TypeScript warnings?

thdoan avatar Oct 17 '23 08:10 thdoan