Skip to content

Commit 6f4ba6a

Browse files
author
Douglas Reid
committed
docs: add information on logging callback
1 parent bf0783f commit 6f4ba6a

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Initial support is offered for the following (with more to follow soon):
3535
- LLMs
3636
- An adapter is provided for Steamship's OpenAI integration (`steamship_langchain.llms.OpenAI`)
3737
- An adapter is provided for *caching* LLM calls, via Steamship's Key-Value store (`SteamshipCache`)
38+
- Callbacks
39+
- A callback that uses Python's `logging` module to record events is provided (`steamship_langchain.callbacks.LoggingCallbackHandler`). This can be used with `ship logs` to access verbose logs when deployed.
3840
- Document Loaders
3941
- An adapter for exporting Steamship Files as LangChain Documents is provided (`steamship_langchain.document_loaders.SteamshipLoader`)
4042
- Tools

docs/adapters/callbacks.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Callbacks
2+
=========
3+
4+
5+
======================
6+
LoggingCallbackHandler
7+
======================
8+
9+
When developing LangChain apps locally, it is often useful to turn on verbose logging
10+
to help debug behavior and performance. The ``LoggingCallbackHandler`` preserves this
11+
capability when deploying your app to Steamship.
12+
13+
To use the ``LoggingCallbackHandler``, set the global callback handler and set ``verbose=True`` in your chain::
14+
15+
from steamship_langchain.callbacks import LoggingCallbackHandler
16+
17+
langchain.set_handler(LoggingCallbackHandler())
18+
19+
...
20+
21+
chain = load_qa_with_sources_chain(llm, verbose=True)
22+
23+
24+
Then, to view the logs, retrieve them with ``ship logs``::
25+
26+
$ ship logs -w my-workspace | jq '.entries[].message'
27+
28+
"Finished chain."
29+
"Response data size 11315"
30+
"Finished chain."
31+
"Got workspace: my-workspace/..."
32+
"Entering new LLMChain chain..."
33+
"Prompt after formatting:\n\u001b[32;1m\u001b[1;3mGiven the following extracted parts ...
34+
"Entering new StuffDocumentsChain chain..."
35+

docs/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Have a look at our `Coverage Page <./getting_started/getting_started.html>`_ for
3434

3535
- `LLMs <./adapters/llms.html>`_
3636

37+
- `Callbacks <./adapters/callbacks.html>`_
38+
3739
- `Document Loaders <./adapters/document_loaders.html>`_
3840

3941
- `Chains <./adapters/chains.html>`_
@@ -53,6 +55,7 @@ Have a look at our `Coverage Page <./getting_started/getting_started.html>`_ for
5355

5456
./adapters/prompts.md
5557
./adapters/llms.rst
58+
./adapters/callbacks.rst
5659
./adapters/document_loaders.rst
5760
./adapters/chains.md
5861
./adapters/agents.md
@@ -75,6 +78,7 @@ Here are some of the common use cases supported by Steamship:
7578
:hidden:
7679

7780
./use_cases/chatgpt.ipynb
81+
./use_cases/question_answering.md
7882

7983

8084
Coverage and Roadmap

0 commit comments

Comments
 (0)