Download server/utils/agents/aibitat/example/beginner-chat.js from leowuming/rag: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/leowuming/rag/resolve/main/server/utils/agents/aibitat/example/beginner-chat.js
- Command line
-
hf download hf://spaces/leowuming/rag/server/utils/agents/aibitat/example/beginner-chat.js
-
curl -L -o beginner-chat.js https://huggingface.co/spaces/leowuming/rag/resolve/main/server/utils/agents/aibitat/example/beginner-chat.js
1.43 kB
| // You must execute this example from within the example folder. | |
| const AIbitat = require("../index.js"); | |
| const { cli } = require("../plugins/cli.js"); | |
| const { NodeHtmlMarkdown } = require("node-html-markdown"); | |
| require("dotenv").config({ path: `../../../../.env.development` }); | |
| const Agent = { | |
| HUMAN: "🧑", | |
| AI: "🤖", | |
| }; | |
| const aibitat = new AIbitat({ | |
| provider: "openai", | |
| model: "gpt-4o", | |
| }) | |
| .use(cli.plugin()) | |
| .function({ | |
| name: "aibitat-documentations", | |
| description: "The documentation about aibitat AI project.", | |
| parameters: { | |
| type: "object", | |
| properties: {}, | |
| }, | |
| handler: async () => { | |
| return await fetch( | |
| "https://raw.githubusercontent.com/wladiston/aibitat/main/README.md" | |
| ) | |
| .then((res) => res.text()) | |
| .then((html) => NodeHtmlMarkdown.translate(html)) | |
| .catch((e) => { | |
| console.error(e.message); | |
| return "FAILED TO FETCH"; | |
| }); | |
| }, | |
| }) | |
| .agent(Agent.HUMAN, { | |
| interrupt: "ALWAYS", | |
| role: "You are a human assistant.", | |
| }) | |
| .agent(Agent.AI, { | |
| functions: ["aibitat-documentations"], | |
| }); | |
| async function main() { | |
| if (!process.env.OPEN_AI_KEY) | |
| throw new Error( | |
| "This example requires a valid OPEN_AI_KEY in the env.development file" | |
| ); | |
| await aibitat.start({ | |
| from: Agent.HUMAN, | |
| to: Agent.AI, | |
| content: `Please, talk about the documentation of AIbitat.`, | |
| }); | |
| } | |
| main(); | |