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

Feat custom request func skylark #43

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function ChartPreview(props: IPropsType) {
</div>
{props.spec ? (
<div>
<p>Total Time: {props.costTime / 1000} ms</p>
<p>Total Time: {props.costTime / 1000} s</p>
<p>spec:</p>
<TextArea value={JSON.stringify(props.spec, null, 4)} style={{ height: 300 }}></TextArea>
{/*<pre style={{ whiteSpace: 'pre' }}>{JSON.stringify(props.spec, null, 4)}</pre>*/}
Expand Down
5 changes: 3 additions & 2 deletions packages/vmind/__tests__/browser/src/pages/DataInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import VMind from '../../../../src/index';
import { Model } from '../../../../src/index';
import { queryDataset } from '../../../../src/gpt/dataProcess';
import { isArray } from 'lodash';
//import { mockDataset } from './mockData'
import { mockDataset, mockData2 } from './mockData';

const TextArea = Input.TextArea;
const Option = Select.Option;
Expand Down Expand Up @@ -124,7 +124,8 @@ export function DataInput(props: IPropsType) {
const { fieldInfo, dataset } = vmind.parseCSVData(csv);
//const { fieldInfo: fieldInfoQuery, dataset: datasetQuery } = await vmind?.dataQuery(describe, fieldInfo, dataset);
//const { fieldInfo, dataset, usage } = await vmind.parseCSVDataWithLLM(csv, describe);
//const dataset = mockDataset

//const dataset = mockData2
//const fieldInfo = vmind?.getFieldInfo(dataset)
const startTime = new Date().getTime();
const chartGenerationRes = await vmind.generateChart(describe, fieldInfo, dataset);
Expand Down
2 changes: 1 addition & 1 deletion packages/vmind/src/core/VMind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class VMind {
}
if (this.getModelType() === ModelType.SKYLARK) {
console.error('Please user GPT model');
return { fieldInfo: [], dataset };
return { fieldInfo: [], dataset } as any;
}
console.error('unsupported model in data query!');

Expand Down
7 changes: 5 additions & 2 deletions packages/vmind/src/skylark/chart-generation/NLToChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export const chartAdvisorSkylark = async (
chartRecommendConstraintsStr,
options.showThoughts ?? true
);
const chartRecommendRes = await requestSkyLark(chartRecommendPrompt, userMessage, options);

const requestFunc = options.customRequestFunc?.chartAdvisor ?? requestSkyLark;

const chartRecommendRes = await requestFunc(chartRecommendPrompt, userMessage, options);
const chartRecommendResJSON = parseSkylarkResponse(chartRecommendRes);
if (chartRecommendResJSON.error) {
throw Error(chartRecommendResJSON.message);
Expand All @@ -106,7 +109,7 @@ export const chartAdvisorSkylark = async (
options.showThoughts ?? true
);

const fieldMapRes = await requestSkyLark(fieldMapPrompt, userMessage, options);
const fieldMapRes = await requestFunc(fieldMapPrompt, userMessage, options);
const fieldMapResJson = parseSkylarkResponse(fieldMapRes);
if (fieldMapResJson.error) {
throw Error('Network Error!');
Expand Down
Loading