Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
orangecat
ollama
Commits
fabf2f34
"vscode:/vscode.git/clone" did not exist on "c58d5d1747e629d71b4aec48b5c6e0e122c95a0f"
Unverified
Commit
fabf2f34
authored
Dec 21, 2023
by
Bruce MacDonald
Committed by
GitHub
Dec 21, 2023
Browse files
allow for starting llava queries with filepath (#1549)
parent
a607d922
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
cmd/cmd.go
cmd/cmd.go
+24
-5
No files found.
cmd/cmd.go
View file @
fabf2f34
...
...
@@ -928,8 +928,23 @@ func generateInteractive(cmd *cobra.Command, opts generateOptions) error {
return
nil
case
strings
.
HasPrefix
(
line
,
"/"
)
:
args
:=
strings
.
Fields
(
line
)
fmt
.
Printf
(
"Unknown command '%s'. Type /? for help
\n
"
,
args
[
0
])
continue
isFile
:=
false
if
multiModal
{
for
_
,
f
:=
range
extractFileNames
(
line
)
{
if
strings
.
HasPrefix
(
f
,
args
[
0
])
{
isFile
=
true
break
}
}
}
if
isFile
{
prompt
+=
line
}
else
{
fmt
.
Printf
(
"Unknown command '%s'. Type /? for help
\n
"
,
args
[
0
])
continue
}
default
:
prompt
+=
line
}
...
...
@@ -937,7 +952,7 @@ func generateInteractive(cmd *cobra.Command, opts generateOptions) error {
if
len
(
prompt
)
>
0
&&
multiline
==
MultilineNone
{
opts
.
Prompt
=
prompt
if
multiModal
{
newPrompt
,
images
,
err
:=
extractFile
Names
(
prompt
)
newPrompt
,
images
,
err
:=
extractFile
Data
(
prompt
)
if
err
!=
nil
{
return
err
}
...
...
@@ -991,13 +1006,17 @@ func normalizeFilePath(fp string) string {
return
fp
}
func
extractFileNames
(
input
string
)
(
string
,
[]
ImageData
,
error
)
{
func
extractFileNames
(
input
string
)
[]
string
{
// Regex to match file paths starting with / or ./ and include escaped spaces (\ or %20)
// and followed by more characters and a file extension
regexPattern
:=
`(?:\./|/)[\S\\ ]+?\.(?i:jpg|jpeg|png|svg)\b`
re
:=
regexp
.
MustCompile
(
regexPattern
)
filePaths
:=
re
.
FindAllString
(
input
,
-
1
)
return
re
.
FindAllString
(
input
,
-
1
)
}
func
extractFileData
(
input
string
)
(
string
,
[]
ImageData
,
error
)
{
filePaths
:=
extractFileNames
(
input
)
var
imgs
[]
ImageData
for
_
,
fp
:=
range
filePaths
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment