Package Exports
- @tonytruong/chatbot-ai-lib
- @tonytruong/chatbot-ai-lib/dist/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tonytruong/chatbot-ai-lib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@tonytruong/chatbot-ai-lib
A library for AI-powered healthcare automation, document parsing, OpenAI integration, and more. Supports embedding, RAG, file parsing, vector database, Facebook OAuth, and utility helpers.
Installation
npm install @tonytruong/chatbot-ai-lib
# or
yarn add @tonytruong/chatbot-ai-libUsage
Import modules
import * as autoCare from '@tonytruong/chatbot-ai-lib';
// or import only what you need:
import { embedding, rag, file, vectordb, openai, facebook, generateRandomToken } from '@tonytruong/chatbot-ai-lib';Configure OpenAI API Key & Model
Bạn có thể cấu hình API key, model, chroma url... bằng cách:
import { setOpenAIConfig } from '@tonytruong/chatbot-ai-lib/config/openai';
setOpenAIConfig({ apiKey: process.env.OPENAI_API_KEY, model: 'gpt-3.5-turbo' });Hoặc truyền trực tiếp vào từng hàm:
await embedding.embedChunks(["Xin chào!"], { apiKey: 'your-key', model: 'your-model' });Embedding Example
import { embedding } from '@tonytruong/chatbot-ai-lib';
const vectors = await embedding.embedChunks(["Xin chào!"]);RAG (Retrieval-Augmented Generation)
import { rag } from '@tonytruong/chatbot-ai-lib';
const answer = await rag.answerWithRAG('Câu hỏi?', 'user-id', ['history1', 'history2']);File Parsing
import { file } from '@tonytruong/chatbot-ai-lib';
const chunks = await file.readAndChunk('/path/to/file.pdf', 'file.pdf');Vector Database
import { vectordb } from '@tonytruong/chatbot-ai-lib';
const collection = await vectordb.getCollection();OpenAI Chat
import { openai } from '@tonytruong/chatbot-ai-lib';
const reply = await openai.getReplyWithContext('Xin chào!', 'user-id');Facebook OAuth
import { facebook } from '@tonytruong/chatbot-ai-lib';
const url = facebook.getFacebookAuthUrl({ clientId: '...', clientSecret: '...', redirectUri: '...' }, 'state');Utility: Generate Random Token
import { generateRandomToken } from '@tonytruong/chatbot-ai-lib';
const token = generateRandomToken(32);License
MIT
Author
Tony Truong tonytruongdev@gmail.com
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.