-
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.
- Loading branch information
Rishi Raj Jain
committed
Apr 27, 2023
1 parent
0d1a6d7
commit 2b3ee88
Showing
9 changed files
with
69 additions
and
62 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,5 @@ | ||
dist/ | ||
node_modules/ | ||
.env | ||
.DS_Store | ||
.edgio |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
connector: "./edgio", | ||
routes: "./edgio/routes.cjs", | ||
}; | ||
connector: './edgio', | ||
routes: './edgio/routes.cjs', | ||
} |
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 |
---|---|---|
@@ -1,24 +1,19 @@ | ||
const { join } = require("path"); | ||
const { existsSync } = require("fs"); | ||
const { nodeFileTrace } = require("@vercel/nft"); | ||
const { DeploymentBuilder } = require("@edgio/core/deploy"); | ||
const { join } = require('path') | ||
const { existsSync } = require('fs') | ||
const { nodeFileTrace } = require('@vercel/nft') | ||
const { DeploymentBuilder } = require('@edgio/core/deploy') | ||
|
||
const appDir = process.cwd(); | ||
const appDir = process.cwd() | ||
|
||
module.exports = async () => { | ||
const builder = new DeploymentBuilder(); | ||
builder.clearPreviousBuildOutput(); | ||
if (existsSync(join(appDir, ".env"))) { | ||
builder.addJSAsset(join(appDir, ".env")); | ||
const builder = new DeploymentBuilder() | ||
builder.clearPreviousBuildOutput() | ||
const env = ['.env.production', '.env'].map((i) => join(appDir, i)).find(existsSync) | ||
if (env) { | ||
builder.addJSAsset(env) | ||
} | ||
if (existsSync(join(appDir, ".env.production"))) { | ||
builder.addJSAsset(join(appDir, ".env.production")); | ||
} | ||
const { fileList } = await nodeFileTrace([join(appDir, "src", "index.mjs")]); | ||
fileList.forEach((i) => builder.addJSAsset(join(appDir, i))); | ||
builder.writeFileSync( | ||
join(builder.jsDir, "__backends__", "package.json"), | ||
JSON.stringify({ type: "commonjs" }) | ||
); | ||
await builder.build(); | ||
}; | ||
const { fileList } = await nodeFileTrace([join(appDir, 'src', 'index.mjs')]) | ||
fileList.forEach((i) => builder.addJSAsset(join(appDir, i))) | ||
builder.writeFileSync(join(builder.jsDir, '__backends__', 'package.json'), JSON.stringify({ type: 'commonjs' })) | ||
await builder.build() | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = async (port) => { | ||
process.env.PORT = port.toString(); | ||
await import("../src/index.mjs"); | ||
}; | ||
process.env.PORT = port.toString() | ||
await import('../src/index.mjs') | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { Router } from "@edgio/core/router"; | ||
import { Router } from '@edgio/core/router' | ||
|
||
const router = new Router(); | ||
const router = new Router() | ||
|
||
router.fallback(({ renderWithApp }) => { | ||
renderWithApp(); | ||
}); | ||
renderWithApp() | ||
}) | ||
|
||
export default router; | ||
export default router |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import { join } from "path"; | ||
import express from "express"; | ||
import { existsSync } from "fs"; | ||
import * as dotenv from "dotenv"; | ||
import { OpenAI } from "langchain/llms/openai"; | ||
import { ConversationChain } from "langchain/chains"; | ||
import { join } from 'path' | ||
import express from 'express' | ||
import { existsSync } from 'fs' | ||
import * as dotenv from 'dotenv' | ||
import { OpenAI } from 'langchain/llms/openai' | ||
import { ConversationChain } from 'langchain/chains' | ||
|
||
const app = express(); | ||
const appDir = process.cwd(); | ||
const port = process.env.PORT || 3001; | ||
const app = express() | ||
const appDir = process.cwd() | ||
const port = process.env.PORT || 3001 | ||
|
||
if (existsSync(join(appDir, ".env"))) { | ||
dotenv.config({ path: join(appDir, ".env") }); | ||
} else if (existsSync(join(appDir, ".env.production"))) { | ||
dotenv.config({ path: join(appDir, ".env.production") }); | ||
const env = ['.env.production', '.env'].map((i) => join(appDir, i)).find(existsSync) | ||
|
||
if (env) { | ||
dotenv.config({ path: env }) | ||
} else { | ||
dotenv.config(); | ||
dotenv.config() | ||
} | ||
|
||
const model = new OpenAI({}); | ||
const model = new OpenAI({}) | ||
|
||
app.post("/chat", express.json(), async (req, res) => { | ||
const chain = new ConversationChain({ llm: model }); | ||
const input = req.body.input; | ||
const result = await chain.call({ input }); | ||
console.log(result.response); | ||
res.send({ body: result.response }); | ||
}); | ||
app.post('/chat', express.json(), async (req, res) => { | ||
const chain = new ConversationChain({ llm: model }) | ||
const input = req.body.input | ||
const result = await chain.call({ input }) | ||
console.log(result.response) | ||
res.send({ body: result.response }) | ||
}) | ||
|
||
app.listen(port, () => console.log(`Listening on port ${port}`)); | ||
app.listen(port, () => console.log(`Listening on port ${port}`)) |