A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 12, 16:00 UTC
[Bugfix] Update Gradio OpenAI Chatbot Webserver example to new Gradio message history format (#29249)
Signed-off-by: joshiemoore <joshiemoore98@gmail.com>
Josh Moore committed
Nov 23, 2025 at 19:47 UTC
c309bb5245b6d05228c9d2f9c8f3e769c08d9194
1 file changed
+6
-14
examples/online_serving/gradio_openai_chatbot_webserver.py
+6
-14
@@ -25,25 +25,17 @@ import gradio as gr
25
from openai import OpenAI
26
27
28
-def format_history_to_openai(history):
29
- history_openai_format = [
30
- {"role": "system", "content": "You are a great AI assistant."}
31
- ]
32
- for human, assistant in history:
33
- history_openai_format.append({"role": "user", "content": human})
34
- history_openai_format.append({"role": "assistant", "content": assistant})
35
- return history_openai_format
36
-
37
-
28
def predict(message, history, client, model_name, temp, stop_token_ids):
39
- # Format history to OpenAI chat format
40
- history_openai_format = format_history_to_openai(history)
41
- history_openai_format.append({"role": "user", "content": message})
29
+ messages = [
30
+ {"role": "system", "content": "You are a great AI assistant."},
31
+ *history,
32
+ {"role": "user", "content": message},
33
+ ]
34
35
# Send request to OpenAI API (vLLM server)
36
stream = client.chat.completions.create(
37
model=model_name,
46
- messages=history_openai_format,
38
+ messages=messages,
39
temperature=temp,
40
stream=True,
41
extra_body={