-
Notifications
You must be signed in to change notification settings - Fork 115
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
Parse https://ollama.com/library/ syntax #648
Conversation
Reviewer's Guide by SourceryThis pull request introduces support for parsing Ollama model URLs from the Class diagram showing model handling classesclassDiagram
class Model {
<<abstract>>
+String model
+String type
}
class Huggingface {
+String type
+__init__(model)
}
class Ollama {
+String type
+__init__(model)
+_local(args)
}
class OCI {
+String type
+__init__(model, conman)
}
class URL {
+String type
+__init__(model)
}
Model <|-- Huggingface
Model <|-- Ollama
Model <|-- OCI
Model <|-- URL
note for Model "Base class for all model types"
note for Ollama "Now supports ollama.com/library URLs"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
@swarajpande5 PTAL |
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.
Hey @ericcurtin - I've reviewed your changes - here's some feedback:
Overall Comments:
- Critical bug in rm_until_substring: The function returns only one character after the substring instead of the remainder of the string. Change
return string[index + len(substring)]
toreturn string[index + len(substring):]
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ramalama/common.py
Outdated
def rm_until_substring(string, substring): | ||
index = string.find(substring) | ||
if index != -1: | ||
return string[index + len(substring)] |
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.
issue (bug_risk): Bug: Function returns only one character after the substring instead of the entire remaining string
The array indexing should be removed to return the full remaining string: return string[index + len(substring):]
7fa046b
to
e0c3f04
Compare
e15ffdf
to
d100ba4
Compare
d100ba4
to
eed8984
Compare
66d084e
to
dda3e6f
Compare
This is ready @rhatdan @swarajpande5 |
model = model.removeprefix("huggingface://") | ||
model = model.removeprefix("hf://") | ||
model = model.removeprefix("hf.co/") | ||
model = rm_until_substring(model, "hf.co/") |
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.
Why are you dropping hugginface://?
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.
It's not dropped, at this point of the code, we have already verified/validated the start of the protocol is fine, so we do a more generic:
model = rm_until_substring(model, "://")
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.
Right thanks.
Just need tests.
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.
if model.startswith("huggingface://") or model.startswith("hf://") or model.startswith("hf.co/"):
Please add tests. |
dda3e6f
to
61a1994
Compare
61a1994
to
a660af9
Compare
Added test, also took the opportunity to change the test from tinyllama to smollm, has a much smaller pull size, will accelerate the test |
LGTM, Merge once test pass. |
People search for ollama models using the web ui, this change allows one to copy the url from the browser and for it to be compatible with ramalama run. Also pull smaller models "smollm" to accelerate the builds. Signed-off-by: Eric Curtin <[email protected]>
a660af9
to
60c8d1b
Compare
People search for ollama models using the web ui, this change allows one to copy the url from the browser and for it to be compatible with ramalama run.
Summary by Sourcery
New Features: