Denoでの生成AI活用を手習いし、実務や個人活動で活かすため
- AnthropicのAPIを使って、Langchainを動作させる
- Quickstartを一通りやる
- 日本語から英語のslugを生成するAPIの作成
実行時、以下のようなエラーが出る。node_modulesの有無は関係なし。
error: Uncaught (in promise) TypeError: load is not a function
at Function._scrape (file:///home/windchime-yk/dev/org/whyk-pg/learn-deno-langchain/node_modules/.deno/[email protected]/node_modules/langchain/dist/document_loaders/web/cheerio.js:70:16)
at eventLoopTick (ext:core/01_core.js:168:7)
at async CheerioWebBaseLoader.load (file:///home/windchime-yk/dev/org/whyk-pg/learn-deno-langchain/node_modules/.deno/[email protected]/node_modules/langchain/dist/document_loaders/web/cheerio.js:87:19)
at async file:///home/windchime-yk/dev/org/whyk-pg/learn-deno-langchain/main.ts:13:13
内部の実装を見る限りだと、Cheerioを動的インポートしている。
これはCheerioがCommonJS形式でエクスポートしているため、エラーになると思われる。
なお内部的には、以下のような実装になっているようなので、Fetch APIとDOMパーサがあれば、代用可能な認識
langchain-core/src/utils/async_caller.ts
のcallable
にFetch APIを渡すAsyncCaller.call
で指定したURLのHTMLを取得し、Cheerioでパース- パース済みのテキストデータをメタデータと抱き合わせてDocumentインスタンスで返却
429エラーが発生し、動作しなかった。
調べたところアカウント作成時期からして無料期間が終了していたため、OpenAIでの確認は保留する。
なお現在のダッシュボード画面から有効期限は確認できないが、これはダッシュボード画面のリニューアルに伴って表示されなくなったため。
error: Uncaught (in promise) InsufficientQuotaError: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
at Object.defaultFailedAttemptHandler [as onFailedAttempt] (file:///home/windchime-yk/.cache/deno/npm/registry.npmjs.org/@langchain/core/0.1.61/dist/utils/async_caller.js:33:21)
at RetryOperation._fn (file:///home/windchime-yk/.cache/deno/npm/registry.npmjs.org/p-retry/4.6.2/index.js:67:20)
at eventLoopTick (ext:core/01_core.js:168:7)
- npm: specifiers | Deno Docs
- BYONM: Dynamically importing CommonJS file from an npm package errors · Issue #21149 · denoland/deno