-
Notifications
You must be signed in to change notification settings - Fork 101
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
base: main
Are you sure you want to change the base?
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
ramalama/cli.py
Outdated
if model.startswith("oci://") or model.startswith("docker://"): | ||
return OCI(model, args.engine) | ||
if model.startswith("http://") or model.startswith("https://") or model.startswith("file://"): | ||
elif ( |
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.
No elif needed. Just if.
ramalama/cli.py
Outdated
return URL(model) | ||
elif model.startswith("oci://") or model.startswith("docker://"): |
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.
ditto
ramalama/common.py
Outdated
@@ -243,3 +243,12 @@ def get_env_vars(): | |||
# env_vars[gpu_type] = str(gpu_num) | |||
|
|||
return env_vars | |||
|
|||
|
|||
def rm_until_substring(model, 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.
This should be a function in model.py part of the model class.
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.
+1 for the method.
break | ||
|
||
self.type = urlparse(model).scheme | ||
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.
this ramala/url.py could be in a separate patch. LGTM
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 only 30 lines of code we are changing here
return URL(model) | ||
elif model.startswith("oci://") or model.startswith("docker://"): | ||
return OCI(model, args.engine) |
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.
My question is for this one, can we have util.py this seems very useful as generic.
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'm not against more refactoring in future PRs. What part exactly would go to utils this whole function?
e0c3f04
to
e15ffdf
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. Signed-off-by: Eric Curtin <[email protected]>
e15ffdf
to
d100ba4
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: