@@ -189,41 +189,24 @@ func findModelFile(absPath string) (string, error) {
189189 return modelPath , nil
190190}
191191
192- // findLoraAdapterFile finds a lora adapter file (.gguf) within a path.
193- // If the path is a regular file, it returns that file.
194- // If the path is a directory, it searches for .gguf files within it.
192+ // findLoraAdapterFile validates a lora adapter path.
193+ // The path must point to a regular file.
195194func findLoraAdapterFile (absPath string ) (string , error ) {
196195 stat , err := os .Lstat (absPath )
197196 if err != nil {
198197 return "" , err
199198 }
200- if stat .Mode ().IsRegular () {
201- // lora adapter path refers to a regular file; assume it's fine to use
202- return absPath , nil
203- } else if ! stat .IsDir () {
204- return "" , fmt .Errorf ("could not find lora adapter file in %s: path is not regular file or directory" , absPath )
199+
200+ if ! stat .Mode ().IsRegular () {
201+ return "" , fmt .Errorf ("lora adapter path %s is not a regular file" , absPath )
205202 }
206203
207- loraPath := ""
208- if err := filepath .WalkDir (absPath , func (path string , d fs.DirEntry , err error ) error {
209- if err != nil {
210- return err
211- }
212- if strings .HasSuffix (path , ".gguf" ) && d .Type ().IsRegular () {
213- if loraPath == "" {
214- loraPath = path
215- } else {
216- return fmt .Errorf ("multiple lora adapter files found: %s and %s" , loraPath , path )
217- }
218- }
219- return nil
220- }); err != nil {
221- return "" , fmt .Errorf ("error searching for lora adapter file in %s: %w" , absPath , err )
222- } else if loraPath == "" {
223- return "" , fmt .Errorf ("could not find lora adapter file in %s" , absPath )
204+ if ! strings .HasSuffix (strings .ToLower (absPath ), ".gguf" ) {
205+ return "" , fmt .Errorf ("lora adapter file must be a .gguf file: %s" , absPath )
224206 }
225- output .Debugf ("Found lora adapter path in directory %s at %s" , absPath , loraPath )
226- return loraPath , nil
207+
208+ output .Debugf ("Found lora adapter path at %s" , absPath )
209+ return absPath , nil
227210}
228211
229212// extractModelKitToCache extracts a ModelKit reference to a cache directory
@@ -275,3 +258,5 @@ func extractModelKitToCache(ctx context.Context, options *DevStartOptions) error
275258 output .Infof ("ModelKit extracted to %s" , extractDir )
276259 return nil
277260}
261+
262+ // AGENT_MODIFIED: Human review required before merge
0 commit comments