Closed diffshare closed 1 year ago
dpbd/tiktoken を利用するが、下記エラーが発生
Uncaught TypeError: wasm.__wbindgen_add_to_stack_pointer is not a function
at encoding_for_model (tiktoken_bg.js:197:1)
at ./src/App.tsx (App.tsx:76:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at ./src/index.tsx (App.tsx:378:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at startup:7:1
at startup:7:1
[gpt-4] 次のコードのようにuserInputのトークン数を表示する変更を行いました。この変更のpull requestの内容をテンプレートに従って出力してください。 ...
useState
フックを使用して、userInputTokenCount
ステートを追加しました。countTokens
関数を定義し、userInput
が更新されるたびに実行して、トークン数を計算するようにしました。userInputTokenCount
を表示する要素を追加しました。
[人間] ChatGPTのtokenの仕組みを調査。
以下のトークナイザーを用いていることがわかった。
https://github.com/openai/tiktoken star 3.3k
他のトークナイザーに比べて高速らしい。 これのnodeの移植版が2つくらい見つかった。
starが多い dpbd/tiktoken を利用する方法を検討する。