Skip to content

Commit

Permalink
Make the multinetjs library work with the structured data
Browse files Browse the repository at this point in the history
  • Loading branch information
JackWilb committed Jan 9, 2024
1 parent b6857fc commit a73e6ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface MultinetAxiosInstance extends AxiosInstance {
updateSession(workspace: string, sessionId: number, type: 'network' | 'table', state: object): AxiosPromise<any>;
renameSession(workspace: string, sessionId: number, type: 'network' | 'table', name: string): AxiosPromise<any>;
getSession(workspace: string, sessionId: number, type: 'network' | 'table'): AxiosPromise<any>;
generateAltText(verbosity: string, level: number, explain: string, data: object, title?: string): AxiosPromise<any>;
generateAltText(level: number, structured: boolean, data: object, title?: string): AxiosPromise<any>;
networkBuildRequests(workspace: string): AxiosPromise<number[]>;
}

Expand Down Expand Up @@ -270,16 +270,15 @@ export function multinetAxiosInstance(config: AxiosRequestConfig): MultinetAxios
return this.get(`workspaces/${workspace}/sessions/${type}/${sessionId}/`);
};

Proto.generateAltText = function(verbosity: string, level: number, explain: string, data: object, title?: string): AxiosPromise<any> {
Proto.generateAltText = function(level: number, structured: boolean, data: object, title?: string): AxiosPromise<any> {
const jsonString = JSON.stringify(data);
const blob = new Blob([jsonString], { type: 'application/json' });
const file = new File([blob], 'data.json');

const formData = new FormData();

formData.append('verbosity', verbosity);
formData.append('structured', structured.toString());
formData.append('level', level.toString());
formData.append('explain', explain);
formData.append('data', file);
if (title) {
formData.append('title', title);
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ class MultinetAPI {
return (await this.axios.getSession(workspace, sessionId, type)).data;
}

public async generateAltText(verbosity: string, level: number, explain: string, data: object, title?: string): Promise<any> {
return (await this.axios.generateAltText(verbosity, level, explain, data, title)).data;
public async generateAltText(level: number, structured: boolean, data: object, title?: string): Promise<any> {
return (await this.axios.generateAltText(level, structured, data, title)).data;
}

public async networkBuildRequests(workspace: string): Promise<number[]> {
Expand Down

0 comments on commit a73e6ff

Please sign in to comment.