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(ai): introduce vercel ai sdk support #316

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

gladyshcodes
Copy link
Contributor

@gladyshcodes gladyshcodes commented Feb 4, 2025

Issue #291

What

Integrate Vercel AI SDK

Why

Simplify the introduction of new providers and models in the future, specifically, Amazon Bedrock (#310) and OpenAI when available

Copy link

vercel bot commented Feb 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
shortest ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 10:30pm

@CLAassistant
Copy link

CLAassistant commented Feb 4, 2025

CLA assistant check
All committers have signed the CLA.

@gladyshcodes
Copy link
Contributor Author

In progress:

  1. Nits
  2. Testing
  3. Feedback iterations

@rmarescu rmarescu added this to the v0.4.4 milestone Feb 5, 2025
Copy link
Member

@rmarescu rmarescu left a comment

Choose a reason for hiding this comment

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

Added some initial comments.

packages/shortest/src/ai/client-provider.ts Outdated Show resolved Hide resolved
packages/shortest/src/ai/client-provider.ts Outdated Show resolved Hide resolved
packages/shortest/src/ai/client-provider.ts Outdated Show resolved Hide resolved
packages/shortest/src/ai/client-provider.ts Outdated Show resolved Hide resolved
packages/shortest/src/ai/client.ts Outdated Show resolved Hide resolved
packages/shortest/src/ai/client_v2.ts Outdated Show resolved Hide resolved
@gladyshcodes gladyshcodes marked this pull request as ready for review February 6, 2025 22:17
@gladyshcodes
Copy link
Contributor Author

@rmarescu Feedback addressed

@gladyshcodes gladyshcodes requested a review from rmarescu February 6, 2025 22:23
Copy link
Member

@rmarescu rmarescu left a comment

Choose a reason for hiding this comment

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

Submitting a partial review. High-level thoughts:

  • No need to map Vercel's models with a local list, it complicates the implementation without too much gain
  • Use AI instead of LLM (don't need 2 names that represent almost the same thing within the codebase)
  • Config schema seems complicated. Can be simplified?

packages/shortest/tests/unit/test-config.ts Outdated Show resolved Hide resolved
packages/shortest/tests/unit/test-config.ts Outdated Show resolved Hide resolved
packages/shortest/package.json Outdated Show resolved Hide resolved
packages/shortest/package.json Outdated Show resolved Hide resolved
packages/shortest/package.json Outdated Show resolved Hide resolved
packages/shortest/src/types/config.ts Outdated Show resolved Hide resolved
}

export interface LLMPPublicConfig {
provider: LLMSupportedProvidersType;
Copy link
Member

Choose a reason for hiding this comment

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

I think even this one can be optional. Ideally, there should be zero config to run Shortest.

No ai prop provided should default to the provider we think is the best, e.g. anthropic, which tries to read the apiKey from ENV (as Vercel AI SDK supports it by default).

Copy link
Contributor Author

@gladyshcodes gladyshcodes Feb 7, 2025

Choose a reason for hiding this comment

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

I personally don't see a strong case for simplifying the configuration. Keeping all settings in a single file actually reduces the cognitive load, as it makes it clear where each value comes from and how the final configuration is assembled

Ideally, there should be zero config to run Shortest

Achieving that is unlikely—especially as users increasingly demand more flexibility and control over Shortest (see, for example, issue #313)

What is possible, though, is keeping all non-sensitive data in config and sensitive data (e.g keys) in the env, not to duplicate them in the config

packages/shortest/src/types/config.ts Outdated Show resolved Hide resolved
packages/shortest/src/types/config.ts Outdated Show resolved Hide resolved
packages/shortest/src/types/config.ts Outdated Show resolved Hide resolved
Copy link

vercel bot commented Feb 7, 2025

You must have Developer access to commit code to Antiwork on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/accounts/team-members-and-roles/access-roles#team-level-roles

@rmarescu rmarescu assigned rmarescu and unassigned gladyshcodes Feb 12, 2025
@rmarescu
Copy link
Member

rmarescu commented Feb 12, 2025

Remaining work (will update as needed):

  • Simplify config
  • Add more logging as needed
  • Verify token usage calculation
  • Test coverage
  • Update shortest.config.ts.example
  • Add support for SHORTEST_ANTHROPIC_API_KEY
  • Verify functionality/code against the old class

rmarescu added a commit that referenced this pull request Feb 13, 2025
In preparation for #316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants