Skip to content

Commit

Permalink
Merge pull request #96 from multinet-app/structured-alt-txt
Browse files Browse the repository at this point in the history
Make the multinetjs library work with the structured data
  • Loading branch information
JackWilb authored Jan 9, 2024
2 parents ae53ee6 + 40f76a3 commit d87f795
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, explain: string, data: object, title?: string, level?: number): AxiosPromise<any>;
generateAltText(structured: boolean, data: object, title?: string, level?: number): AxiosPromise<any>;
networkBuildRequests(workspace: string): AxiosPromise<number[]>;
}

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

Proto.generateAltText = function(verbosity: string, explain: string, data: object, title?: string, level?: number): AxiosPromise<any> {
Proto.generateAltText = function(structured: boolean, data: object, title?: string, level?: number): 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('explain', explain);
formData.append('structured', structured.toString());
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, explain: string, data: object, title?: string, level?: number): Promise<any> {
return (await this.axios.generateAltText(verbosity, explain, data, title, level)).data;
public async generateAltText(structured: boolean, data: object, title?: string, level?: number): Promise<any> {
return (await this.axios.generateAltText(structured, data, title, level)).data;
}

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

0 comments on commit d87f795

Please sign in to comment.