Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoin committed Aug 7, 2023
1 parent 45a2d54 commit a2d97ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
18 changes: 17 additions & 1 deletion examples/openai-server/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<!--
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

Goal: Make a text-generation server that is compatible with the [OpenAI API Reference](https://platform.openai.com/docs/api-reference/introduction) so it can plug-in readily with applications that use the interface.

## Install requirements
Expand Down Expand Up @@ -98,7 +114,7 @@ completion = openai.Completion.create(
model=model,
prompt="def fib():",
stream=stream,
max_tokenss=32)
max_tokens=32)

print("Completion results:")
if stream:
Expand Down
21 changes: 17 additions & 4 deletions examples/openai-server/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import openai


# Modify OpenAI's API values to use the DeepSparse API server.
openai.api_key = "EMPTY"
openai.api_base = "http://localhost:8000/v1"
Expand All @@ -13,10 +28,8 @@
# Completion API
stream = True
completion = openai.Completion.create(
model=model,
prompt="def fib():",
stream=stream,
max_tokenss=32)
model=model, prompt="def fib():", stream=stream, max_tokens=32
)

print("Completion results:")
if stream:
Expand Down

0 comments on commit a2d97ee

Please sign in to comment.