Skip to content

Commit a5fda63

Browse files
Add Chatbot Arena Web Server Documentation and Fix Latex Display (#3615)
Co-authored-by: Wei-Lin Chiang <[email protected]>
1 parent 5ac9372 commit a5fda63

File tree

7 files changed

+64
-0
lines changed

7 files changed

+64
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,34 @@ This is the user interface that users will interact with.
237237
By following these steps, you will be able to serve your models using the web UI. You can open your browser and chat with a model now.
238238
If the models do not show up, try to reboot the gradio web server.
239239

240+
## Launch Chatbot Arena (side-by-side battle UI)
241+
242+
Currently, Chatbot Arena is powered by FastChat. Here is how you can launch an instance of Chatbot Arena locally.
243+
244+
FastChat supports popular API-based models such as OpenAI, Anthropic, Gemini, Mistral and more. To add a custom API, please refer to the model support [doc](./docs/model_support.md). Below we take OpenAI models as an example.
245+
246+
Create a JSON configuration file `api_endpoint.json` with the api endpoints of the models you want to serve, for example:
247+
```
248+
{
249+
"gpt-4o-2024-05-13": {
250+
"model_name": "gpt-4o-2024-05-13",
251+
"api_base": "https://api.openai.com/v1",
252+
"api_type": "openai",
253+
"api_key": [Insert API Key],
254+
"anony_only": false
255+
}
256+
}
257+
```
258+
For Anthropic models, specify `"api_type": "anthropic_message"` with your Anthropic key. Similarly, for gemini model, specify `"api_type": "gemini"`. More details can be found in [api_provider.py](https://github.com/lm-sys/FastChat/blob/main/fastchat/serve/api_provider.py).
259+
260+
To serve your own model using local gpus, follow the instructions in [Serving with Web GUI](#serving-with-web-gui).
261+
262+
Now you're ready to launch the server:
263+
```
264+
cd fastchat/serve
265+
python gradio_web_server_multi.py --port 8080 --share --register-api-endpoint-file api_endpoint.json
266+
```
267+
240268
#### (Optional): Advanced Features, Scalability, Third Party UI
241269
- You can register multiple model workers to a single controller, which can be used for serving a single model with higher throughput or serving multiple models at the same time. When doing so, please allocate different GPUs and ports for different model workers.
242270
```

fastchat/serve/gradio_block_arena_anony.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ def build_side_by_side_ui_anony(models):
480480
elem_id="chatbot",
481481
height=650,
482482
show_copy_button=True,
483+
latex_delimiters=[
484+
{"left": "$", "right": "$", "display": False},
485+
{"left": "$$", "right": "$$", "display": True},
486+
{"left": r"\(", "right": r"\)", "display": False},
487+
{"left": r"\[", "right": r"\]", "display": True},
488+
],
483489
)
484490

485491
with gr.Row():

fastchat/serve/gradio_block_arena_named.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ def build_side_by_side_ui_named(models):
358358
elem_id=f"chatbot",
359359
height=650,
360360
show_copy_button=True,
361+
latex_delimiters=[
362+
{"left": "$", "right": "$", "display": False},
363+
{"left": "$$", "right": "$$", "display": True},
364+
{"left": r"\(", "right": r"\)", "display": False},
365+
{"left": r"\[", "right": r"\]", "display": True},
366+
],
361367
)
362368

363369
with gr.Row():

fastchat/serve/gradio_block_arena_vision.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ def build_single_vision_language_model_ui(
356356
label="Scroll down and start chatting",
357357
height=650,
358358
show_copy_button=True,
359+
latex_delimiters=[
360+
{"left": "$", "right": "$", "display": False},
361+
{"left": "$$", "right": "$$", "display": True},
362+
{"left": r"\(", "right": r"\)", "display": False},
363+
{"left": r"\[", "right": r"\]", "display": True},
364+
],
359365
)
360366

361367
with gr.Row():

fastchat/serve/gradio_block_arena_vision_anony.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ def build_side_by_side_vision_ui_anony(context: Context, random_questions=None):
432432
elem_id="chatbot",
433433
height=650,
434434
show_copy_button=True,
435+
latex_delimiters=[
436+
{"left": "$", "right": "$", "display": False},
437+
{"left": "$$", "right": "$$", "display": True},
438+
{"left": r"\(", "right": r"\)", "display": False},
439+
{"left": r"\[", "right": r"\]", "display": True},
440+
],
435441
)
436442

437443
with gr.Row():

fastchat/serve/gradio_block_arena_vision_named.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ def build_side_by_side_vision_ui_named(context: Context, random_questions=None):
372372
elem_id=f"chatbot",
373373
height=650,
374374
show_copy_button=True,
375+
latex_delimiters=[
376+
{"left": "$", "right": "$", "display": False},
377+
{"left": "$$", "right": "$$", "display": True},
378+
{"left": r"\(", "right": r"\)", "display": False},
379+
{"left": r"\[", "right": r"\]", "display": True},
380+
],
375381
)
376382

377383
with gr.Row():

fastchat/serve/gradio_web_server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,12 @@ def build_single_model_ui(models, add_promotion_links=False):
873873
label="Scroll down and start chatting",
874874
height=650,
875875
show_copy_button=True,
876+
latex_delimiters=[
877+
{"left": "$", "right": "$", "display": False},
878+
{"left": "$$", "right": "$$", "display": True},
879+
{"left": r"\(", "right": r"\)", "display": False},
880+
{"left": r"\[", "right": r"\]", "display": True},
881+
],
876882
)
877883
with gr.Row():
878884
textbox = gr.Textbox(

0 commit comments

Comments
 (0)