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

Add Chatbot Arena Web Server Documentation and Fix Latex Display #3615

Merged
merged 13 commits into from
Nov 14, 2024
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,32 @@ This is the user interface that users will interact with.
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.
If the models do not show up, try to reboot the gradio web server.

## Launch Chatbot Arena
CodingWithTim marked this conversation as resolved.
Show resolved Hide resolved

Currently, Chatbot Arena is powered by FastChat. Here is how you can launch an instance of Chatbot Arena locally.

Create a file `api_endpoint.json` and record the the api endpoints of the models you want to serve, for example:
CodingWithTim marked this conversation as resolved.
Show resolved Hide resolved
```
{
"gpt-4o-2024-05-13": {
"model_name": "gpt-4o-2024-05-13",
"api_base": "https://api.openai.com/v1",
"api_type": "openai",
"api_key": [Insert API Key],
"anony_only": false
}
}
```
Then make sure to export `OPENAI_API_KEY` with your openai key. For anthropic model, set `api_type` to `"anthropic_message"` and export `ANTHROPIC_API_KEY` with your anthropic key. For gemini model, set `api_type` to `"gemini"` and export `GEMINI_API_KEY` with your gemini key. For additional information, you can refer to `fastchat/serve/api_provider.py` for implementation details of other model types.
CodingWithTim marked this conversation as resolved.
Show resolved Hide resolved

If you want to serve your own model using local gpus, following the instructions in [Serving with Web GUI](#serving-with-web-gui).
CodingWithTim marked this conversation as resolved.
Show resolved Hide resolved

To launch a gradio web server, run `gradio_web_server_multi.py`.
CodingWithTim marked this conversation as resolved.
Show resolved Hide resolved
```
cd fastchat/serve
python gradio_web_server_multi.py --port 8080 --share --register-api-endpoint-file api_endpoint.json
```

#### (Optional): Advanced Features, Scalability, Third Party UI
- 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.
```
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_block_arena_anony.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,12 @@ def build_side_by_side_ui_anony(models):
elem_id="chatbot",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)

with gr.Row():
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_block_arena_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ def build_side_by_side_ui_named(models):
elem_id=f"chatbot",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)

with gr.Row():
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_block_arena_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ def build_single_vision_language_model_ui(
label="Scroll down and start chatting",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)

with gr.Row():
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_block_arena_vision_anony.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ def build_side_by_side_vision_ui_anony(context: Context, random_questions=None):
elem_id="chatbot",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)

with gr.Row():
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_block_arena_vision_named.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ def build_side_by_side_vision_ui_named(context: Context, random_questions=None):
elem_id=f"chatbot",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)

with gr.Row():
Expand Down
6 changes: 6 additions & 0 deletions fastchat/serve/gradio_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,12 @@ def build_single_model_ui(models, add_promotion_links=False):
label="Scroll down and start chatting",
height=650,
show_copy_button=True,
latex_delimiters=[
{"left": "$", "right": "$", "display": False},
{"left": "$$", "right": "$$", "display": True},
{"left": r"\(", "right": r"\)", "display": False},
{"left": r"\[", "right": r"\]", "display": True},
],
)
with gr.Row():
textbox = gr.Textbox(
Expand Down
Loading