Closed
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
AI-ASSISTED: Cursor
d0f47be to
b25576c
Compare
Contributor
Author
|
@greptileai , i have updated this pr with a squash commit , please update your review based on the actually submitted pr (current) |
| const prefix = "huggingface/"; | ||
| const lowerS = s.toLowerCase(); | ||
| if (lowerS.startsWith(prefix)) { | ||
| return s.slice(lowerS.indexOf(prefix) + prefix.length).trim() || s; |
Contributor
There was a problem hiding this comment.
overly complex - lowerS.indexOf(prefix) always returns 0 when startsWith check passes
simplify to:
Suggested change
| return s.slice(lowerS.indexOf(prefix) + prefix.length).trim() || s; | |
| return s.slice(prefix.length).trim() || s; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/huggingface-models.ts
Line: 33
Comment:
overly complex - `lowerS.indexOf(prefix)` always returns 0 when `startsWith` check passes
simplify to:
```suggestion
return s.slice(prefix.length).trim() || s;
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
huggingface/prefix (or “huggingface” as preface) caused errors, and the HF Inference client was given the full string including the prefix even though the API expects only a Hub-style model id and optional tags.:cheapest,:fastest).modelIdForHfInferenceClient()to strip a leadinghuggingface/before calling the HF client; Pi embedded runner uses it when resolving Hugging Face models so the resolved Modelidnever includes the prefix. Removed duplicatebuildHuggingfaceProviderinmodels-config.providers.ts. Added tests for the new helper.:cheapest,:fastest,:provider, etc.) are unchanged; only the string sent to the HF inference client is normalized.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
huggingface/org/model) could error or send the prefix to the HF API.org/model:cheapest). No change to non-HF providers or to how users write refs in config/CLI.Security Impact (required)
Repro + Verification
Environment
models.providers.huggingfaceand/or onboarding with Hugging Face selectedSteps
HF_TOKENorHUGGINGFACE_HUB_TOKEN).huggingface/prefix (e.g.huggingface/mistralai/Mistral-7B-Instruct-v0.3or a path that previously sent the prefix).Expected
Actual (before fix)
Evidence
Attach at least one:
modelIdForHfInferenceClient; Pi embedded runner model resolution with HF)Human Verification (required)
modelIdForHfInferenceClient(strip prefix, preserve tags, no change when no prefix). Model resolution path in Pi embedded runner usesnormalizedModelIdfor Hugging Face so resolved Modelidhas no prefix.Compatibility / Migration
Failure Recovery (if this breaks)
src/agents/huggingface-models.ts,src/agents/pi-embedded-runner/model.ts,src/agents/models-config.providers.ts,src/agents/huggingface-models.test.ts.Risks and Mitigations
idstill containinghuggingface/for display or routing.Mitigation: Normalization is applied only for the Hugging Face provider in the Pi embedded runner resolution path; display/CLI can still show the user’s original ref; HF API contract requires no prefix.
Greptile Summary
This PR fixes HuggingFace Inference API integration by stripping the
huggingface/prefix before sending model IDs to the HF client. The core fix is small and correct:modelIdForHfInferenceClient()helper insrc/agents/huggingface-models.ts:28to normalize model IDssrc/agents/pi-embedded-runner/model.ts:61to use the helper when resolving HuggingFace modelsKey changes:
huggingface/deepseek-ai/DeepSeek-R1are normalized todeepseek-ai/DeepSeek-R1before calling HF API:cheapest,:fastest,:provider) are preserved correctlyHuggingFace/orHUGGINGFACE/are handled case-insensitivelyScope concern: This PR includes 72 files with extensive refactoring of extensions (
bluebubbles,feishu,line,zalo,msteams) and test files. While these appear to be legitimate type safety improvements and refactoring (removing unused types, addingGroupPolicytype annotations), they should ideally be in separate commits or PRs. The PR description claims this is a focused bug fix, but the actual changes include substantial unrelated work.Confidence Score: 4/5
vi.resetModules()cleanup issue has been addressed. However, the PR mixes a focused bug fix with extensive refactoring across 72 files (type safety improvements, test refactoring, and code cleanup in unrelated extensions), which is poor commit hygiene but doesn't introduce functional issues. The score reflects confidence in the correctness of the changes, with a -1 penalty for scope creep and mixing unrelated changes.Last reviewed commit: 09637cb