-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/AYSZ' into AYSL
- Loading branch information
Showing
7 changed files
with
244 additions
and
27 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 |
---|---|---|
@@ -1,13 +1,132 @@ | ||
# writing assistant using lanchain.js and LanceDB | ||
**AI Writing Assistant with LangChain.js and LanceDB** | ||
====================================================== | ||
|
||
![](https://github.com/lancedb/assets/blob/main/recipes/demo_vid_langchain_integration-ezgif.com-video-to-gif-converter.gif) | ||
This project demonstrates an **AI-powered writing assistant** built using **LangChain.js** and **LanceDB**. The assistant utilizes **OpenAI's API** for language generation and LanceDB for efficient vector storage and retrieval, making it both scalable and customizable. | ||
|
||
# add your open_ai_key (run this command in your terminal) | ||
export OPENAI_API_KEY= your_key | ||
* * * | ||
|
||
# command to run on your local machine | ||
**Features** | ||
------------ | ||
|
||
npm run dev | ||
# To use your own data. go to src>Backend>dataSourceFiles and replace the .txt file | ||
* 🔍 **Customizable Data**: Replace the default dataset with your own text files to tailor the assistant for domain-specific applications. | ||
* ⚡ **Efficient Retrieval**: Uses LanceDB to ensure low-latency and high-accuracy content retrieval. | ||
* 🌐 **Scalable Architecture**: Built with modular components, making it easy to extend functionality or integrate with other tools. | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
* * * | ||
|
||
**Demo** | ||
-------- | ||
|
||
![LangChain.js + LanceDB Demo](https://github.com/lancedb/assets/blob/main/recipes/demo_vid_langchain_integration-ezgif.com-video-to-gif-converter.gif) | ||
|
||
* * * | ||
|
||
**Getting Started** | ||
------------------- | ||
|
||
### **1\. Prerequisites** | ||
|
||
Ensure the following are installed: | ||
|
||
* Node.js (v20 or above) | ||
* NPM or Yarn | ||
* A valid [OpenAI API Key](https://platform.openai.com/signup) | ||
|
||
* * * | ||
|
||
### **2\. Installation** | ||
|
||
Clone the repository and install the required dependencies: | ||
|
||
`git clone` | ||
|
||
`cd` | ||
|
||
`npm install` | ||
|
||
* * * | ||
|
||
### **3\. Configuration** | ||
|
||
Set your OpenAI API key in your environment: | ||
|
||
`export OPENAI_API_KEY=your_openai_key` | ||
|
||
Alternatively, create a `.env` file in the project root: | ||
|
||
|
||
`OPENAI_API_KEY=your_openai_key` | ||
|
||
* * * | ||
|
||
### **4\. Customizing the Dataset** | ||
|
||
To use your own data: | ||
|
||
1. Navigate to the directory: | ||
|
||
|
||
`src/Backend/dataSourceFiles` | ||
|
||
2. Replace the default `.txt` file with your own text file. | ||
3. Restart the server to apply changes. | ||
|
||
* * * | ||
|
||
### **5\. Running the Application** | ||
|
||
Start the development server: | ||
|
||
`npm run dev` | ||
|
||
Access the app in your browser at: | ||
|
||
`http://localhost:3000` | ||
|
||
* * * | ||
|
||
**Technical Details** | ||
--------------------- | ||
|
||
### **How It Works** | ||
|
||
1. **Data Embedding** | ||
|
||
* Text data from the `.txt` file is processed and converted into embeddings using OpenAI's embedding models. | ||
2. **Vector Storage and Retrieval** | ||
|
||
* LanceDB stores and indexes the embeddings for fast similarity-based searches. | ||
* When a user inputs a query, the system retrieves relevant text segments based on vector similarity. | ||
3. **Response Generation** | ||
|
||
* LangChain.js orchestrates the interaction with OpenAI's API, using the retrieved context to generate meaningful responses. | ||
|
||
* * * | ||
|
||
**Commands** | ||
------------ | ||
|
||
* **Start the App**: | ||
|
||
`npm run dev` | ||
|
||
* **Start the server only**: | ||
|
||
`npm run server` | ||
|
||
* **Replace Data**: | ||
Place your `.txt` file in the `src/Backend/dataSourceFiles` directory and restart the server. | ||
|
||
|
||
* * * | ||
|
||
**Future Enhancements** | ||
----------------------- | ||
|
||
* Support for additional file formats (e.g., `.csv`, `.json`). | ||
* Deployment to cloud platforms (e.g., Vercel, AWS). | ||
* A user-friendly interface for uploading and managing datasets. | ||
|
||
* * * | ||
|
||
Feel free to fork, contribute, and customize the project to suit your needs! 🎉 |
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 |
---|---|---|
@@ -1,21 +1,119 @@ | ||
# Real Time autocomplete suggestions using lanchain.js and LanceDB | ||
# upload your data source and start typeing your article and you will be suggested with relevent relea time suggestions that will act as auto complete for your article sentance | ||
# you can also switch between gpt models. | ||
**Real-Time Autocomplete Suggestions with LangChain.js and LanceDB** | ||
|
||
![](https://github.com/lancedb/assets/blob/main/recipes/sentance_Auto_complete.gif) | ||
An AI-powered **real-time autocomplete suggestion tool** built with **LangChain.js** and **LanceDB**. Upload your data source, start typing your article, and receive **relevant sentence suggestions** in real-time. This tool dynamically predicts and completes your sentences, enhancing your writing flow. Additionally, you can seamlessly switch between different **GPT models** for varied outputs. | ||
|
||
# add your open_ai_key (run this command in your terminal) | ||
export OPENAI_API_KEY= your_key | ||
**Demo** | ||
-------- | ||
|
||
# node version above 20 required | ||
# to run only server use | ||
![Real-Time Autocomplete Demo](https://github.com/lancedb/assets/blob/main/recipes/sentance_Auto_complete.gif) | ||
|
||
npm install | ||
npm run server | ||
# command to run on your local machine | ||
**Features** | ||
------------ | ||
|
||
npm install | ||
npm run dev | ||
# To use your own data. go to src>Backend>dataSourceFiles and replace the .txt file or you can upload. | ||
* ✍️ **Real-Time Suggestions**: Contextual, sentence-level suggestions to speed up your writing process. | ||
* 📂 **Customizable Data Source**: Use your own datasets by uploading text files or replacing the default source. | ||
* 🌟 **Switchable Models**: Easily toggle between GPT models for varied response styles. | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
**Getting Started** | ||
------------------- | ||
|
||
### **1\. Prerequisites** | ||
|
||
Ensure you have: | ||
|
||
* **Node.js** version **20+** installed. | ||
* A valid [OpenAI API Key](https://platform.openai.com/signup). | ||
|
||
### **2\. Installation** | ||
|
||
#### Clone the Repository and Install Dependencies: | ||
|
||
|
||
`git clone` | ||
|
||
`cd ` | ||
|
||
`npm install` | ||
|
||
### **3\. Configuration** | ||
|
||
Set your OpenAI API key in your environment: | ||
|
||
`export OPENAI_API_KEY=your_openai_key` | ||
|
||
Alternatively, you can create a `.env` file in the project root: | ||
|
||
`OPENAI_API_KEY=your_openai_key` | ||
|
||
### **4\. Running the Server Only** | ||
|
||
To run just the backend server: | ||
|
||
`npm run server` | ||
|
||
|
||
### **5\. Running the Full Application** | ||
|
||
To run the full application locally: | ||
|
||
`npm run dev` | ||
|
||
Access the app in your browser at: | ||
|
||
`http://localhost:3000` | ||
|
||
|
||
**Customizing the Dataset** | ||
--------------------------- | ||
|
||
### Upload or Replace the Data Source: | ||
|
||
1. Navigate to: | ||
|
||
plaintext | ||
|
||
Copy code | ||
|
||
`src/Backend/dataSourceFiles` | ||
|
||
2. Replace the default `.txt` file with your custom text file **or** use the file upload functionality in the app. | ||
3. Restart the server to load the new dataset. | ||
|
||
**Technical Overview** | ||
|
||
### **How It Works** | ||
|
||
1. **Data Preprocessing and Embedding** | ||
|
||
* Input data is tokenized and converted into embeddings using OpenAI's models. | ||
2. **Vector Search and Retrieval** | ||
|
||
* LanceDB efficiently retrieves the most relevant text snippets based on similarity to the user's input. | ||
3. **Real-Time Sentence Suggestions** | ||
|
||
* LangChain.js dynamically generates sentence-level completions tailored to the current context. | ||
4. **Model Switching** | ||
|
||
* Easily toggle between GPT models in the application for diverse suggestions. | ||
|
||
**Commands** | ||
|
||
* **Start the Backend Server**: | ||
|
||
`npm run server` | ||
|
||
* **Run the Full Application**: | ||
|
||
`npm run dev` | ||
|
||
* **Replace or Upload Data**: | ||
Place your `.txt` file in the `src/Backend/dataSourceFiles` directory or use the file upload feature in the app. | ||
|
||
**Future Enhancements** | ||
----------------------- | ||
|
||
* Support for more file formats, such as `.csv` and `.json`. | ||
* Interactive UI for dataset uploads and management. | ||
* Deployable versions for cloud platforms like AWS, Vercel, or Netlify. | ||
|
||
Feel free to fork, contribute, and customize this project for your unique requirements! 🚀 |
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