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

LLM tool #224

Merged
merged 28 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ef63133
Merge branch 'open-mmlab:main' into dev-lixinghua
lixinghua123 Apr 26, 2023
31dde27
feat: LLM tool question view
lixinghua123 May 26, 2023
39e45a7
feat: LLM Tool Answer Scoring Module
lixinghua123 May 26, 2023
586b522
feat: LLM tool answer sort
lixinghua123 May 26, 2023
b1f06b9
feat: LLM Tool Answer Scoring Module
lixinghua123 May 26, 2023
0ba1df5
feat: LLM tool annotation module
lixinghua123 May 26, 2023
8a01832
feat: LLM Tool Showcase
lixinghua123 May 26, 2023
1b784df
feat: LLM tool shortcuts
lixinghua123 May 26, 2023
a2d7b10
feat: LLM tool mock data
lixinghua123 May 26, 2023
07dfa1b
feat: LLM tool submit datas
lixinghua123 May 29, 2023
ac81ff3
feat: LLM tool question view
lixinghua123 May 26, 2023
22f840f
feat: LLM Tool Answer Scoring Module
lixinghua123 May 26, 2023
3ae2880
feat: LLM tool answer sort
lixinghua123 May 26, 2023
cd97a12
feat: LLM Tool Answer Scoring Module
lixinghua123 May 26, 2023
e945b60
feat: LLM tool annotation module
lixinghua123 May 26, 2023
e7a1edb
feat: LLM Tool Showcase
lixinghua123 May 26, 2023
d937e9a
feat: LLM tool shortcuts
lixinghua123 May 26, 2023
5cb779b
feat: LLM tool mock data
lixinghua123 May 26, 2023
59b45b7
feat: LLM tool submit datas
lixinghua123 May 29, 2023
0fc671b
feat: LLM Tool View Mode Internationalization
lixinghua123 Jun 6, 2023
5bc5c45
feat: LLM Tool Style Adjustment
lixinghua123 Jun 6, 2023
571a694
feat: LLM Tool type adjustment
lixinghua123 Jun 7, 2023
7e02842
feat: LLM Tool answer sort key adjustment
lixinghua123 Jun 8, 2023
c4a4ce2
feat: LLM tool mock data
lixinghua123 Jun 8, 2023
432070c
feat: LLM Tool type adjustment
lixinghua123 Jun 8, 2023
a15f0ee
Merge branch 'LLM-lixinghua' of github.com:lixinghua123/labelbee into…
lixinghua123 Jul 3, 2023
486a68f
fix: LLM tool code optimisation
lixinghua123 Jul 3, 2023
c83c4b3
fix: LLM tool type adjustment
lixinghua123 Jul 3, 2023
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: 4 additions & 0 deletions packages/lb-annotation/src/constant/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export enum EToolName {
Cuboid = 'cuboidTool',
/** 点云多边形工具 */
PointCloudPolygon = 'pointCloudPolygon',
/** LLM标注工具 */
LLM = 'LLMTool',
}

export enum ECheckModel {
Expand Down Expand Up @@ -99,6 +101,7 @@ export const TOOL_NAME: { [a: string]: string } = {
[EVideoToolName.VideoClipTool]: '视频截取',
[EPointCloudName.PointCloud]: '点云',
[EToolName.Cuboid]: '立体框',
[EToolName.LLM]: 'LLM标注',
};

export const TOOL_NAME_EN: { [a: string]: string } = {
Expand All @@ -123,6 +126,7 @@ export const TOOL_NAME_EN: { [a: string]: string } = {
[EVideoToolName.VideoClipTool]: 'VideoClipTool',
[EPointCloudName.PointCloud]: 'PointCloud',
[EToolName.Cuboid]: 'Cuboid',
[EToolName.LLM]: 'LLM',
};

export enum EDependPattern {
Expand Down
82 changes: 82 additions & 0 deletions packages/lb-components/src/components/LLMToolView/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* @file LLM tool view
* @Author: lixinghua [email protected]
* @Date: 2023-04-10
*/

import React, { useContext, useEffect, useState } from 'react';
import { AppState } from '@/store';
import { connect } from 'react-redux';
import { LabelBeeContext } from '@/store/ctx';
import { message } from 'antd';
import { prefix } from '@/constant';
import { LLMContext } from '@/views/MainView';
lixinghua123 marked this conversation as resolved.
Show resolved Hide resolved
import { Layout } from 'antd/es';
import LLMSidebar from '@/components/LLMToolView/sidebar';
import { getStepConfig } from '@/store/annotation/reducer';
import QuestionView from './questionView';
import { useTranslation } from 'react-i18next';
import { IAnswerList } from './types';

interface IProps {
checkMode?: boolean;
annotation?: any;
setHoverKey: (value: number) => void;
}
const { Sider } = Layout;
const LLMViewCls = `${prefix}-LLMView`;
const layoutCls = `${prefix}-layout`;
const LLMToolView: React.FC<IProps> = (props) => {
const { annotation, setHoverKey, checkMode } = props;
const { imgIndex, imgList, stepList, step } = annotation;
const { hoverKey } = useContext(LLMContext);
const [answerList, setAnswerList] = useState<IAnswerList[]>([]);
const [question, setQuestion] = useState<string>('');
const LLMStepConfig = getStepConfig(stepList, step)?.config;
const { t } = useTranslation();
useEffect(() => {
let interval: undefined | ReturnType<typeof setInterval>;

if (!checkMode) {
interval = setInterval(() => {
message.info(t('EfficientListening'));
}, 1000 * 60);

return () => {
if (interval) {
clearInterval(interval);
}
};
}
}, []);

useEffect(() => {
if (!imgList[imgIndex]) {
return;
}

const qaData = imgList[imgIndex]?.questionList;

setQuestion(qaData?.question);
setAnswerList(qaData?.answerList || []);
}, [imgIndex]);

return (
<Layout className={LLMViewCls}>
<QuestionView hoverKey={hoverKey} question={question} answerList={answerList} />
{LLMStepConfig && LLMStepConfig !== '{}' && (
<Sider className={`${layoutCls}__side`} width={600}>
<LLMSidebar setHoverKey={setHoverKey} checkMode={checkMode} />
</Sider>
)}
</Layout>
);
};

const mapStateToProps = (state: AppState) => {
return {
annotation: state.annotation,
};
};

export default connect(mapStateToProps, null, null, { context: LabelBeeContext })(LLMToolView);
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* @file Question view
* @Author: lixinghua [email protected]
* @Date: 2023-04-10
*/

import React, { useEffect } from 'react';
import { Tag } from 'antd';
import LongText from '@/components/longText';
import { prefix } from '@/constant';
import classNames from 'classnames';
import { useTranslation, I18nextProvider } from 'react-i18next';
import { IAnswerList } from '@/components/LLMToolView/types';
import { i18n } from '@labelbee/lb-utils';

interface IProps {
hoverKey?: number;
question: any;
answerList: IAnswerList[];
lang?: string;
}
const LLMViewCls = `${prefix}-LLMView`;
const QuestionView: React.FC<IProps> = (props) => {
const { hoverKey, question, answerList, lang } = props;
const { t } = useTranslation();

useEffect(() => {
if (lang) {
i18n?.changeLanguage(lang);
}
}, []);

return (
<div className={LLMViewCls}>
<div className={`${LLMViewCls}__textBox`} style={{ borderBottom: '1px solid #EBEBEB' }}>
<div className={`${LLMViewCls}__title`}>{t('Title')}</div>
<div className={`${LLMViewCls}__content`}>
<LongText wordCount={200} text={question} />
</div>
</div>
<div className={`${LLMViewCls}__textBox`}>
<div className={`${LLMViewCls}__title`}>{t('Answer')}</div>
{answerList.map((i: IAnswerList, index: number) => (
<div
className={classNames({
[`${LLMViewCls}__content`]: true,
[`${LLMViewCls}__contentActive`]: hoverKey === i?.order,
})}
key={index}
>
<Tag
style={{
color: '#666FFF',
background: '#eeefff',
height: '20px',
padding: '0px 8px',
border: 'none',
}}
>
{i?.order}
</Tag>
<LongText wordCount={1000} text={i?.answer} />
</div>
))}
</div>
</div>
);
};

const WrapQuestionView = (props: IProps) => {
return (
<I18nextProvider i18n={i18n}>
<QuestionView {...props} />
</I18nextProvider>
);
};

export default WrapQuestionView;
Loading