Skip to content

Commit 2dd0a65

Browse files
authored
feat: Add component GitHub infiniflow#1739 (infiniflow#1871)
### What problem does this PR solve? feat: Add component GitHub infiniflow#1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
1 parent 5686f03 commit 2dd0a65

File tree

8 files changed

+52
-0
lines changed

8 files changed

+52
-0
lines changed

web/src/assets/svg/github.svg

+6
Loading

web/src/locales/en.ts

+3
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ The above is the content you need to summarize.`,
667667
authKey: 'Auth key',
668668
sourceLang: 'Source language',
669669
targetLang: 'Target language',
670+
gitHub: 'GitHub',
671+
githubDescription:
672+
'This component is used to search the repository from https://github.com/. Top N specifies the number of search results to be adjusted.',
670673
},
671674
footer: {
672675
profile: 'All rights reserved @ React',

web/src/locales/zh-traditional.ts

+3
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ export default {
625625
authKey: '授權鍵',
626626
sourceLang: '原始語言',
627627
targetLang: '目標語言',
628+
gitHub: 'GitHub',
629+
gitHubDescription:
630+
'此元件用於從 https://github.com/ 搜尋儲存庫。 Top N 指定要調整的搜尋結果的數量。',
628631
},
629632
footer: {
630633
profile: '“保留所有權利 @ react”',

web/src/locales/zh.ts

+3
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,9 @@ export default {
643643
authKey: '授权键',
644644
sourceLang: '源语言',
645645
targetLang: '目标语言',
646+
gitHub: 'GitHub',
647+
githubDescription:
648+
'该组件用于从 https://github.com/ 搜索仓库。Top N 指定需要调整的搜索结果数量。',
646649
},
647650
footer: {
648651
profile: 'All rights reserved @ React',

web/src/pages/flow/constant.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ReactComponent as BaiduIcon } from '@/assets/svg/baidu.svg';
33
import { ReactComponent as BingIcon } from '@/assets/svg/bing.svg';
44
import { ReactComponent as DeepLIcon } from '@/assets/svg/deepl.svg';
55
import { ReactComponent as DuckIcon } from '@/assets/svg/duck.svg';
6+
import { ReactComponent as GithubIcon } from '@/assets/svg/github.svg';
67
import { ReactComponent as GoogleScholarIcon } from '@/assets/svg/google-scholar.svg';
78
import { ReactComponent as GoogleIcon } from '@/assets/svg/google.svg';
89
import { ReactComponent as KeywordIcon } from '@/assets/svg/keyword.svg';
@@ -48,6 +49,7 @@ export enum Operator {
4849
Bing = 'Bing',
4950
GoogleScholar = 'GoogleScholar',
5051
DeepL = 'DeepL',
52+
GitHub = 'GitHub',
5153
}
5254

5355
export const operatorIconMap = {
@@ -69,6 +71,7 @@ export const operatorIconMap = {
6971
[Operator.Bing]: BingIcon,
7072
[Operator.GoogleScholar]: GoogleScholarIcon,
7173
[Operator.DeepL]: DeepLIcon,
74+
[Operator.GitHub]: GithubIcon,
7275
};
7376

7477
export const operatorMap = {
@@ -153,6 +156,7 @@ export const operatorMap = {
153156
[Operator.Bing]: {},
154157
[Operator.GoogleScholar]: {},
155158
[Operator.DeepL]: {},
159+
[Operator.GitHub]: {},
156160
};
157161

158162
export const componentMenuList = [
@@ -207,6 +211,9 @@ export const componentMenuList = [
207211
{
208212
name: Operator.DeepL,
209213
},
214+
{
215+
name: Operator.GitHub,
216+
},
210217
];
211218

212219
export const initialRetrievalValues = {
@@ -316,6 +323,10 @@ export const initialDeepLValues = {
316323
auth_key: 'relevance',
317324
};
318325

326+
export const initialGithubValues = {
327+
top_n: 5,
328+
};
329+
319330
export const CategorizeAnchorPointPositions = [
320331
{ top: 1, right: 34 },
321332
{ top: 8, right: 18 },
@@ -381,6 +392,7 @@ export const RestrictedUpstreamMap = {
381392
[Operator.Bing]: [Operator.Begin, Operator.Retrieval],
382393
[Operator.GoogleScholar]: [Operator.Begin, Operator.Retrieval],
383394
[Operator.DeepL]: [Operator.Begin, Operator.Retrieval],
395+
[Operator.GitHub]: [Operator.Begin, Operator.Retrieval],
384396
};
385397

386398
export const NodeMap = {
@@ -402,6 +414,7 @@ export const NodeMap = {
402414
[Operator.Bing]: 'ragNode',
403415
[Operator.GoogleScholar]: 'ragNode',
404416
[Operator.DeepL]: 'ragNode',
417+
[Operator.GitHub]: 'ragNode',
405418
};
406419

407420
export const LanguageOptions = [

web/src/pages/flow/flow-drawer/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import CategorizeForm from '../categorize-form';
1212
import { Operator } from '../constant';
1313
import DuckDuckGoForm from '../duckduckgo-form';
1414
import GenerateForm from '../generate-form';
15+
import GithubForm from '../github-form';
1516
import GoogleForm from '../google-form';
1617
import GoogleScholarForm from '../google-scholar-form';
1718
import { useHandleFormValuesChange, useHandleNodeNameChange } from '../hooks';
@@ -50,6 +51,7 @@ const FormMap = {
5051
[Operator.Bing]: BingForm,
5152
[Operator.GoogleScholar]: GoogleScholarForm,
5253
[Operator.DeepL]: DeepLForm,
54+
[Operator.GitHub]: GithubForm,
5355
};
5456

5557
const EmptyContent = () => <div>empty</div>;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import TopNItem from '@/components/top-n-item';
2+
import { Form } from 'antd';
3+
import { IOperatorForm } from '../interface';
4+
5+
const GithubForm = ({ onValuesChange, form }: IOperatorForm) => {
6+
return (
7+
<Form
8+
name="basic"
9+
labelCol={{ span: 6 }}
10+
wrapperCol={{ span: 18 }}
11+
autoComplete="off"
12+
form={form}
13+
onValuesChange={onValuesChange}
14+
>
15+
<TopNItem initialValue={5}></TopNItem>
16+
</Form>
17+
);
18+
};
19+
20+
export default GithubForm;

web/src/pages/flow/hooks.ts

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
initialDeepLValues,
3939
initialDuckValues,
4040
initialGenerateValues,
41+
initialGithubValues,
4142
initialGoogleScholarValues,
4243
initialGoogleValues,
4344
initialKeywordExtractValues,
@@ -101,6 +102,7 @@ export const useInitializeOperatorParams = () => {
101102
[Operator.Bing]: initialBingValues,
102103
[Operator.GoogleScholar]: initialGoogleScholarValues,
103104
[Operator.DeepL]: initialDeepLValues,
105+
[Operator.GitHub]: initialGithubValues,
104106
};
105107
}, [llmId]);
106108

0 commit comments

Comments
 (0)