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: [alpha] Providers grid refactor #1345

Merged
merged 16 commits into from
Feb 24, 2025
Merged

Conversation

lily-de
Copy link
Collaborator

@lily-de lily-de commented Feb 22, 2025

Overview of new providers architecture

  1. Centralized Provider Registry:
  • All providers are defined in one place, which makes it clear where to add or update a provider.
    This also streamlines maintaining shared logic or styling across providers.
  1. Consistent Base Components
  • Each provider wraps a common “base” component (in this case, a set of <ActionButton>s inside a ProviderCard) to ensure consistent look and feel.
  • Any styling or functionality changes in the base component automatically propagate to all providers.
  1. Default vs. Custom Actions
  • The registry offers default actions (common operations) for most use cases.
  • For edge cases, providers can define custom actions or callbacks, keeping the system flexible.
  1. Easier Maintenance & Onboarding
  • Because definitions live in one folder, newcomers can quickly see all available providers and how they’re structured.
  • Adding or updating a provider involves adding/updating a single file in that folder, rather than scattering definitions across multiple components.

How to view

  1. run just run-ui-alpha
  2. On the more menu you can file 'see new providers grid' in indigo text

Note -- currently buttons do not affect any change, you will just see a success toast pop up to indicate that process for linking callback functions to buttons worked

Details

Terminology

  • Actions / CardActions / ActionButton / ProviderActions: here "Action" in all these terms refers to something that a provider needs in order to be configured or interacted with by the user. These are things such as:
    • adding keys
    • updating current settings
    • refreshing (e.g. for ollama running in the background)
    • launching goose with a certain provider on onboarding
    • deleting keys
  • Callbacks: The functions that are executed upon pressing a button on the card, different buttons have different callbacks -- the Add button pulls up a provider settings modal, the delete button pulls up a confirm modal, the refresh button check for ollama running, etc

Adding a new provider

Adding a new provider with buttons involves adding a similar relatively small item to a mapping

  • name
  • description
  • any required/optional parameters for configuration
  • what buttons to display - the placement of the buttons is handled downstream in a sub component and button definitions can be grouped together into a list of actions mapped to callbacks to generate the final button at rendering time so similar style buttons can have unique callbacks for different cards

example

OpenAI

{
    name: 'OpenAI',
    details: {
      id: 'openai',
      name: 'OpenAI',
      description: 'Access GPT-4, GPT-3.5 Turbo, and other OpenAI models',
      parameters: [
        {
          name: 'OPENAI_API_KEY',
          is_secret: true,
        },
      ],
      getActions: (provider, callbacks) => {
        const { onAdd, onDelete, onShowSettings } = callbacks || {};
        return [
          {
            id: 'default-provider-actions',
            renderButton: () => (
              <DefaultProviderActions
                name={provider.name}
                isConfigured={provider.isConfigured}
                onAdd={onAdd}
                onDelete={onDelete}
                onShowSettings={onShowSettings}
              />
            ),
          },
        ];
      },
    },
  },

Updating card styling (buttons primarily)

  • Updating styling of the card requires editing the button definitions as needed and then updating their placement in a sub component that controls where different buttons show up (CardHeader is currently where the green check goes, CardBody is where other actions/buttons such as editing or adding keys)

log.info('Spawn options:', JSON.stringify(spawnOptions, null, 2));

// Spawn the goosed process
const goosedProcess = spawn(goosedPath, ['agent'], spawnOptions);

Check failure

Code scanning / Semgrep OSS

Command Injection via child_process Error

Command Injection via child_process
@lily-de lily-de force-pushed the ldelalande/providers-refactor branch from 609ef4a to 7e81e19 Compare February 22, 2025 16:27
@lily-de lily-de force-pushed the ldelalande/providers-refactor branch from fd913e5 to 32d7550 Compare February 22, 2025 19:57
@lily-de lily-de linked an issue Feb 22, 2025 that may be closed by this pull request
@lily-de lily-de marked this pull request as ready for review February 24, 2025 16:14
…onents/CardActions.tsx


remove unnecessary log
@lily-de lily-de merged commit c0c9fcc into main Feb 24, 2025
6 checks passed
@lily-de lily-de deleted the ldelalande/providers-refactor branch February 24, 2025 18:03
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.

Implement Provider Registry in UI
3 participants