C1M5 Programming Assignment: 4.1 Exercise 1: No response generated for simplified=True function calls

In Exercise 1 of the Module 5 assignment, I added a simplified prompt in the graded code area and executed the code, the unit testcase run and the subsequent test fails with UnboundLocalError: cannot access local variable ‘response’ where it is not associated with a value.

I have noticed that this happens primarily for simplified=True function calls.

I tried to manually execute the function check_if_faq_or_product , the no response issue pops up only when simplified is set to True.

Call: check_if_faq_or_product(‘How can I contact the user support?’, False)

Result: (‘FAQ’, 220)

Call: check_if_faq_or_product(‘How can I contact the user support?’, True)

Result:

UnboundLocalError                         Traceback (most recent call last)
Cell In[33], line 99
96             label = ‘undefined’
98         return label, total_tokens
—> 99 check_if_faq_or_product(‘How can I contact the user support?’, True)

Cell In[33], line 85, in check_if_faq_or_product(query, simplified)
81         router_span.set_status(Status(StatusCode.OK))
84 # Get the Label by accessing the content key of the response dictionary
—> 85 label = response[‘choices’][0][‘message’][‘content’]
86 total_tokens = response[‘usage’][‘total_tokens’]
87 span.set_output(str({“label”: label, ‘total_tokens’:total_tokens}))

UnboundLocalError: cannot access local variable ‘response’ where it is not associated with a value

I wonder if the tracer is broken somehow. Specifically this code’s execution:

with tracer.start_as_current_span("routing_faq_or_product", openinference_span_kind = 'tool') as span:
    span.set_input(str({"query":query, "simplified": simplified}))

I tried to skip the 1.4 Optional Telemetry setup to prevent the tracer issues, but realized that’s not possible as tracer is a necessary variable to run 4.1 exercise. So is 1.4 mandatory and not optional, unlike the title says?

Please find the Lab ID and the error messages below.

LAB ID: qrbdmogghssj

Response of Unit Test cases:

Failed test case: check_if_faq_or_product raised an exception with the following parameters query = What are your working hours?.
Expected: check_if_faq_or_product must run without exceptions
Got: cannot access local variable 'response' where it is not associated with a value

Running the following unedited test Let’s test both versions code:

queries = [
‘What is your return policy?’,
‘Give me three examples of blue T-shirts you have available.’,
‘How can I contact the user support?’,
‘Do you have blue Dresses?’,
‘Create a look suitable for a wedding party happening during dawn.’
]

labels = [‘FAQ’, ‘Product’, ‘FAQ’, ‘Product’, ‘Product’]

for query, correct_label in zip(queries, labels):
# Call check_if_faq_or_product and store the results
response_std, tokens_std = check_if_faq_or_product(query, simplified=False)
response_simp, tokens_simp = check_if_faq_or_product(query, simplified=True)

# Print results
process_and_print_query(query, correct_label, response_std, tokens_std, response_simp, tokens_simp)

Result:

UnboundLocalError                         Traceback (most recent call last)
Cell In[20], line 14
     11 for query, correct_label in zip(queries, labels):
     12     # Call check_if_faq_or_product and store the results
     13     response_std, tokens_std = check_if_faq_or_product(query, simplified=False)
---> 14     response_simp, tokens_simp = check_if_faq_or_product(query, simplified=True)
     16     # Print results
     17     process_and_print_query(query, correct_label, response_std, tokens_std, response_simp, tokens_simp)

Cell In[18], line 85, in check_if_faq_or_product(query, simplified)
     81         router_span.set_status(Status(StatusCode.OK))
     84 # Get the Label by accessing the content key of the response dictionary
---> 85 label = response['choices'][0]['message']['content']
     86 total_tokens = response['usage']['total_tokens']
     87 span.set_output(str({"label": label, 'total_tokens':total_tokens}))

UnboundLocalError: cannot access local variable 'response' where it is not associated with a value

hi @sriharishj

is this the first exercise test result?

can you DM me screenshot of your codes by personal DM.

Also just to be sure, I hope you know there were changed made to labs multiple times due to multiple issue arising from deprecated model. So before you started, did you make sure to get updated notebook by rebooting and clicking Get the latest version??

Also in the section where you provided queries and then labels. Don’t mention labels in separate line, rather mention for each query you wrote, next to it mention if it is FAQ or product label, something like this

Do you have blue dress? Label: Product

Regards
Dr. Deepti

Hi @Deepti_Prasad,

Thank you for your quick response.

Yes, this is the First exercise’s test result.

I did delete all the files (to make sure they got updated), rebooted and got the latest version before submitting my query here. I did redo it a couple times with clearing my browser cache to verify and the issue still persists.

I’ll send over the screenshots via DM now.

Those queries and labels mentioned are not my code, but rather an un-editable code section present after the 1st exercise’s unit test function call. I have mentioned the examples in my prompt as per your recommendation. Thank you for pointing it out anyways.

Regards,
Sri Harish

hi @sriharishj

please follow this thread response

It is a new exception which I even I experienced. I have reported issue to staff, but will have to wait when they(@lucas.coutinho ) look at the report once their weekday starts in their respective timeline.

regards
Dr. Deepti

Alright, will do so. Thank you.

Hi!

Thanks for tagging me @Deepti_Prasad!

This issue happened due to a deprecated model, which has been fixed. You can close and open the assignment to fetch the fixed version.

Cheers,
Lucas

1 Like

@lucas.coutinho

I have tagged you in more posts. please check the mentor lounge topic related to rag

Regards
Dr. Deepti

1 Like

The latest version is working now, thank you.

1 Like

@sriharishj

your latest error looks more to check with your codes than general lab issues which currently rag labs is experiencing.

please check your codes again.

this looks like your prompts need more option to choose between to get response as you mentioned only single examples with each label category.

You are right, thank you. Adding additional examples and restarting the Kernel, fixed the response error. Thank you again.

1 Like

great :clap::clap:

for label category related prompt, i always provide minimum of 3 prompt examples for each label categories.

Remember "“the more refined your prompt is, resulting in better response with the context window choice for llm response.

leaving this thread open, in case you get any further error related to this selected lab, post the error screenshot error without posting any codes here.(based on community guidelines)

Good luck!

Keep Learning!

Regards

Dr. Deepti