-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "langchain-sdk-demo", | ||
"version": "1.0.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"test": "webpack && phatjs dist/index.js" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@langchain/openai": "^0.0.15", | ||
"@phala/sidevm-env": "^1.0.2", | ||
"array.prototype.flatmap": "^1.3.1" | ||
}, | ||
"devDependencies": { | ||
"@swc/cli": "^0.1.62", | ||
"@swc/core": "^1.3.51", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-config-standard-with-typescript": "^26.0.0", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-n": "^15.0.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"ts-loader": "^9.4.2", | ||
"typescript": "*", | ||
"webpack": "^5.75.0", | ||
"webpack-cli": "^5.0.1" | ||
} | ||
} |
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,8 @@ | ||
module.exports = { | ||
entry: { | ||
web: __dirname + "/src/index.ts", | ||
}, | ||
output: { | ||
path: __dirname + "/dist", | ||
}, | ||
}; |
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,14 @@ | ||
import "@phala/sidevm-env" | ||
import { ChatOpenAI } from "@langchain/openai"; | ||
|
||
const OPENAI_API_KEY = ""; | ||
|
||
async function main() { | ||
const chatModel = new ChatOpenAI({ | ||
openAIApiKey: OPENAI_API_KEY | ||
}); | ||
const response = await chatModel.invoke("what is LangSmith?"); | ||
console.log("response:", JSON.stringify(response)); | ||
} | ||
|
||
main().catch(console.error).finally(() => Sidevm.exit()); |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist/", | ||
"noImplicitAny": true, | ||
"module": "es6", | ||
"target": "es2020", | ||
"allowJs": true, | ||
"moduleResolution": "node" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
sidevm-quickjs/examples/gpt-langchain-sdk/webpack.config.js
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,23 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
entry: './src/index', | ||
mode: 'production', | ||
output: { | ||
filename: 'index.js', | ||
path: path.resolve(__dirname, 'dist'), | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'], | ||
}, | ||
target: 'web', | ||
}; |
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