Skip to content

DenoでLangChainを動かして柔軟な対話をしてみる

License

Notifications You must be signed in to change notification settings

whyk-pg/learn-deno-langchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Learn Deno Langchain

本リポジトリの目的

Denoでの生成AI活用を手習いし、実務や個人活動で活かすため

本リポジトリの達成目標

  • AnthropicのAPIを使って、Langchainを動作させる
  • Quickstartを一通りやる
  • 日本語から英語のslugを生成するAPIの作成

作業ログ

Langchain

Cheerio使用時のエラー

実行時、以下のようなエラーが出る。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パーサがあれば、代用可能な認識

OpenAI

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)

参考資料

Deno

Langchain

OpenAI

About

DenoでLangChainを動かして柔軟な対話をしてみる

Resources

License

Stars

Watchers

Forks