diff --git a/README.md b/README.md index e2465f46c..241d9c7d4 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,34 @@ 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 (side-by-side battle UI) + +Currently, Chatbot Arena is powered by FastChat. Here is how you can launch an instance of Chatbot Arena locally. + +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. + +Create a JSON configuration file `api_endpoint.json` with the api endpoints of the models you want to serve, for example: +``` +{ + "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 + } +} +``` +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). + +To serve your own model using local gpus, follow the instructions in [Serving with Web GUI](#serving-with-web-gui). + +Now you're ready to launch the server: +``` +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. ``` diff --git a/fastchat/serve/gradio_block_arena_anony.py b/fastchat/serve/gradio_block_arena_anony.py index 80ee2aaca..625c69c44 100644 --- a/fastchat/serve/gradio_block_arena_anony.py +++ b/fastchat/serve/gradio_block_arena_anony.py @@ -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(): diff --git a/fastchat/serve/gradio_block_arena_named.py b/fastchat/serve/gradio_block_arena_named.py index 38fa2e9a5..2f7b39adb 100644 --- a/fastchat/serve/gradio_block_arena_named.py +++ b/fastchat/serve/gradio_block_arena_named.py @@ -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(): diff --git a/fastchat/serve/gradio_block_arena_vision.py b/fastchat/serve/gradio_block_arena_vision.py index 07f2d3a5b..b3d812220 100644 --- a/fastchat/serve/gradio_block_arena_vision.py +++ b/fastchat/serve/gradio_block_arena_vision.py @@ -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(): diff --git a/fastchat/serve/gradio_block_arena_vision_anony.py b/fastchat/serve/gradio_block_arena_vision_anony.py index 2dade176c..d4d4d484e 100644 --- a/fastchat/serve/gradio_block_arena_vision_anony.py +++ b/fastchat/serve/gradio_block_arena_vision_anony.py @@ -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(): diff --git a/fastchat/serve/gradio_block_arena_vision_named.py b/fastchat/serve/gradio_block_arena_vision_named.py index 3048ac935..7c653acf3 100644 --- a/fastchat/serve/gradio_block_arena_vision_named.py +++ b/fastchat/serve/gradio_block_arena_vision_named.py @@ -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(): diff --git a/fastchat/serve/gradio_web_server.py b/fastchat/serve/gradio_web_server.py index 98399e575..4f0521da0 100644 --- a/fastchat/serve/gradio_web_server.py +++ b/fastchat/serve/gradio_web_server.py @@ -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(