Repository: Significant-Gravitas/Auto-GPT
File: autogpt_platform/frontend/src/lib/autogpt-server-api/baseClient.ts (TypeScript)

Code before:
  }

  listGraphs(): Promise<GraphMeta[]> {
    return this._get(`/graphs`);
  }

  async listGraphsWithRuns(): Promise<GraphMetaWithRuns[]> {
    let graphs = await this._get(`/graphs?with_runs=true`);
    return graphs.map(parseGraphMetaWithRuns);
  }

  listTemplates(): Promise<GraphMeta[]> {
    return this._get("/templates");
  }

  getGraph(
    id: string,
    version?: number,
    hide_secrets?: boolean,
  ): Promise<Graph> {
    let query = version !== undefined ? `?version=${version}` : "";
    if (hide_secrets !== undefined) {
      query += query ? "&" : "?";
      query += `hide_secrets=${hide_secrets}`;
    }
    return this._get(`/graphs/${id}` + query);
  }

  getTemplate(id: string, version?: number): Promise<Graph> {
    const query = version !== undefined ? `?version=${version}` : "";
    return this._get(`/templates/${id}` + query);
  }

  getGraphAllVersions(id: string): Promise<Graph[]> {
    return this._get(`/graphs/${id}/versions`);
  }

  getTemplateAllVersions(id: string): Promise<Graph[]> {
    return this._get(`/templates/${id}/versions`);
  }

  createGraph(graphCreateBody: GraphCreatable): Promise<Graph>;
  createGraph(fromTemplateID: string, templateVersion: number): Promise<Graph>;
  createGraph(
    graphOrTemplateID: GraphCreatable | string,
    templateVersion?: number,
  ): Promise<Graph> {
    let requestBody: GraphCreateRequestBody;

    if (typeof graphOrTemplateID == "string") {
      if (templateVersion == undefined) {

Review comment (security):
nit: `_get` has a `query: Record<string, any>` parameter:
```ts
  private async _get(path: string, query?: Record<string, any>) {
```
so you can simply do:
```suggestion
    let query: Record<string, any> = {};
    if (version !== undefined) {
      query["version"] = version;
    }
    if (hide_secrets !== undefined) {
      query["hide_secrets"] = hide_secrets;
    }
    return this._get(`/graphs/${id}`, query);
```

Code after:
  }

  listGraphs(): Promise<GraphMeta[]> {
    return this._get(`/graphs`);
  }

  async listGraphsWithRuns(): Promise<GraphMetaWithRuns[]> {
    let graphs = await this._get(`/graphs?with_runs=true`);
    return graphs.map(parseGraphMetaWithRuns);
  }

  listTemplates(): Promise<GraphMeta[]> {
    return this._get("/templates");
  }

  getGraph(
    id: string,
    version?: number,
    hide_credentials?: boolean,
  ): Promise<Graph> {
    let query: Record<string, any> = {};
    if (version !== undefined) {
      query["version"] = version;
    }
    if (hide_credentials !== undefined) {
      query["hide_credentials"] = hide_credentials;
    }
    return this._get(`/graphs/${id}`, query);
  }

  getTemplate(id: string, version?: number): Promise<Graph> {
    const query = version !== undefined ? `?version=${version}` : "";
    return this._get(`/templates/${id}` + query);
  }

  getGraphAllVersions(id: string): Promise<Graph[]> {
    return this._get(`/graphs/${id}/versions`);
  }

  getTemplateAllVersions(id: string): Promise<Graph[]> {
    return this._get(`/templates/${id}/versions`);
  }

  createGraph(graphCreateBody: GraphCreatable): Promise<Graph>;
  createGraph(fromTemplateID: string, templateVersion: number): Promise<Graph>;
  createGraph(
    graphOrTemplateID: GraphCreatable | string,
    templateVersion?: number,
  ): Promise<Graph> {
    let requestBody: GraphCreateRequestBody;