Repository: gradio-app/gradio

Issue:
Returning a dict from a function doesn't work as expected when the dict only has one key
### Describe the bug

When you return a dictionary from a function, the component may not be updated as expected if the dictionary has one key.

This is because the dict will get converted into a tuple of lists as opposed to a list with one element.

The following code handles dict outputs and you can see that it converts the predictions into a list

```python
        if type(predictions) is dict and len(predictions) > 0:
            keys_are_blocks = [isinstance(key, Block) for key in predictions.keys()]
            if all(keys_are_blocks):
                reordered_predictions = [skip() for _ in dependency["outputs"]]
                for component, value in predictions.items():
                    if component._id not in dependency["outputs"]:
                        return ValueError(
                            f"Returned component {component} not specified as output of function."
                        )
                    output_index = dependency["outputs"].index(component._id)
                    reordered_predictions[output_index] = value
                predictions = reordered_predictions
```
Then we convert that to a tuple:

```python
        if len(dependency["outputs"]) == 1:
            predictions = (predictions,)
```





### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

```python
import gradio as gr
import random
import string

with gr.Blocks() as demo:
    num = gr.Number()
    text = gr.Textbox()
    update = gr.Button(value="update")

    def update_values():
        return {text: random.choice(string.ascii_lowercase)}

    update.click(update_values, inputs=None, outputs=[text])

demo.launch()
```    



### Screenshot

You can see that the text displays `['v']` as opposed to just the character "v"

![image](https://user-images.githubusercontent.com/41651716/188704048-26d1a4d9-40f3-418e-b95f-25181b73f249.png)


### Logs

```shell
-
```


### System Info

```shell
3.2
```


### Severity

annoying


Discussion:

Resolving patch:
diff --git a/gradio/blocks.py b/gradio/blocks.py
--- a/gradio/blocks.py
+++ b/gradio/blocks.py
@@ -671,7 +671,7 @@ def postprocess_data(self, fn_index, predictions, state):
                         )
                     output_index = dependency["outputs"].index(component._id)
                     reordered_predictions[output_index] = value
-                predictions = reordered_predictions
+                predictions = utils.resolve_singleton(reordered_predictions)
             elif any(keys_are_blocks):
                 raise ValueError(
                     "Returned dictionary included some keys as Components. Either all keys must be Components to assign Component values, or return a List of values to assign output values in order."


Test patch:
diff --git a/test/test_blocks.py b/test/test_blocks.py
--- a/test/test_blocks.py
+++ b/test/test_blocks.py
@@ -279,6 +279,25 @@ def test_blocks_does_not_replace_keyword_literal():
     assert output[0]["value"] == "NO_VALUE"
 
 
+def test_blocks_returns_correct_output_dict_single_key():
+
+    with gr.Blocks() as demo:
+        num = gr.Number()
+        num2 = gr.Number()
+        update = gr.Button(value="update")
+
+        def update_values():
+            return {num2: gr.Number.update(value=42)}
+
+        update.click(update_values, inputs=[num], outputs=[num2])
+
+    output = demo.postprocess_data(0, {num2: gr.Number.update(value=42)}, state=None)
+    assert output[0]["value"] == 42
+
+    output = demo.postprocess_data(0, {num2: 23}, state=None)
+    assert output[0] == 23
+
+
 class TestCallFunction:
     @pytest.mark.asyncio
     async def test_call_regular_function(self):