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

async handling adjustments #918

Merged
merged 21 commits into from
Feb 23, 2024
Merged

async handling adjustments #918

merged 21 commits into from
Feb 23, 2024

Conversation

piotrm0
Copy link
Contributor

@piotrm0 piotrm0 commented Feb 21, 2024

Adjusted handling of wrapped async methods so that a record is added to the database with placeholder values and then updated once the async computation is done. Example using rag_chain of langchain_quickstart.ipynb:

with tru_recorder as recording:
    llm_response = rag_chain.ainvoke("What is Task Decomposition?")

print(recording.records[0].main_output)

Output:

NOTE from trulens_eval:
    This app produced an asynchronous response of type `coroutine`. This record will be updated once
    the response is available. If this message persists, check that you are
    using the correct version of the app method and `await` any asynchronous
    results.

But once we do:

await llm_response

The record gets updated so the same main output printout is as expected:

Task Decomposition is a technique used to break down complex tasks into smaller and simpler steps. This approach allows agents to plan and execute tasks more efficiently by dividing them into manageable components. Task decomposition can be achieved through various methods such as prompting with specific instructions or utilizing human inputs.

Presently this only works if the whole output of the wrapped function is the awaitable, it will not work if the awaitable is hidden inside the return somewhere.

Also refactored some async methods to not rely on the sync/desync utility which should reduce the number of "coroutine already awaited" errors.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 21, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@piotrm0 piotrm0 marked this pull request as draft February 21, 2024 03:25
@piotrm0 piotrm0 marked this pull request as ready for review February 22, 2024 01:24
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Feb 22, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 22, 2024
@piotrm0 piotrm0 merged commit 3699ce5 into main Feb 23, 2024
8 checks passed
Josephrp pushed a commit to Josephrp/trulens that referenced this pull request Feb 23, 2024
* adding cost tracking tests and cost tracking with litellm

* move endpoint cost tests outside of unit tests folder

* adjust docs parameters

* finishing bedrock issues and moved around some tests

check packages on init (truera#917)

* add check imports

* nits

Increase provider test coverage to Huggingface feedback provider (truera#919)

upgrade Llama-Index integration to 0.10 (truera#891)

* upgrade tru_llama

* Update tru_llama.py

* fix indent

* optional imports

* migrate to 0.10

* trullama docstring

* change data load to dir reader in test

* more import changes

* update create_llama

* shrink async test

* test response text from object

* ignore output in json assert

* simplify langchain prompts

* cost tracking tests and litellm cost tracking (truera#910)

* adding cost tracking tests and cost tracking with litellm

* move endpoint cost tests outside of unit tests folder

* adjust docs parameters

* finishing bedrock issues and moved around some tests

* Update tru_llama.py

* framework-llama-notebook imports

* import lines llama

* pinecone quickstart llama update

* updage agents notebook

* llama version update

* missed import changes

* more import changes

---------

Co-authored-by: Piotr Mardziel <piotrm@gmail.com>

Automated File Generation from Docs Notebook Changes (truera#922)

Co-authored-by: joshreini1 <joshreini1@users.noreply.github.com>

Update issue templates (truera#923)

* Update issue templates

* Update bug-report.md

* Update feature_request.md

adding notebook explanations

async handling adjustments (truera#918)

* working

* adjuting async wrapping to produce a record before final result is ready

* docs and finish awaitable wrapping

* clear notebook

* nits and docs

* typo

* fix bug in prior pr

* update streamlit version lower bound

* format

* fixing up docs

* add integration tests to release pipeline

* fix job name

* adjust pipeline config

* fixing up tests

* fixes and don't run db integration tests

* update some llama index imports

* address migration error in release pipeline

* fix makefile

* add another llama index package

bearer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants