-
Notifications
You must be signed in to change notification settings - Fork 445
Refactor model examples #1439
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
base: master
Are you sure you want to change the base?
Refactor model examples #1439
Conversation
WalkthroughThis update standardizes and modernizes vision model example usage across documentation and code. It removes numerous model-specific example scripts in Python and Rust, replacing them with a single, configurable Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI Example (vision_chat.py/.rs)
participant Model Runner (Python/Rust)
participant Model
User->>CLI Example: Run with --model-id, --arch, --image-url
CLI Example->>Model Runner: Initialize with model-id, arch
CLI Example->>Model Runner: Send chat completion request (with image)
Model Runner->>Model: Process request
Model-->>Model Runner: Generate response
Model Runner-->>CLI Example: Return response
CLI Example-->>User: Print response content
Possibly related PRs
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Code Metrics Report=============================================================================== Language Files Lines Code Comments Blanks =============================================================================== C Header 3 62 53 0 9 CSS 1 473 408 14 51 Dockerfile 1 42 23 10 9 HTML 1 73 61 4 8 JavaScript 7 1248 936 174 138 JSON 14 123 122 0 1 Makefile 1 6 5 0 1 Python 87 4097 3457 161 479 Shell 1 63 26 18 19 Plain Text 3 3723 0 2413 1310 TOML 21 695 634 10 51 YAML 2 21 19 2 0 ------------------------------------------------------------------------------- Jupyter Notebooks 3 0 0 0 0 |- Markdown 2 77 32 31 14 |- Python 2 205 178 1 26 (Total) 282 210 32 40 ------------------------------------------------------------------------------- Markdown 60 5211 0 3984 1227 |- BASH 11 123 117 2 4 |- JSON 2 42 42 0 0 |- Python 7 121 109 0 12 |- Rust 22 757 634 1 122 |- TOML 2 75 63 0 12 (Total) 6329 965 3987 1377 ------------------------------------------------------------------------------- Rust 376 132481 117880 2913 11688 |- Markdown 175 3002 29 2662 311 (Total) 135483 117909 5575 11999 =============================================================================== Total 581 148318 123624 9703 14991 =============================================================================== |
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.
Actionable comments posted: 6
🔭 Outside diff range comments (1)
docs/LLAMA4.md (1)
184-184
:⚠️ Potential issueFix inconsistent model name in example.
The example shows
model="gemma3"
in the Llama 4 documentation, which appears to be a copy-paste error from another model's documentation.Apply this fix:
- model="gemma3", + model="llama4",
🧹 Nitpick comments (1)
docs/VISION_MODELS.md (1)
16-16
: Refine conjunction usage in note
The phrase “allow both base64 encoded images as well as a URL/path” is slightly redundant. Consider changing to “allow both base64 encoded images and a URL/path”.🧰 Tools
🪛 LanguageTool
[grammar] ~16-~16: Probable usage error. Use “and” after ‘both’.
Context: ...es and allow both base64 encoded images as well as a URL/path to the image. There are many...(BOTH_AS_WELL_AS)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (45)
docs/GEMMA3.md
(3 hunks)docs/IDEFICS2.md
(1 hunks)docs/LLAMA4.md
(3 hunks)docs/LLaVA.md
(3 hunks)docs/MISTRAL3.md
(3 hunks)docs/PHI3V.md
(3 hunks)docs/PHI4MM.md
(3 hunks)docs/QWEN2VL.md
(3 hunks)docs/VISION_MODELS.md
(1 hunks)docs/VLLAMA.md
(3 hunks)examples/python/deepseekr1.py
(0 hunks)examples/python/deepseekv2.py
(0 hunks)examples/python/gemma3.py
(0 hunks)examples/python/llama4.py
(0 hunks)examples/python/llama_vision.py
(0 hunks)examples/python/llava_next.py
(0 hunks)examples/python/mistral3.py
(0 hunks)examples/python/phi4mm.py
(0 hunks)examples/python/plain.py
(1 hunks)examples/python/qwen2vl.py
(0 hunks)examples/python/smolvlm.py
(0 hunks)examples/python/vision_chat.py
(1 hunks)examples/server/gemma3.py
(0 hunks)examples/server/llama4.py
(0 hunks)examples/server/llama_vision.py
(0 hunks)examples/server/llava.py
(0 hunks)examples/server/llava_next.py
(0 hunks)examples/server/mistral3.py
(0 hunks)examples/server/phi4mm.py
(0 hunks)examples/server/qwen2vl.py
(0 hunks)examples/server/vision_chat.py
(3 hunks)mistralrs/examples/deepseekr1/main.rs
(0 hunks)mistralrs/examples/deepseekv2/main.rs
(0 hunks)mistralrs/examples/gemma2/main.rs
(0 hunks)mistralrs/examples/gemma3/main.rs
(0 hunks)mistralrs/examples/llama4/main.rs
(0 hunks)mistralrs/examples/llama_vision/main.rs
(0 hunks)mistralrs/examples/llava_next/main.rs
(0 hunks)mistralrs/examples/mistral3/main.rs
(0 hunks)mistralrs/examples/phi3v/main.rs
(0 hunks)mistralrs/examples/phi4mm/main.rs
(0 hunks)mistralrs/examples/qwen2vl/main.rs
(0 hunks)mistralrs/examples/simple/main.rs
(1 hunks)mistralrs/examples/smolvlm/main.rs
(0 hunks)mistralrs/examples/vision_chat/main.rs
(1 hunks)
💤 Files with no reviewable changes (30)
- examples/python/deepseekr1.py
- examples/python/mistral3.py
- mistralrs/examples/qwen2vl/main.rs
- examples/python/deepseekv2.py
- mistralrs/examples/llama4/main.rs
- mistralrs/examples/gemma3/main.rs
- mistralrs/examples/gemma2/main.rs
- examples/server/llava_next.py
- mistralrs/examples/llama_vision/main.rs
- examples/server/qwen2vl.py
- mistralrs/examples/llava_next/main.rs
- examples/python/gemma3.py
- examples/python/llava_next.py
- mistralrs/examples/smolvlm/main.rs
- examples/server/mistral3.py
- examples/python/smolvlm.py
- mistralrs/examples/mistral3/main.rs
- examples/server/phi4mm.py
- examples/server/llama4.py
- examples/python/llama4.py
- examples/python/llama_vision.py
- examples/python/qwen2vl.py
- examples/server/gemma3.py
- examples/server/llava.py
- mistralrs/examples/phi4mm/main.rs
- mistralrs/examples/deepseekv2/main.rs
- examples/server/llama_vision.py
- examples/python/phi4mm.py
- mistralrs/examples/deepseekr1/main.rs
- mistralrs/examples/phi3v/main.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
examples/python/plain.py (1)
mistralrs-pyo3/src/lib.rs (1)
mistralrs
(1499-1530)
🪛 LanguageTool
docs/VISION_MODELS.md
[grammar] ~16-~16: Probable usage error. Use “and” after ‘both’.
Context: ...es and allow both base64 encoded images as well as a URL/path to the image. There are many...
(BOTH_AS_WELL_AS)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Clippy
- GitHub Check: Check (windows-latest, stable)
- GitHub Check: Check (macOS-latest, stable)
- GitHub Check: Docs
- GitHub Check: Check (ubuntu-latest, stable)
- GitHub Check: Test Suite (ubuntu-latest, stable)
- GitHub Check: Test Suite (macOS-latest, stable)
- GitHub Check: Test Suite (windows-latest, stable)
🔇 Additional comments (21)
docs/IDEFICS2.md (1)
140-140
: Update Python example link
The documentation now correctly references the consolidatedvision_chat.py
script for Python examples. Ensure the relative path (../examples/python/vision_chat.py
) resolves properly from this doc location.docs/QWEN2VL.md (3)
61-61
: Update HTTP server example link
The HTTP server section now points tovision_chat.py
instead of the oldqwen2vl.py
—this aligns with the unified example approach. Verify the path (../examples/server/vision_chat.py
) is correct.
139-139
: Update Rust example link
The Rust section link has been updated tovision_chat/main.rs
for consistency across model docs. Confirm that../mistralrs/examples/vision_chat/main.rs
exists and is accurate.
187-187
: Update Python example link
The Python section now references the genericvision_chat.py
. Please check that../examples/python/vision_chat.py
is reachable from this markdown.docs/GEMMA3.md (3)
15-15
: Standardize HTTP server example link
Updated to point at the unifiedvision_chat.py
server example. Validate../examples/server/vision_chat.py
is correct.
100-100
: Standardize Rust example link
The Rust example link now goes tovision_chat/main.rs
. Ensure../mistralrs/examples/vision_chat/main.rs
exists.
145-145
: Standardize Python example link
The Python section referencesvision_chat.py
instead of the oldgemma3.py
. Confirm the path (../examples/python/vision_chat.py
).docs/PHI3V.md (3)
22-22
: Standardize HTTP server example link
Now directs to the consolidatedvision_chat.py
. Verify../examples/server/vision_chat.py
is accurate.
99-99
: Standardize Rust example link
The Rust section link has been updated tovision_chat/main.rs
. Please check../mistralrs/examples/vision_chat/main.rs
.
143-143
: Standardize Python example link
Updated to use the unifiedvision_chat.py
for Python. Confirm../examples/python/vision_chat.py
resolves correctly.docs/VLLAMA.md (1)
68-68
: Documentation links updated correctly for unified examples.The documentation links have been properly updated to point to the new consolidated
vision_chat
examples, which aligns with the PR objectives of standardizing example structure across different models.Also applies to: 155-155, 201-201
docs/MISTRAL3.md (1)
25-25
: Documentation links consistently updated.The example links have been properly updated to reference the unified
vision_chat
examples, maintaining consistency with the refactoring effort.Also applies to: 110-110, 155-155
docs/PHI4MM.md (1)
22-22
: Example links updated to reflect unified structure.The documentation correctly points to the new
vision_chat
examples, maintaining consistency across all model documentation files.Also applies to: 97-97, 142-142
docs/LLAMA4.md (1)
27-27
: Documentation links updated correctly.The example links have been properly updated to reference the unified
vision_chat
examples.Also applies to: 119-119, 165-165
examples/server/vision_chat.py (2)
1-1
: Excellent addition of CLI argument parsing.The addition of argparse with model and image URL parameters successfully achieves the PR objective of enabling model selection through CLI arguments. The default image URL provides a good fallback.
Also applies to: 32-38
46-46
: Dynamic model and image URL configuration implemented correctly.The use of parsed arguments for model and image URL makes this script flexible and reusable across different vision models.
Also applies to: 51-51
docs/LLaVA.md (1)
27-27
: Documentation links updated correctly for unified example structure.The path updates from
llava_next
tovision_chat
correctly reflect the consolidation of model-specific examples into a unified structure, which aligns with the PR objectives.Also applies to: 104-104, 149-149
mistralrs/examples/simple/main.rs (1)
8-12
: Excellent implementation of CLI argument parsing.The addition of command-line argument parsing with a sensible default value maintains backwards compatibility while adding flexibility. The use of
clap::Parser
with derive macros is idiomatic and clean.Also applies to: 16-17
mistralrs/examples/vision_chat/main.rs (1)
5-14
: Well-designed CLI argument structure for vision chat example.The implementation correctly makes
model_id
required (since vision models have different capabilities) while providing a sensible default forimage_url
. The argument usage is consistent and the code remains clean and readable.Also applies to: 18-19, 25-25
examples/python/vision_chat.py (2)
22-22
: Model field assignment looks correct.Using
args.arch.lower()
for the model field is appropriate and follows the expected pattern for chat completion requests.
29-29
: Dynamic image URL assignment is well implemented.The use of the command-line argument for the image URL provides good flexibility while maintaining a sensible default value.
"url": "https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg" | ||
}, | ||
}, | ||
{"type": "image_url", "image_url": {"url": args.image_url}}, | ||
{ | ||
"type": "text", | ||
"text": "<|image_1|>\nWhat is shown in this image? Write a detailed response analyzing the scene.", |
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.
🛠️ Refactor suggestion
Consider making image token format configurable.
The hardcoded <|image_1|>
token format may not be compatible with all vision models. Some models use different image token formats or don't require explicit image tokens.
Consider adding an optional CLI argument for the image token format:
parser.add_argument(
"--image-url",
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg",
)
+parser.add_argument(
+ "--image-token",
+ default="<|image_1|>",
+ help="Image token format for the model (use empty string for no token)"
+)
Then update the text content:
{
"type": "text",
- "text": "<|image_1|>\nWhat is shown in this image? Write a detailed response analyzing the scene.",
+ "text": f"{args.image_token}\nWhat is shown in this image? Write a detailed response analyzing the scene." if args.image_token else "What is shown in this image? Write a detailed response analyzing the scene.",
},
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"text": "<|image_1|>\nWhat is shown in this image? Write a detailed response analyzing the scene.", | |
# --- around your existing parser setup --- | |
parser.add_argument( | |
"--image-url", | |
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg", | |
) | |
parser.add_argument( | |
"--image-token", | |
default="<|image_1|>", | |
help="Image token format for the model (use empty string for no token)" | |
) | |
# --- later, where you build the message payload --- | |
message = { | |
"type": "text", | |
"text": ( | |
f"{args.image_token}\nWhat is shown in this image? " | |
"Write a detailed response analyzing the scene." | |
) | |
if args.image_token | |
else "What is shown in this image? Write a detailed response analyzing the scene.", | |
} |
🤖 Prompt for AI Agents
In examples/server/vision_chat.py at line 54, the image token "<|image_1|>" is
hardcoded, which may not work with all vision models. Add an optional CLI
argument to specify the image token format, then replace the hardcoded token in
the text string with this configurable value to allow flexibility for different
models.
model_id="mistralai/Mistral-7B-Instruct-v0.1", | ||
arch=Architecture.Mistral, | ||
model_id=args.model_id, | ||
arch=Architecture[args.arch], |
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.
Potential KeyError with Architecture enum access.
Direct dictionary-style access to Architecture[args.arch]
will raise a KeyError
if an invalid architecture name is provided, causing the program to crash ungracefully.
🤖 Prompt for AI Agents
In examples/python/plain.py at line 12, the code uses Architecture[args.arch]
which can raise a KeyError if args.arch is not a valid key. To fix this, add
validation to check if args.arch is a valid member of the Architecture enum
before accessing it, or use a safer method like
Architecture.__members__.get(args.arch) and handle the case where it returns
None by providing an appropriate error message or fallback.
parser = argparse.ArgumentParser(description="Text model chat example") | ||
parser.add_argument("--model-id", required=True, help="HuggingFace model id") | ||
parser.add_argument("--arch", required=True, help="Architecture name") | ||
args = parser.parse_args() |
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.
🛠️ Refactor suggestion
Add error handling for invalid architecture names.
The script now requires CLI arguments without providing helpful error messages for invalid inputs. Consider adding validation to provide user-friendly feedback.
Add error handling to prevent KeyError
when an invalid architecture is provided:
+def get_architecture(arch_name):
+ try:
+ return Architecture[arch_name]
+ except KeyError:
+ available_archs = [attr for attr in dir(Architecture) if not attr.startswith('_')]
+ raise ValueError(f"Invalid architecture '{arch_name}'. Available architectures: {available_archs}")
+
runner = Runner(
which=Which.Plain(
model_id=args.model_id,
- arch=Architecture[args.arch],
+ arch=get_architecture(args.arch),
),
)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
parser = argparse.ArgumentParser(description="Text model chat example") | |
parser.add_argument("--model-id", required=True, help="HuggingFace model id") | |
parser.add_argument("--arch", required=True, help="Architecture name") | |
args = parser.parse_args() | |
def get_architecture(arch_name): | |
try: | |
return Architecture[arch_name] | |
except KeyError: | |
available_archs = [attr for attr in dir(Architecture) if not attr.startswith('_')] | |
raise ValueError(f"Invalid architecture '{arch_name}'. Available architectures: {available_archs}") | |
runner = Runner( | |
which=Which.Plain( | |
model_id=args.model_id, | |
arch=get_architecture(args.arch), | |
), | |
) |
🤖 Prompt for AI Agents
In examples/python/plain.py around lines 4 to 7, the code parses CLI arguments
for model ID and architecture but lacks validation for the architecture
argument. Add a validation step after parsing arguments to check if the provided
architecture name is valid (e.g., by comparing against a predefined list of
supported architectures). If the architecture is invalid, print a user-friendly
error message and exit the program gracefully to prevent a KeyError later in the
code.
), | ||
) | ||
|
||
res = runner.send_chat_completion_request( | ||
ChatCompletionRequest( | ||
model="mistral", | ||
model=args.arch.lower(), |
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.
💡 Verification agent
🧩 Analysis chain
Verify that lowercased architecture name is appropriate for model field.
The model field now uses args.arch.lower()
, but this assumes all architecture names should be lowercased for the model identifier. This may not be universally correct.
🏁 Script executed:
#!/bin/bash
# Check how model field is used across the codebase to verify naming conventions
rg -A 3 -B 3 "model.*=" examples/ mistralrs/ --type py --type rs
Length of output: 93
🏁 Script executed:
#!/bin/bash
# Display the first 200 lines of the example to inspect how `model` is constructed and used
sed -n '1,200p' examples/python/plain.py
Length of output: 880
🏁 Script executed:
#!/bin/bash
# Display the Architecture enum definition
rg -l "class Architecture" -t py | xargs sed -n '1,200p'
# Display the ChatCompletionRequest class definition
rg -l "class ChatCompletionRequest" -t py | xargs sed -n '1,200p'
Length of output: 122
Use the correct model identifier in ChatCompletionRequest
The model
field of ChatCompletionRequest
should receive the user-supplied model ID (args.model_id
), not the lowercased architecture name, which may not match any valid model.
• File: examples/python/plain.py, line 18
Suggested fix:
- model=args.arch.lower(),
+ model=args.model_id,
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
model=args.arch.lower(), | |
model=args.model_id, |
🤖 Prompt for AI Agents
In examples/python/plain.py at line 18, the model field is incorrectly set to
args.arch.lower(), which may not correspond to a valid model identifier. Replace
args.arch.lower() with args.model_id to ensure the ChatCompletionRequest
receives the correct user-supplied model ID.
model_id="microsoft/Phi-3.5-vision-instruct", | ||
arch=VisionArchitecture.Phi3V, | ||
model_id=args.model_id, | ||
arch=VisionArchitecture[args.arch], |
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.
Enum conversion is vulnerable to KeyError.
The direct enum access VisionArchitecture[args.arch]
will raise a KeyError if an invalid architecture name is provided, causing the script to crash ungracefully.
With the validation added in the previous comment, this line will be safe. Alternatively, you could add error handling:
- arch=VisionArchitecture[args.arch],
+ arch=getattr(VisionArchitecture, args.arch, None) or VisionArchitecture[args.arch],
However, the argparse validation approach is cleaner and provides better user experience.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In examples/python/vision_chat.py at line 16, the direct enum conversion using
VisionArchitecture[args.arch] can raise a KeyError if args.arch is invalid. To
fix this, ensure that args.arch is validated beforehand, ideally by adding
choices to the argparse argument definition for arch, so only valid enum names
are accepted. This prevents invalid values from reaching this line and avoids
runtime exceptions.
import argparse | ||
from mistralrs import Runner, Which, ChatCompletionRequest, VisionArchitecture | ||
|
||
parser = argparse.ArgumentParser(description="Vision model chat example") | ||
parser.add_argument("--model-id", required=True, help="HuggingFace model id") | ||
parser.add_argument("--arch", required=True, help="VisionArchitecture name") | ||
parser.add_argument( | ||
"--image-url", | ||
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg", | ||
) | ||
args = parser.parse_args() |
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.
🛠️ Refactor suggestion
Add input validation for the architecture argument.
The argument parser setup is well-structured, but there's no validation for the --arch
argument. This could lead to runtime errors if an invalid architecture name is provided.
Add validation to prevent runtime errors:
+import sys
+
parser = argparse.ArgumentParser(description="Vision model chat example")
parser.add_argument("--model-id", required=True, help="HuggingFace model id")
-parser.add_argument("--arch", required=True, help="VisionArchitecture name")
+parser.add_argument(
+ "--arch",
+ required=True,
+ choices=[arch.name for arch in VisionArchitecture],
+ help="VisionArchitecture name"
+)
parser.add_argument(
"--image-url",
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg",
)
args = parser.parse_args()
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import argparse | |
from mistralrs import Runner, Which, ChatCompletionRequest, VisionArchitecture | |
parser = argparse.ArgumentParser(description="Vision model chat example") | |
parser.add_argument("--model-id", required=True, help="HuggingFace model id") | |
parser.add_argument("--arch", required=True, help="VisionArchitecture name") | |
parser.add_argument( | |
"--image-url", | |
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg", | |
) | |
args = parser.parse_args() | |
import argparse | |
import sys | |
from mistralrs import Runner, Which, ChatCompletionRequest, VisionArchitecture | |
parser = argparse.ArgumentParser(description="Vision model chat example") | |
parser.add_argument("--model-id", required=True, help="HuggingFace model id") | |
parser.add_argument( | |
"--arch", | |
required=True, | |
choices=[arch.name for arch in VisionArchitecture], | |
help="VisionArchitecture name" | |
) | |
parser.add_argument( | |
"--image-url", | |
default="https://www.nhmagazine.com/content/uploads/2019/05/mtwashingtonFranconia-2-19-18-108-Edit-Edit.jpg", | |
) | |
args = parser.parse_args() |
🤖 Prompt for AI Agents
In examples/python/vision_chat.py around lines 1 to 11, the --arch argument
lacks validation, which may cause runtime errors if an invalid architecture name
is given. Fix this by adding a check after parsing arguments to verify that
args.arch matches one of the valid VisionArchitecture names. If the value is
invalid, print an error message and exit the program gracefully to prevent
further execution with an unsupported architecture.
Summary
Testing
cargo fmt --all
make fmt
timeout 60 cargo clippy --workspace --tests --examples -- -D warnings
(failed: timed out)timeout 60 cargo test -p mistralrs-core -p mistralrs-quant -p mistralrs-vision
(failed: timed out)https://chatgpt.com/codex/tasks/task_e_68425ab1e4fc832283388c438c1d9a64
Summary by CodeRabbit
Documentation
New Features
Refactor
Chores