Skip to content

Commit

Permalink
Add docs for additional_outputs in gr.ChatInterface (#10130)
Browse files Browse the repository at this point in the history
* changes

* change
  • Loading branch information
abidlabs authored Dec 5, 2024
1 parent 4984e84 commit 3a6151e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions guides/05_chatbots/01_creating-a-chatbot-fast.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ You can also add example values for your additional inputs. Pass in a list of li

If you need to create something even more custom, then its best to construct the chatbot UI using the low-level `gr.Blocks()` API. We have [a dedicated guide for that here](/guides/creating-a-custom-chatbot-with-blocks).

## Additional Outputs

In the same way that you can accept additional inputs into your chat function, you can also return additional outputs. Simply pass in a list of components to the `additional_outputs` parameter in `gr.ChatInterface` and return additional values for each component from your chat function. Here's an example that extracts code and outputs it into a separate `gr.Code` component:

$code_chatinterface_artifacts

**Note:** unlike the case of additional inputs, the components passed in `additional_outputs` must be already defined in your `gr.Blocks` context -- they are not rendered automatically. If you need to render them after your `gr.ChatInterface`, you can set `render=False` when they are first defined and then `.render()` them in the appropriate section of your `gr.Blocks()` as we do in the example above.

## Returning Complex Responses

We mentioned earlier that in the simplest case, your chat function should return a `str` response, which will be rendered as text in the chatbot. However, you can also return more complex responses as we discuss below:
Expand Down

0 comments on commit 3a6151e

Please sign in to comment.