Return Source Documents in LECL
Labels: name: area: vector store, name: auto:question, name: integration: pinecone

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

The chain is defined as:
```python
retriever_chain = create_retriever_chain(llm, retriever, use_chat_history)

_get_k_or_less_documents = partial(get_k_or_less_documents, k=k)

context = (
    RunnableMap(
        {
            "question": lambda x: x["question"],
            "memory": memory.load_memory_variables,
        }
    )
    | RunnableMap(
    {
        "context": (
            retriever_chain
            | _get_k_or_less_documents
            | reorder_documents
            | format_docs
        ),
        "question": lambda x: x["question"],
        "chat_history": lambda x: x["memory"]["chat_history"],
    }
)
)

prompt = ChatPromptTemplate.from_messages(
    messages=[
        ("system", SYSTEM_ANSWER_QUESTION_TEMPLATE),
        MessagesPlaceholder(variable_name="chat_history"),
        ("human", "{question}"),
    ]
)

response_synthesizer = prompt | llm
response_chain = context | response_synthesizer
```


### Description

I am trying to get back source documents used for my RAG application. However, I cannot find any ways to retrieve the document. I am using `chain.astream` to stream through my chain. The relevant code and chains are given below.

```python
async def generate_response():
    input = {"question": data.message}

    response = ""
    async for token in chain.astream(input=input):
        yield token.content
        response += token.content
    memory.save_context(input, {"output": response})
```

The chain is defined as:
```python
retriever_chain = create_retriever_chain(llm, retriever, use_chat_history)

_get_k_or_less_documents = partial(get_k_or_less_documents, k=k)

context = (
    RunnableMap(
        {
            "question": lambda x: x["question"],
            "memory": memory.load_memory_variables,
        }
    )
    | RunnableMap(
    {
        "context": (
            retriever_chain
            | _get_k_or_less_documents
            | reorder_documents
            | format_docs
        ),
        "question": lambda x: x["question"],
        "chat_history": lambda x: x["memory"]["chat_history"],
    }
)
)

prompt = ChatPromptTemplate.from_messages(
    messages=[
        ("system", SYSTEM_ANSWER_QUESTION_TEMPLATE),
        MessagesPlaceholder(variable_name="chat_history"),
        ("human", "{question}"),
    ]
)

response_synthesizer = prompt | llm
response_chain = context | response_synthesizer
```

Any kind of help is highly appreciated.

### System Info

langchain                                0.1.0
langchain-community                      0.0.11
langchain-core                           0.1.9
langchain-openai                         0.0.2

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [X] Async