Skip to content

feat(agentflow) Create Async Data Fetching Infrastructure in agentflow#5937

Draft
j-sanaa wants to merge 5 commits intomainfrom
feat/agentflow-create-async-infra
Draft

feat(agentflow) Create Async Data Fetching Infrastructure in agentflow#5937
j-sanaa wants to merge 5 commits intomainfrom
feat/agentflow-create-async-infra

Conversation

@j-sanaa
Copy link
Contributor

@j-sanaa j-sanaa commented Mar 9, 2026

JIRA - FLOWISE-227

  • Created API modules for models, tools, and credentials
  • created loadMethodRegistry which allows for dynamic API dispatch
  • Added test cases for all new files
  • Added new example - API inspector to verify that all endpoints are called correctly using the newly added API models

Recording of testing all new API endpoints -

API.calls.verification.mov

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the agentflow package by establishing a robust asynchronous data fetching infrastructure. It provides structured API access for models, tools, and credentials, and introduces a dynamic dispatch mechanism for these services. The changes aim to streamline API interactions and improve the maintainability and testability of the data layer, complemented by a new interactive example for verification.

Highlights

  • New API Modules: Introduced dedicated API modules for fetching models, tools, and credentials, enhancing the data fetching capabilities within agentflow.
  • Dynamic API Dispatch: Implemented a loadMethodRegistry to enable dynamic dispatch of API calls, providing a flexible mechanism for interacting with different API services based on method names.
  • API Inspector Example: Added a new example, the 'API Inspector', which serves as a live testing and verification tool for the newly created API endpoints and the loadMethodRegistry.
  • Comprehensive Testing: Included new test cases for all newly added API modules and the loadMethodRegistry to ensure their correct functionality and reliability.
Changelog
  • packages/agentflow/examples/src/App.tsx
    • Imported ApiInspectorExampleProps.
    • Registered the new 'API Inspector' example in the application's example list.
  • packages/agentflow/examples/src/demos/ApiInspectorExample.tsx
    • Added a new React component ApiInspectorExample to demonstrate and test the new API modules and loadMethodRegistry.
  • packages/agentflow/examples/src/demos/index.ts
    • Exported the new ApiInspectorExample component.
  • packages/agentflow/src/core/types/index.ts
    • Defined new TypeScript interfaces for Model, Tool, and Credential.
  • packages/agentflow/src/index.ts
    • Exported ApiServices and getLoadMethod from the API infrastructure.
    • Exported the new Credential, Model, and Tool types for broader use.
  • packages/agentflow/src/infrastructure/api/client.ts
    • Removed withCredentials: true from the Axios client configuration, commenting it out.
  • packages/agentflow/src/infrastructure/api/credentials.test.ts
    • Added unit tests for the createCredentialsApi functions.
  • packages/agentflow/src/infrastructure/api/credentials.ts
    • Created createCredentialsApi to handle API calls related to credentials, including fetching all credentials and filtering by name.
  • packages/agentflow/src/infrastructure/api/index.ts
    • Exported createCredentialsApi, CredentialsApi, ApiServices, getLoadMethod, loadMethodRegistry, createModelsApi, ModelsApi, createToolsApi, and ToolsApi.
  • packages/agentflow/src/infrastructure/api/loadMethodRegistry.test.ts
    • Added unit tests for the loadMethodRegistry and getLoadMethod functions.
  • packages/agentflow/src/infrastructure/api/loadMethodRegistry.ts
    • Defined ApiServices interface and loadMethodRegistry for mapping method names to API calls, along with getLoadMethod for retrieving these functions.
  • packages/agentflow/src/infrastructure/api/models.test.ts
    • Added unit tests for the createModelsApi functions.
  • packages/agentflow/src/infrastructure/api/models.ts
    • Created createModelsApi to manage API calls for models, including fetching all chat models and filtering by provider.
  • packages/agentflow/src/infrastructure/api/tools.test.ts
    • Added unit tests for the createToolsApi functions.
  • packages/agentflow/src/infrastructure/api/tools.ts
    • Created createToolsApi to provide API functions for tools, such as fetching all tools and retrieving a tool by ID.
  • packages/agentflow/src/infrastructure/store/ApiContext.test.tsx
    • Updated mock imports for API creation functions to include models, tools, and credentials APIs.
    • Extended API context assertions to verify the presence of new API services.
  • packages/agentflow/src/infrastructure/store/ApiContext.tsx
    • Updated ApiContextValue to include modelsApi, toolsApi, and credentialsApi.
    • Modified ApiProvider to initialize and provide instances of the new API modules.
Activity
  • The pull request was created by j-sanaa to implement new asynchronous data fetching infrastructure.
  • New API modules for models, tools, and credentials were added.
  • A loadMethodRegistry was introduced for dynamic API dispatch.
  • Test cases were added for all new files.
  • A new example, the API Inspector, was created to verify API endpoints.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a robust asynchronous data fetching infrastructure for agentflow, creating dedicated API modules for models, tools, and credentials, and adds a loadMethodRegistry for dynamic API dispatch. While the overall structure is sound, it introduces potential URL and Path Injection vulnerabilities where user-supplied parameters are directly concatenated into URLs; these should be remediated by using proper URL encoding or leveraging the built-in parameter handling of the HTTP client library (Axios). Additionally, there are opportunities to improve code clarity by refactoring data fetching functions to use async/await with try/catch and to ensure type safety by addressing a potential unsafe type assertion in loadMethodRegistry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant