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
cdddd3df
Commit
cdddd3df
authored
Nov 10, 2023
by
Jeffrey Morgan
Browse files
add `format` to example python client
parent
afa61bdf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
api/client.py
api/client.py
+3
-2
No files found.
api/client.py
View file @
cdddd3df
...
@@ -7,7 +7,7 @@ BASE_URL = os.environ.get('OLLAMA_HOST', 'http://localhost:11434')
...
@@ -7,7 +7,7 @@ BASE_URL = os.environ.get('OLLAMA_HOST', 'http://localhost:11434')
# Generate a response for a given prompt with a provided model. This is a streaming endpoint, so will be a series of responses.
# Generate a response for a given prompt with a provided model. This is a streaming endpoint, so will be a series of responses.
# The final response object will include statistics and additional data from the request. Use the callback function to override
# The final response object will include statistics and additional data from the request. Use the callback function to override
# the default handler.
# the default handler.
def
generate
(
model_name
,
prompt
,
system
=
None
,
template
=
None
,
context
=
None
,
options
=
None
,
callback
=
None
):
def
generate
(
model_name
,
prompt
,
system
=
None
,
template
=
None
,
format
=
""
,
context
=
None
,
options
=
None
,
callback
=
None
):
try
:
try
:
url
=
f
"
{
BASE_URL
}
/api/generate"
url
=
f
"
{
BASE_URL
}
/api/generate"
payload
=
{
payload
=
{
...
@@ -16,7 +16,8 @@ def generate(model_name, prompt, system=None, template=None, context=None, optio
...
@@ -16,7 +16,8 @@ def generate(model_name, prompt, system=None, template=None, context=None, optio
"system"
:
system
,
"system"
:
system
,
"template"
:
template
,
"template"
:
template
,
"context"
:
context
,
"context"
:
context
,
"options"
:
options
"options"
:
options
,
"format"
:
format
,
}
}
# Remove keys with None values
# Remove keys with None values
...
...
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