Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Add chat completion Example and simplify dependencies #576

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

zhuohan123
Copy link
Collaborator

@zhuohan123 zhuohan123 commented Jul 25, 2023

Fix #545 #537

Make fastchat an optional dependency giving the huge dependency list of fastchat and many complaints on installation.

Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Left minor comments.

Comment on lines 30 to 50
# Chat completion API
chat_completion = openai.ChatCompletion.create(
model=model,
messages=[{
"role": "system",
"content": "You are a helpful assistant."
}, {
"role": "user",
"content": "Who won the world series in 2020?"
}, {
"role":
"assistant",
"content":
"The Los Angeles Dodgers won the World Series in 2020."
}, {
"role": "user",
"content": "Where was it played?"
}])

print("Chat completion results:")
print(chat_completion)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick question: why don't we have this in a separate file (say openai_chat_client.py)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special reason at the beginning. Let me move it to another file then.

@@ -63,6 +67,9 @@ async def check_model(request) -> Optional[JSONResponse]:


async def get_gen_prompt(request) -> str:
assert _fastchat_available, (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: As this is user-facing error, I feel raising error is a bit more appropriate.

assert is used to ensure internal correctness, not to enforce correct usage nor to indicate that some unexpected event occurred. If an exception is desired in the latter cases, use a raise statement.

@zhuohan123 zhuohan123 merged commit 82ad323 into main Jul 26, 2023
2 checks passed
@zhuohan123 zhuohan123 deleted the fix-openai-server branch July 26, 2023 06:45
hongxiayang pushed a commit to hongxiayang/vllm that referenced this pull request Feb 13, 2024
sjchoi1 pushed a commit to casys-kaist-internal/vllm that referenced this pull request May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slow installation: install all versions of one package.
2 participants