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

feat: Add Runnable.close() to close any resources associated with it #439

Merged
merged 1 commit into from
May 28, 2024

Conversation

davidmigloz
Copy link
Owner

@davidmigloz davidmigloz commented May 28, 2024

Previously only LLMs and ChatModels had a close method to close the associated client, but it was not a standard interface. Now the close method is part of the Runnable interface, so you can close any Runnable.

For example:

final chain = promptTemplate
    .pipe(model)
    .pipe(outputParser);
// ...
chain.close();

This will call the close method of all the runnables in the chain. In this case, it won't do anything for promptTemplate and outputParser as they have no associated resources to close, but it will close the HTTP client of the model.

@davidmigloz davidmigloz self-assigned this May 28, 2024
@davidmigloz davidmigloz added t:enhancement New feature or request c:lcel LangChain Expression Language labels May 28, 2024
@davidmigloz davidmigloz added this to the v0.8.0 milestone May 28, 2024
@davidmigloz davidmigloz merged commit 4e08cce into main May 28, 2024
1 check passed
@davidmigloz davidmigloz deleted the close branch May 28, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:lcel LangChain Expression Language t:enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant