-
Notifications
You must be signed in to change notification settings - Fork 243
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
In progress:
|
There was a problem hiding this 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.
@rmarescu Feedback addressed |
There was a problem hiding this 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 ofLLM
(don't need 2 names that represent almost the same thing within the codebase) - Config schema seems complicated. Can be simplified?
} | ||
|
||
export interface LLMPPublicConfig { | ||
provider: LLMSupportedProvidersType; |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
Co-authored-by: Razvan Marescu <razvan@marescu.net>
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 |
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Co-authored-by: Razvan Marescu <razvan@marescu.net>
Details
|
} else { | ||
if (event.level === "warn") { | ||
console.warn( | ||
pc.bgYellowBright(pc.black(" WARN ")), | ||
pc.yellow(event.message), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | ||
this.conversationHistory.push(initialMessageOptions); | ||
this.log.trace("💬", "New conversation message", initialMessageOptions); | ||
this.log.trace("💬", "Conversation history initialized", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each test triggers runAction
> runConversation
. This tracing should make is easier to follow the AI conversation and the tools executed.
private get tools(): Record<string, CoreTool> { | ||
if (this._tools) return this._tools; | ||
|
||
this._tools = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All tools should have the same interface internally, and be managed via a ToolsRegistry or such (can be addressed in a future PR).
@@ -607,6 +611,8 @@ export class BrowserTool extends BaseBrowserTool { | |||
}; | |||
} | |||
throw new ToolError(`Action failed: ${error}`); | |||
} finally { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored all resetGroup
calls to be called within a finally
block. This approach ensures the log groups are properly defined with minimal logic.
try {
this.log.setGroup("New group");
} finally {
this.log.resetGroup();
}
@@ -122,10 +122,8 @@ function getParamValue(args: string[], paramName: string): string | undefined { | |||
async function main() { | |||
const args = process.argv.slice(2); | |||
const logLevel = getParamValue(args, "--log-level"); | |||
const logFormat = getParamValue(args, "--log-format"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed to removed in a previous PR where --log-format
was removed as a CLI arg.
|
||
private filesCount: number = 0; | ||
private testsCount: number = 0; | ||
private passedTestsCount: number = 0; | ||
private failedTestsCount: number = 0; | ||
private totalInputTokens: number = 0; | ||
private totalOutputTokens: number = 0; | ||
private totalPromptTokens: number = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to match the terminology from AI providers.
); | ||
} | ||
|
||
private parseMetadata(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly moved from log/output.ts, with some adjustments.
if (event.level === "error") { | ||
message = pc.red(message); | ||
} | ||
|
||
let outputParts = []; | ||
outputParts.push(colorFn(`${level}`.padEnd(LogOutput.MAX_LEVEL_LENGTH))); | ||
outputParts.push(timestamp); | ||
outputParts.push( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.Simplified fro full timestamp, to only HH:MM:SS
// import { LanguageModelUsage } from "ai"; | ||
import { z } from "zod"; | ||
|
||
// TODO: Validate against LanguageModelUsage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be done in a follow-up PR.
@@ -20,6 +22,7 @@ IMPORTANT GLOBAL RULES: | |||
- After invoking a tool, wait until the tool finishes its execution and you receive a success/failure result. | |||
- You will also receive metadata about the tool's execution to help you interpret its outcome. | |||
- Only after the tool finishes and you know the result should you request any screenshots or proceed to the next action. | |||
- Always include the "action" field matching the tool name in your tool calls (e.g. for "navigate" tool, include 'action: "navigate"'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is critial to ensure that Vercel AI SDK doesn't return AI_InvalidToolArgumentsError
.
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