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
OpenDAS
ollama
Commits
972e91ef
"src/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "2234877e01c2824dd2a5ea37e1f6c8cc1d34664e"
Commit
972e91ef
authored
Jun 28, 2023
by
Michael Yang
Browse files
update generate to yield object
parent
77eddba5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
ollama/cmd/cli.py
ollama/cmd/cli.py
+0
-2
ollama/cmd/server.py
ollama/cmd/server.py
+4
-2
ollama/engine.py
ollama/engine.py
+1
-1
No files found.
ollama/cmd/cli.py
View file @
972e91ef
import
os
import
os
import
sys
import
sys
import
json
from
pathlib
import
Path
from
pathlib
import
Path
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
...
@@ -67,7 +66,6 @@ def generate_oneshot(*args, **kwargs):
...
@@ -67,7 +66,6 @@ def generate_oneshot(*args, **kwargs):
print
(
flush
=
True
)
print
(
flush
=
True
)
for
output
in
engine
.
generate
(
*
args
,
**
kwargs
):
for
output
in
engine
.
generate
(
*
args
,
**
kwargs
):
output
=
json
.
loads
(
output
)
choices
=
output
.
get
(
"choices"
,
[])
choices
=
output
.
get
(
"choices"
,
[])
if
len
(
choices
)
>
0
:
if
len
(
choices
)
>
0
:
print
(
choices
[
0
].
get
(
"text"
,
""
),
end
=
""
,
flush
=
True
)
print
(
choices
[
0
].
get
(
"text"
,
""
),
end
=
""
,
flush
=
True
)
...
...
ollama/cmd/server.py
View file @
972e91ef
from
aiohttp
import
web
import
json
import
aiohttp_cors
import
aiohttp_cors
from
aiohttp
import
web
from
ollama
import
engine
from
ollama
import
engine
...
@@ -89,7 +90,8 @@ async def generate(request):
...
@@ -89,7 +90,8 @@ async def generate(request):
}
}
for
output
in
engine
.
generate
(
model
,
prompt
,
**
kwargs
):
for
output
in
engine
.
generate
(
model
,
prompt
,
**
kwargs
):
await
response
.
write
(
output
.
encode
(
"utf-8"
))
output
=
json
.
dumps
(
output
).
encode
(
'utf-8'
)
await
response
.
write
(
output
)
await
response
.
write
(
b
"
\n
"
)
await
response
.
write
(
b
"
\n
"
)
return
response
return
response
ollama/engine.py
View file @
972e91ef
...
@@ -33,7 +33,7 @@ def generate(model, prompt, models_home=".", llms={}, *args, **kwargs):
...
@@ -33,7 +33,7 @@ def generate(model, prompt, models_home=".", llms={}, *args, **kwargs):
kwargs
.
update
({
"stream"
:
True
})
kwargs
.
update
({
"stream"
:
True
})
for
output
in
llm
(
prompt
,
*
args
,
**
kwargs
):
for
output
in
llm
(
prompt
,
*
args
,
**
kwargs
):
yield
json
.
dumps
(
output
)
yield
output
def
load
(
model
,
models_home
=
"."
,
llms
=
{}):
def
load
(
model
,
models_home
=
"."
,
llms
=
{}):
...
...
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