Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks Refactor [base] #3256

Merged
merged 45 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3cc2ce6
callbacks changes
agola11 Apr 20, 2023
55c7964
Merge branch 'master' into ankush/callbacks-refactor
agola11 Apr 21, 2023
fa4a4f2
cr
agola11 Apr 21, 2023
675e27c
Callbacks Refactor [2/n]: refactor `CallbackManager` code to own file…
agola11 Apr 23, 2023
90cef7b
cr
agola11 Apr 23, 2023
4cdd19b
Callbacks Refactor [2/n] update tracer to work with new callbacks mec…
agola11 Apr 26, 2023
7bcdc66
fix notebook and warnings
agola11 Apr 26, 2023
6fec15b
write to different session
agola11 Apr 26, 2023
5066869
fix execution order issue
agola11 Apr 27, 2023
e953d2c
mypy
agola11 Apr 27, 2023
6cd653d
cr
agola11 Apr 27, 2023
8ae809a
mypy
agola11 Apr 28, 2023
1fc3941
mypy
agola11 Apr 28, 2023
15c0fa5
cr
agola11 Apr 28, 2023
5dcb44e
fix llm chain
agola11 Apr 28, 2023
da27d87
fix most tests
agola11 Apr 28, 2023
2ed4649
fix baby agi
agola11 Apr 28, 2023
0e81e83
Nc/callbacks docs (#3717)
nfcampos Apr 28, 2023
eb9de30
merge
agola11 Apr 28, 2023
1b48ea8
cr
agola11 Apr 28, 2023
18138c6
cr
agola11 Apr 28, 2023
50f6895
Chains callbacks refactor (#3683)
dev2049 Apr 28, 2023
eeb18c4
Merge branch 'master' of github.com:hwchase17/langchain into ankush/c…
agola11 Apr 28, 2023
40f3f6e
Merge branch 'ankush/callbacks-refactor' of github.com:hwchase17/lang…
agola11 Apr 28, 2023
83cda5e
lint
agola11 Apr 28, 2023
9c876bd
update chain notebooks (#3740)
dev2049 Apr 28, 2023
43410e4
fix test
agola11 Apr 28, 2023
145e1af
Merge branch 'ankush/callbacks-refactor' of github.com:hwchase17/lang…
agola11 Apr 28, 2023
56f16cd
Merge branch 'master' into ankush/callbacks-refactor
agola11 Apr 28, 2023
9c988ae
cr
agola11 Apr 28, 2023
bd9ac67
nb nit (#3744)
dev2049 Apr 28, 2023
e60489e
fix lint
agola11 Apr 28, 2023
3c5f983
Merge branch 'ankush/callbacks-refactor' of github.com:hwchase17/lang…
agola11 Apr 28, 2023
9dad051
fix test warnings (#3753)
dev2049 Apr 29, 2023
5f78219
fix some docs, add session variable
agola11 Apr 29, 2023
290fe75
Add RunManager to Tools Arguments (#3746)
vowelparrot Apr 29, 2023
20ba888
Call Manager for New Tools (#3755)
vowelparrot Apr 29, 2023
a038f37
Resolve merge conflicts
vowelparrot Apr 29, 2023
9192abc
Notebook Nits
vowelparrot Apr 29, 2023
35cc38f
merge
agola11 Apr 29, 2023
ebc6242
fix docs
agola11 Apr 29, 2023
737467a
use UUID
agola11 Apr 29, 2023
3839703
bw compat environ variable
agola11 Apr 29, 2023
fa1742c
fix openai callback
agola11 Apr 29, 2023
fb78f69
cr
hwchase17 Apr 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/ecosystem/gpt4all.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ To stream the model's predictions, add in a CallbackManager.

```python
from langchain.llms import GPT4All
from langchain.callbacks.base import CallbackManager
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

# There are many CallbackHandlers supported, such as
# from langchain.callbacks.streamlit import StreamlitCallbackHandler

callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
model = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8, callback_handler=callback_handler, verbose=True)
model = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8, callback_handler=callback_handler,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this line wrong anyway? In the previous line creating a callback_manager, then passing a callback_handler var (that I think doesn't exist) to a callback_handler arg that I also think doesn't exist

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, this was messed up by the pycharm refactoring tool

verbose=True)

# Generate text. Tokens are streamed through the callback manager.
model("Once upon a time, ")
Expand Down
13 changes: 4 additions & 9 deletions langchain/callbacks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@

from langchain.callbacks.aim_callback import AimCallbackHandler
from langchain.callbacks.base import (
AsyncCallbackManager,
BaseCallbackHandler,
BaseCallbackManager,
CallbackManager,
)
from langchain.callbacks.clearml_callback import ClearMLCallbackHandler
from langchain.callbacks.comet_ml_callback import CometCallbackHandler
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.openai_info import OpenAICallbackHandler
from langchain.callbacks.shared import SharedCallbackManager
from langchain.callbacks.stdout import StdOutCallbackHandler
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
from langchain.callbacks.tracers import SharedLangChainTracer
from langchain.callbacks.tracers import LangChainTracer
from langchain.callbacks.wandb_callback import WandbCallbackHandler


def get_callback_manager() -> BaseCallbackManager:
"""Return the shared callback manager."""
return SharedCallbackManager()
return CallbackManager([])


def set_handler(handler: BaseCallbackHandler) -> None:
Expand All @@ -48,7 +46,7 @@ def set_default_callback_manager() -> None:

def set_tracing_callback_manager(session_name: Optional[str] = None) -> None:
"""Set tracing callback manager."""
handler = SharedLangChainTracer()
handler = LangChainTracer()
callback = get_callback_manager()
callback.set_handlers([handler, StdOutCallbackHandler()])
if session_name is None:
Expand All @@ -71,10 +69,7 @@ def get_openai_callback() -> Generator[OpenAICallbackHandler, None, None]:


__all__ = [
"CallbackManager",
"AsyncCallbackManager",
"OpenAICallbackHandler",
"SharedCallbackManager",
"StdOutCallbackHandler",
"AimCallbackHandler",
"WandbCallbackHandler",
Expand Down
Loading