Skip to content

Add Bedrock Provider Quickstart Notebook - #2560

Open
RamanaReddyGunda wants to merge 8 commits into
truera:mainfrom
RamanaReddyGunda:ramana/bedrock-provider-quickstart-notebook
Open

Add Bedrock Provider Quickstart Notebook#2560
RamanaReddyGunda wants to merge 8 commits into
truera:mainfrom
RamanaReddyGunda:ramana/bedrock-provider-quickstart-notebook

Conversation

@RamanaReddyGunda

@RamanaReddyGunda RamanaReddyGunda commented Jun 18, 2026

Copy link
Copy Markdown

Closes #2469

Description

Please include a summary of the changes and the related issue that can be
included in the release announcement. Please also include relevant motivation
and context.

Other details good to know for developers

Please include any other details of this change useful for TruLens developers.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • New Tests
  • This change includes re-generated golden test results
  • This change requires a documentation update

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 18, 2026
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -0,0 +1,298 @@
{

@sfc-gh-jreini sfc-gh-jreini Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove the security note here.


Reply via ReviewNB

@@ -0,0 +1,298 @@
{

@sfc-gh-jreini sfc-gh-jreini Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to set regular key variables here and then print them, just keep them as environment variables and pass the env variables in the later cells.


Reply via ReviewNB

@@ -0,0 +1,298 @@
{

@sfc-gh-jreini sfc-gh-jreini Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't leave this ouput in the notebook - also this makes me worry you haven't run this example successfully. please verify the example runs successfully end to end.


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #5.    os.environ['TRULENS_OTEL_TRACING'] = '0'

don't turn off OTEL tracing - why did you do this to start with? Did you run into errors?


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #1.    try:

Call an actual out of the box metric (such as relevance) rather than building your own with the hidden _create_chat_completion method.


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #9.    def context_relevance(query: str, context: List[Dict] = None) -> Dict[str, Any]:

use out of the box context relevance metric instead of creating your own.

def context_relevance_with_cot_reasons(


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #4.    try:

remove the try/except block


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #10.        record_id = session.add_record(

create an app and instrument it like in the trulens quickstart (you are welcome to use this simple retrieve function in it) instead of doing add_record.


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Line #19.            meta={'model': bedrock_model},

the bedrock model should be captured automatically once you add in instrumentatino so no need to manually pass it here


Reply via ReviewNB

@@ -0,0 +1,288 @@
{

@joshreini1 joshreini1 Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Split up the cell descriptions to above each cell they describe instead of including here at the end.


Reply via ReviewNB

@sfc-gh-jreini sfc-gh-jreini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Progress: built-in metrics (provider.relevance, provider.context_relevance) and TruBasicApp are the right patterns — those match the Anthropic and other provider quickstarts.

Remaining issue: the rag_app function calls provider._create_chat_completion() directly. That is a private method on TruLens's LLMProvider base class — it is not part of the public API and can change without notice. Quickstart notebooks should not teach users to call private methods.

For the generation step, call the Bedrock SDK directly, the same way the Anthropic quickstart calls anthropic.completions.create():

import boto3
bedrock_client = boto3.client('bedrock-runtime', region_name=aws_region)
response = bedrock_client.converse(
modelId=bedrock_model,
messages=[{'role': 'user', 'content': [{'text': prompt}]}]
)
return response['output']['message']['content'][0]['text']

This is one focused change — everything else looks good.

@sfc-gh-jreini

Copy link
Copy Markdown
Contributor

Checking in — the Aug 10 commit looks like just a sync merge from main, not the fix I flagged. The outstanding item is still: replace provider._create_chat_completion() in the rag_app function with a direct Bedrock SDK call (boto3.client('bedrock-runtime').converse(...)). Let me know if you have questions about the expected pattern.

@RamanaReddyGunda

Copy link
Copy Markdown
Author

my latest code pushed branch (https://github.com/RamanaReddyGunda/trulens/tree/ramana/bedrock-provider-quickstart-notebook) and raised merge request to main branch.
if any misunderstands please guide me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Bedrock Provider Quickstart Notebook

3 participants