forked from langchain-ai/langchainjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test-exports-vite, update docusaurus
- Loading branch information
Showing
24 changed files
with
729 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + TS</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "test-exports-vite", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"test": "tsc" | ||
}, | ||
"dependencies": { | ||
"langchain": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.9.3", | ||
"vite": "^4.2.0", | ||
"vite-plugin-top-level-await": "^1.3.0", | ||
"vite-plugin-wasm": "^3.2.2" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Import a few things we'll use to test the exports | ||
import { LLMChain } from "langchain/chains"; | ||
import { ChatOpenAI } from "langchain/chat_models/openai"; | ||
import { | ||
ChatPromptTemplate, | ||
HumanMessagePromptTemplate, | ||
} from "langchain/prompts"; | ||
import { CallbackManager } from "langchain/callbacks"; | ||
|
||
export function setupChain(element: HTMLButtonElement) { | ||
const runChain = async () => { | ||
const llm = new ChatOpenAI({ | ||
// Don't do this in your app, it would leak your API key | ||
openAIApiKey: import.meta.env.VITE_OPENAI_API_KEY, | ||
streaming: true, | ||
callbackManager: CallbackManager.fromHandlers({ | ||
handleLLMNewToken: async (token) => | ||
console.log("handleLLMNewToken", token), | ||
}), | ||
}); | ||
|
||
// Test count tokens | ||
const n = await llm.getNumTokens("Hello"); | ||
console.log("getNumTokens", n); | ||
|
||
// Test a chain + prompt + model | ||
const chain = new LLMChain({ | ||
llm, | ||
prompt: ChatPromptTemplate.fromPromptMessages([ | ||
HumanMessagePromptTemplate.fromTemplate("{input}"), | ||
]), | ||
}); | ||
const res = await chain.run("hello"); | ||
|
||
console.log("runChain", res); | ||
}; | ||
element.addEventListener("click", runChain); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export * from "langchain/agents"; | ||
export * from "langchain/base_language"; | ||
export * from "langchain/tools"; | ||
export * from "langchain/chains"; | ||
export * from "langchain/embeddings/base"; | ||
export * from "langchain/embeddings/fake"; | ||
export * from "langchain/embeddings/openai"; | ||
export * from "langchain/llms/base"; | ||
export * from "langchain/llms/openai"; | ||
export * from "langchain/prompts"; | ||
export * from "langchain/vectorstores/base"; | ||
export * from "langchain/vectorstores/prisma"; | ||
export * from "langchain/text_splitter"; | ||
export * from "langchain/memory"; | ||
export * from "langchain/document"; | ||
export * from "langchain/docstore"; | ||
export * from "langchain/document_loaders/base"; | ||
export * from "langchain/chat_models/base"; | ||
export * from "langchain/chat_models/openai"; | ||
export * from "langchain/chat_models/anthropic"; | ||
export * from "langchain/schema"; | ||
export * from "langchain/callbacks"; | ||
export * from "langchain/output_parsers"; | ||
export * from "langchain/retrievers/remote"; | ||
export * from "langchain/cache"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// import all entrypoints to test, do not do this in your own app | ||
import "./entrypoints.js"; | ||
|
||
import "./style.css"; | ||
import typescriptLogo from "./typescript.svg"; | ||
import viteLogo from "/vite.svg"; | ||
import { setupChain } from "./chain"; | ||
|
||
document.querySelector<HTMLDivElement>("#app")!.innerHTML = ` | ||
<div> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src="${viteLogo}" class="logo" alt="Vite logo" /> | ||
</a> | ||
<a href="https://www.typescriptlang.org/" target="_blank"> | ||
<img src="${typescriptLogo}" class="logo vanilla" alt="TypeScript logo" /> | ||
</a> | ||
<h1>Vite + TypeScript</h1> | ||
<div class="card"> | ||
<button id="chain" type="button">click to run chain</button> | ||
</div> | ||
<p class="read-the-docs"> | ||
Click on the Vite and TypeScript logos to learn more | ||
</p> | ||
</div> | ||
`; | ||
|
||
setupChain(document.querySelector<HTMLButtonElement>("#chain")!); |
Oops, something went wrong.