Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/DocumentStore #2106

Merged
merged 61 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
114b185
datasource: initial commit
vinodkiran Mar 22, 2024
bc92e1b
datasource: datasource details and chunks
vinodkiran Mar 23, 2024
7a411f2
datasource: Document Store Node
vinodkiran Mar 23, 2024
3171170
Merge branch 'main' into FEATURE/Datasource
vinodkiran Mar 24, 2024
a0d323a
Merge branch 'main' into FEATURE/Datasource
vinodkiran Mar 26, 2024
c01d1f9
more changes
vinodkiran Mar 28, 2024
e3c96d1
Document Store - Base functionality
vinodkiran Mar 31, 2024
48987a1
Document Store Loader Component
vinodkiran Apr 1, 2024
b78a1d0
Document Store Loader Component
vinodkiran Apr 2, 2024
73ffa74
before merging the modularity PR
vinodkiran Apr 3, 2024
7a116e0
Merge branch 'main' into FEATURE/Datasource
vinodkiran Apr 3, 2024
e675e37
after merging the modularity PR
vinodkiran Apr 3, 2024
e3101ee
preview mode
vinodkiran Apr 4, 2024
3b21afd
initial draft PR
vinodkiran Apr 5, 2024
1c20a89
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 5, 2024
6fd01ae
fixes
vinodkiran Apr 5, 2024
bb4202b
minor updates and fixes
vinodkiran Apr 6, 2024
5229085
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 8, 2024
f873460
preview with loader and splitter
vinodkiran Apr 8, 2024
aaa9272
preview with credential
vinodkiran Apr 8, 2024
0c42894
show stored chunks
vinodkiran Apr 10, 2024
63945c5
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 11, 2024
14800af
preview update...
vinodkiran Apr 12, 2024
7412e76
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 12, 2024
1856369
edit config
vinodkiran Apr 12, 2024
5412c0e
save, preview and other changes
vinodkiran Apr 13, 2024
458f8b1
save, preview and other changes
vinodkiran Apr 13, 2024
ca52066
save, process and other changes
vinodkiran Apr 14, 2024
f6a0706
save, process and other changes
vinodkiran Apr 14, 2024
ccc5f0e
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 14, 2024
e5a86c5
Merge branch 'refs/heads/main' into FEATURE/Datasource
vinodkiran Apr 15, 2024
47924e3
alpha1 - for internal testing
vinodkiran Apr 16, 2024
43b90e5
rerouting urls
vinodkiran Apr 16, 2024
2914b0a
bug fix on new leader create
vinodkiran Apr 16, 2024
22163a5
pagination support for chunks
vinodkiran Apr 21, 2024
cf84342
delete document store
vinodkiran Apr 21, 2024
52b2d19
Merge branch 'main' into feature/Datasource
HenryHengZJ Apr 25, 2024
18e75fb
Update pnpm-lock.yaml
HenryHengZJ Apr 25, 2024
73ff491
Merge branch 'main' into feature/Datasource
HenryHengZJ Apr 26, 2024
c473195
doc store card view
HenryHengZJ Apr 27, 2024
bf22598
Update store files to use updated storage functions, Document Store T…
vinodkiran Apr 27, 2024
4fb1e72
ui changes
HenryHengZJ Apr 29, 2024
029f7cf
Merge branch 'main' into feature/Datasource
HenryHengZJ Apr 29, 2024
68037e4
add expanded chunk dialog, improve ui
HenryHengZJ Apr 30, 2024
b180f25
change throw Error to InternalError
HenryHengZJ Apr 30, 2024
5da5044
Bug Fixes and removal of subFolder, adding of view chunks for store
vinodkiran Apr 30, 2024
235a124
lint fixes
vinodkiran Apr 30, 2024
dae134d
Merge remote-tracking branch 'origin/FEATURE/Datasource' into FEATURE…
vinodkiran Apr 30, 2024
389fa88
merge changes
vinodkiran Apr 30, 2024
e2b4daa
DocumentStoreStatus component
vinodkiran Apr 30, 2024
56de0f8
ui changes for doc store
HenryHengZJ Apr 30, 2024
f073ef6
add remove metadata key field, add custom document loader
HenryHengZJ May 1, 2024
ba6b951
add chatflows used doc store chips
HenryHengZJ May 1, 2024
71324c5
add types/interfaces to DocumentStore Services
vinodkiran May 1, 2024
ac19f7f
document loader list dialog title bar color change
HenryHengZJ May 1, 2024
353af9a
update interfaces
HenryHengZJ May 1, 2024
85becf4
Whereused Chatflow Name and Added chunkNo to retain order of created …
vinodkiran May 2, 2024
9f462f6
Merge branch 'main' into feature/Datasource
HenryHengZJ May 2, 2024
1e0f964
use typeorm order chunkNo, ui changes
HenryHengZJ May 2, 2024
3308cb1
Merge branch 'main' into feature/Datasource
HenryHengZJ May 2, 2024
5301db5
Merge branch 'main' into feature/Datasource
HenryHengZJ May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README-JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a href="https://github.com/FlowiseAI/Flowise">
<img width="100%" src="https://github.com/FlowiseAI/Flowise/blob/main/images/flowise.gif?raw=true"></a>

## ⚡クイックスタート
## ⚡ クイックスタート

[NodeJS](https://nodejs.org/en/download) >= 18.15.0 をダウンロードしてインストール

Expand Down Expand Up @@ -67,7 +67,7 @@

## 👨‍💻 開発者向け

Flowise には、3つの異なるモジュールが1つの mono リポジトリにあります。
Flowise には、3 つの異なるモジュールが 1 つの mono リポジトリにあります。

- `server`: API ロジックを提供する Node バックエンド
- `ui`: React フロントエンド
Expand Down
28 changes: 14 additions & 14 deletions README-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ English | [中文](./README-ZH.md) | [日本語](./README-JA.md) | 한국어
<a href="https://github.com/FlowiseAI/Flowise">
<img width="100%" src="https://github.com/FlowiseAI/Flowise/blob/main/images/flowise.gif?raw=true"></a>

## ⚡빠른 시작 가이드
## ⚡빠른 시작 가이드

18.15.0 버전 이상의 [NodeJS](https://nodejs.org/en/download) 다운로드 및 설치

Expand All @@ -43,10 +43,10 @@ English | [中文](./README-ZH.md) | [日本語](./README-JA.md) | 한국어
### 도커 컴포즈 활용

1. 프로젝트의 최상위(root) 디렉토리에 있는 `docker` 폴더로 이동하세요.
2. `.env.example` 파일을 복사한 후, 같은 경로에 붙여넣기 한 다음, `.env`로 이름을 변경합니다.
2. `.env.example` 파일을 복사한 후, 같은 경로에 붙여넣기 한 다음, `.env`로 이름을 변경합니다.
3. `docker-compose up -d` 실행
4. [http://localhost:3000](http://localhost:3000) URL 열기
5. `docker-compose stop` 명령어를 통해 컨테이너를 종료시킬 수 있습니다.
5. `docker-compose stop` 명령어를 통해 컨테이너를 종료시킬 수 있습니다.

### 도커 이미지 활용

Expand All @@ -70,7 +70,7 @@ English | [中文](./README-ZH.md) | [日本語](./README-JA.md) | 한국어
Flowise는 단일 리포지토리에 3개의 서로 다른 모듈이 있습니다.

- `server`: API 로직을 제공하는 노드 백엔드
- `ui`: 리액트 프론트엔드
- `ui`: 리액트 프론트엔드
- `components`: 서드파티 노드 통합을 위한 컴포넌트

### 사전 설치 요건
Expand Down Expand Up @@ -112,11 +112,11 @@ Flowise는 단일 리포지토리에 3개의 서로 다른 모듈이 있습니
pnpm start
```

이제 [http://localhost:3000](http://localhost:3000)에서 애플리케이션에 접속할 수 있습니다.
이제 [http://localhost:3000](http://localhost:3000)에서 애플리케이션에 접속할 수 있습니다.

6. 개발 환경에서 빌드할 경우:

- `packages/ui`경로에 `.env` 파일을 생성하고 `VITE_PORT`(`.env.example` 참조)를 지정합니다.
- `packages/ui`경로에 `.env` 파일을 생성하고 `VITE_PORT`(`.env.example` 참조)를 지정합니다.
- `packages/server`경로에 `.env` 파일을 생성하고 `PORT`(`.env.example` 참조)를 지정합니다.
- 실행하기

Expand All @@ -143,7 +143,7 @@ Flowise는 인스턴스 구성을 위한 다양한 환경 변수를 지원합니

[Flowise 문서](https://docs.flowiseai.com/)

## 🌐 자체 호스팅 하기
## 🌐 자체 호스팅 하기

기존 인프라 환경에서 Flowise를 자체 호스팅으로 배포하세요. 다양한 배포 [deployments](https://docs.flowiseai.com/configuration/deployment) 방법을 지원합니다.

Expand Down Expand Up @@ -182,23 +182,23 @@ Flowise는 인스턴스 구성을 위한 다양한 환경 변수를 지원합니

## 💻 클라우드 호스팅 서비스

곧 출시될 예정입니다.
곧 출시될 예정입니다.

## 🙋 기술 지원
## 🙋 기술 지원

질문, 버그 리포팅, 새로운 기능 요청 등은 [discussion](https://github.com/FlowiseAI/Flowise/discussions) 섹션에서 자유롭게 이야기 해주세요.
질문, 버그 리포팅, 새로운 기능 요청 등은 [discussion](https://github.com/FlowiseAI/Flowise/discussions) 섹션에서 자유롭게 이야기 해주세요.

## 🙌 오픈소스 활동에 기여하기

다음과 같은 멋진 기여자들(contributors)에게 감사드립니다.
다음과 같은 멋진 기여자들(contributors)에게 감사드립니다.

<a href="https://github.com/FlowiseAI/Flowise/graphs/contributors">
<img src="https://contrib.rocks/image?repo=FlowiseAI/Flowise" />
</a>

[contributing guide](CONTRIBUTING.md)를 살펴보세요. 디스코드 [Discord](https://discord.gg/jbaHfsRVBW) 채널에서도 이슈나 질의응답을 진행하실 수 있습니다.
[contributing guide](CONTRIBUTING.md)를 살펴보세요. 디스코드 [Discord](https://discord.gg/jbaHfsRVBW) 채널에서도 이슈나 질의응답을 진행하실 수 있습니다.
[![Star History Chart](https://api.star-history.com/svg?repos=FlowiseAI/Flowise&type=Timeline)](https://star-history.com/#FlowiseAI/Flowise&Date)

## 📄 라이센스
## 📄 라이센스

본 리포지토리의 소스코드는 [Apache License Version 2.0](LICENSE.md) 라이센스가 적용됩니다.
본 리포지토리의 소스코드는 [Apache License Version 2.0](LICENSE.md) 라이센스가 적용됩니다.
64 changes: 49 additions & 15 deletions packages/components/nodes/documentloaders/API/APILoader.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import axios, { AxiosRequestConfig } from 'axios'
import { omit } from 'lodash'
import { Document } from '@langchain/core/documents'
import { TextSplitter } from 'langchain/text_splitter'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { ICommonObject, IDocument, INode, INodeData, INodeParams } from '../../../src/Interface'

class API_DocumentLoaders implements INode {
label: string
Expand Down Expand Up @@ -66,6 +67,25 @@ class API_DocumentLoaders implements INode {
'JSON body for the POST request. If not specified, agent will try to figure out itself from AIPlugin if provided',
additionalParams: true,
optional: true
},
{
label: 'Additional Metadata',
name: 'metadata',
type: 'json',
description: 'Additional metadata to be added to the extracted documents',
optional: true,
additionalParams: true
},
{
label: 'Omit Metadata Keys',
name: 'omitMetadataKeys',
type: 'string',
rows: 4,
description:
'Each document loader comes with a default set of metadata keys that are extracted from the document. You can use this field to omit some of the default metadata keys. The value should be a list of keys, seperated by comma',
placeholder: 'key1, key2, key3.nestedKey1',
optional: true,
additionalParams: true
}
]
}
Expand All @@ -76,6 +96,12 @@ class API_DocumentLoaders implements INode {
const method = nodeData.inputs?.method as string
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string

let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
omitMetadataKeys = _omitMetadataKeys.split(',').map((key) => key.trim())
}

const options: ApiLoaderParams = {
url,
Expand All @@ -94,7 +120,7 @@ class API_DocumentLoaders implements INode {

const loader = new ApiLoader(options)

let docs = []
let docs: IDocument[] = []

if (textSplitter) {
docs = await loader.loadAndSplit(textSplitter)
Expand All @@ -104,18 +130,26 @@ class API_DocumentLoaders implements INode {

if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
let finaldocs = []
for (const doc of docs) {
const newdoc = {
...doc,
metadata: {
docs = docs.map((doc) => ({
...doc,
metadata: omit(
{
...doc.metadata,
...parsedMetadata
}
}
finaldocs.push(newdoc)
}
return finaldocs
},
omitMetadataKeys
)
}))
} else {
docs = docs.map((doc) => ({
...doc,
metadata: omit(
{
...doc.metadata
},
omitMetadataKeys
)
}))
}

return docs
Expand Down Expand Up @@ -146,15 +180,15 @@ class ApiLoader extends BaseDocumentLoader {
this.method = method
}

public async load(): Promise<Document[]> {
public async load(): Promise<IDocument[]> {
if (this.method === 'POST') {
return this.executePostRequest(this.url, this.headers, this.body)
} else {
return this.executeGetRequest(this.url, this.headers)
}
}

protected async executeGetRequest(url: string, headers?: ICommonObject): Promise<Document[]> {
protected async executeGetRequest(url: string, headers?: ICommonObject): Promise<IDocument[]> {
try {
const config: AxiosRequestConfig = {}
if (headers) {
Expand All @@ -174,7 +208,7 @@ class ApiLoader extends BaseDocumentLoader {
}
}

protected async executePostRequest(url: string, headers?: ICommonObject, body?: ICommonObject): Promise<Document[]> {
protected async executePostRequest(url: string, headers?: ICommonObject, body?: ICommonObject): Promise<IDocument[]> {
try {
const config: AxiosRequestConfig = {}
if (headers) {
Expand Down
61 changes: 44 additions & 17 deletions packages/components/nodes/documentloaders/Airtable/Airtable.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import axios from 'axios'
import { omit } from 'lodash'
import { Document } from '@langchain/core/documents'
import { TextSplitter } from 'langchain/text_splitter'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
import { getCredentialData, getCredentialParam } from '../../../src/utils'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { IDocument, ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'

class Airtable_DocumentLoaders implements INode {
label: string
Expand Down Expand Up @@ -93,9 +94,21 @@ class Airtable_DocumentLoaders implements INode {
description: 'Number of results to return. Ignored when Return All is enabled.'
},
{
label: 'Metadata',
label: 'Additional Metadata',
name: 'metadata',
type: 'json',
description: 'Additional metadata to be added to the extracted documents',
optional: true,
additionalParams: true
},
{
label: 'Omit Metadata Keys',
name: 'omitMetadataKeys',
type: 'string',
rows: 4,
description:
'Each document loader comes with a default set of metadata keys that are extracted from the document. You can use this field to omit some of the default metadata keys. The value should be a list of keys, seperated by comma',
placeholder: 'key1, key2, key3.nestedKey1',
optional: true,
additionalParams: true
}
Expand All @@ -111,6 +124,12 @@ class Airtable_DocumentLoaders implements INode {
const limit = nodeData.inputs?.limit as string
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata
const _omitMetadataKeys = nodeData.inputs?.omitMetadataKeys as string

let omitMetadataKeys: string[] = []
if (_omitMetadataKeys) {
omitMetadataKeys = _omitMetadataKeys.split(',').map((key) => key.trim())
}

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const accessToken = getCredentialParam('accessToken', credentialData, nodeData)
Expand All @@ -131,7 +150,7 @@ class Airtable_DocumentLoaders implements INode {
throw new Error('Base ID and Table ID must be provided.')
}

let docs = []
let docs: IDocument[] = []

if (textSplitter) {
docs = await loader.loadAndSplit(textSplitter)
Expand All @@ -141,18 +160,26 @@ class Airtable_DocumentLoaders implements INode {

if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
let finaldocs = []
for (const doc of docs) {
const newdoc = {
...doc,
metadata: {
docs = docs.map((doc) => ({
...doc,
metadata: omit(
{
...doc.metadata,
...parsedMetadata
}
}
finaldocs.push(newdoc)
}
return finaldocs
},
omitMetadataKeys
)
}))
} else {
docs = docs.map((doc) => ({
...doc,
metadata: omit(
{
...doc.metadata
},
omitMetadataKeys
)
}))
}

return docs
Expand Down Expand Up @@ -213,7 +240,7 @@ class AirtableLoader extends BaseDocumentLoader {
this.returnAll = returnAll
}

public async load(): Promise<Document[]> {
public async load(): Promise<IDocument[]> {
if (this.returnAll) {
return this.loadAll()
}
Expand All @@ -238,7 +265,7 @@ class AirtableLoader extends BaseDocumentLoader {
}
}

private createDocumentFromPage(page: AirtableLoaderPage): Document {
private createDocumentFromPage(page: AirtableLoaderPage): IDocument {
// Generate the URL
const pageUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}/${page.id}`

Expand All @@ -251,7 +278,7 @@ class AirtableLoader extends BaseDocumentLoader {
})
}

private async loadLimit(): Promise<Document[]> {
private async loadLimit(): Promise<IDocument[]> {
let data: AirtableLoaderRequest = {
maxRecords: this.limit,
view: this.viewId
Expand Down Expand Up @@ -282,7 +309,7 @@ class AirtableLoader extends BaseDocumentLoader {
return returnPages.map((page) => this.createDocumentFromPage(page))
}

private async loadAll(): Promise<Document[]> {
private async loadAll(): Promise<IDocument[]> {
let data: AirtableLoaderRequest = {
view: this.viewId
}
Expand Down
Loading
Loading