Repository: truera/trulens
Issue: AssertionError using LangChain's ChatOpenAI with `streaming=true`
Root cause: Validation Gap

### Summary
Running the basic example but setting `streaming=true` with `ChatOpenAI` causes an `AssertionError` in langchain. 

Running:
```
langchain                     0.1.1
langchain-community           0.0.13
langchain-core                0.1.11
trulens-eval                  0.20.3
```


### Example:
```
llm = ChatOpenAI(streaming=True)
prompt_template = """
Answer the question based on the supplied context.
Context: {context}
Question: {question}
Your answer:
"""

retriever = vstore.as_retriever()
prompt = ChatPromptTemplate.from_template(prompt_template)

qa_chain = (
    {"context": retriever, "question": RunnablePassthrough()}
    | prompt
    | llm
    | StrOutputParser()
)

# Feedbacks
provider = Langchain(chain=llm)
context = App.select_context(qa_chain)

grounded = Groundedness(groundedness_provider=provider)
f_groundedness = (
    Feedback(grounded.groundedness_measure_with_cot_reasons, name="Groundedness (A to C)")
    .on(context.collect())
    .on_output()
    .aggregate(grounded.grounded_statements_aggregator)
) 

...

tru_recorder = TruChain(
        qa_chain,
        app_id=app,
        # feedbacks=[f_answer_relevance, f_context_relevance, f_groundedness],
        feedbacks=[f_answer_relevance, f_context_relevance, f_groundedness, f_ground_truth],
        # feedback_mode="deferred",
)

with tru_recorder as recorder:
    qa_chain.invoke("question")
```

Error:
```
Could not find usage information in openai response:
<openai.Stream object at 0x296220f90>

Traceback (most recent call last):
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/trulens_eval/instruments.py", line 735, in tru_wrapper
    rets, cost = Endpoint.track_all_costs_tally(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/trulens_eval/feedback/provider/endpoint/base.py", line 479, in track_all_costs_tally
    result, cbs = Endpoint.track_all_costs(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/trulens_eval/feedback/provider/endpoint/base.py", line 421, in track_all_costs
    return Endpoint._track_costs(thunk, with_endpoints=endpoints)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/trulens_eval/feedback/provider/endpoint/base.py", line 585, in _track_costs
    result: T = thunk()
                ^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/trulens_eval/instruments.py", line 736, in <lambda>
    lambda: func(*bindings.args, **bindings.kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 165, in invoke
    self.generate_prompt(
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 543, in generate_prompt
    return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 407, in generate
    raise e
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 397, in generate
    self._generate_with_cache(
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 576, in _generate_with_cache
    return self._generate(
           ^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_community/chat_models/openai.py", line 432, in _generate
    return generate_from_stream(stream_iter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jordan.frazier/Documents/testvenv/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py", line 69, in generate_from_stream
    assert generation is not None
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError
```


Hi; fixing some issues regarding async in this PR/branch: https://github.com/truera/trulens/pull/793. Does the issue appear with that version of trulens_eval?



hi @piotrm0, tried it out on that branch and the assertion error is gone! I'm able to retrieve feedback results as expected. Thank you for the quick fix!

Hi @piotrm0 just wanted to check in on that PR -- is there anything I can do on my end to help with getting reviewed? 

edit: saw it merged! Thanks.