Update openai.py
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c826317ed7c23..57f3151b9b54c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 ### Bug Fixes / Nits
 - Fix elasticsearch hybrid scoring (#7852)
 - Replace `get_color_mapping` and `print_text` Langchain dependency with internal implementation (#7845)
+- Fix async streaming with azure (#7856)
 - Avoid `NotImplementedError()` in sub question generator (#7855)
 
 ## [0.8.35] - 2023-09-27
diff --git a/llama_index/llms/openai.py b/llama_index/llms/openai.py
index 35e088fbf264b..1545866378458 100644
--- a/llama_index/llms/openai.py
+++ b/llama_index/llms/openai.py
@@ -457,6 +457,9 @@ async def gen() -> ChatResponseAsyncGen:
                 stream=True,
                 **all_kwargs,
             ):
+                if len(response["choices"]) == 0 and response.get("prompt_annotations"):
+                    # open ai sends empty response first while streaming ignore it
+                    continue
                 if len(response["choices"]) > 0:
                     delta = response["choices"][0]["delta"]
                 else:
@@ -474,7 +477,10 @@ async def gen() -> ChatResponseAsyncGen:
                         if function_call.get("function_name", "") is None:
                             del function_call["function_name"]
                     else:
-                        function_call["arguments"] += function_call_delta["arguments"]
+                        function_call["arguments"] = (
+                            function_call.get("arguments", "")
+                            + function_call_delta["arguments"]
+                        )
 
                 additional_kwargs = {}
                 if function_call is not None:

Fixed bug in astream_chat

# Description

Azure openai api when used in astream_chat mode with query engine tools returns error : 
  `query_engine_tools = [
    QueryEngineTool(
        query_engine=vector_engine,
        metadata=ToolMetadata(
            name="ask_vector_engine", description="Tool to query vector db to get questions answered from related files , good to fetch detail if specific"
        ),
    ),
    QueryEngineTool(
        query_engine=graph_query_engine,
        metadata=ToolMetadata(
            name="ask_knowledge_index", description="Tool to query knowledge graph index , use this tool to fetch relations and then use vector engine to detail the answer ,use recursively until statisfied"
        ),
    ),
]
agent= OpenAIAgent.from_tools(query_engine_tools, verbose=True,llm=AZURE_LLM)
response = await agent2.astream_chat(
      "hi what is the pdf's about ?"
  )

response_gen = response.response_gen


async for token in response.async_response_gen():
    print(token, end="")

`
The error was 
`
WARNING:llama_index.chat_engine.types:Encountered exception writing response to history: 'arguments'

`

Fixes # (issue)

## Type of Change

Please delete options that are not relevant.

- [ ☑] Bug fix (non-breaking change which fixes an issue)


# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ☑] I stared at the code and made sure it makes sense

# Suggested Checklist:

- [ ☑] I have performed a self-review of my own code
- [ ☑] I have commented my code, particularly in hard-to-understand areas

