C1M3_Assignment error

Can you please help me with the solution for Exercise 1. I am unable to resolve the error

Hi dis28,

Please try to describe the problem you face without using code. Then we can try to help you.

I am facing some issue with Exercise 1 solution and need help to debug it. I think I am making a mistake here. Could you please guide what I should mention as parameters in new-msg to keep track of tool use

What kind of help can this community provide if I am unable to debug the code. Are there any resources from where I can learn. I have already gone through the videos and it is not helpful to solve this assignment. Thanks in advance!

Hopefully a mentor for this course will see your message and post a reply.

1 Like

Hi dis28,

Look carefully at the comments in the code snippet:

            # Set role to "tool" (plain string) to signal a tool was used

This should be self-explanatory

            # As stated in the markdown when inspecting the ChatCompletionMessage object 
            # every call has an attribute called id

It says here that call has an attribute called id. Think about how you can reach that attribute. This is explained, e.g. here Python Attributes – Class and Instance Attribute Examples

            # The name of the tool was already defined above, use that variable

This should again be self-explanatory

            # Pass the result of calling the tool to json.dumps

Look at the preceding code to see the name of the variable that contains the result of calling the tool. Then enter that variable name in json.dumps().

I hope this helps!

2 Likes

adding just more pointers to @reinoudbosch suggestions.

@dis28

In the instructions mentions

Parameter Configuration: Consider the parameters already defined in your function, such as model, messages, and tools. Think about how these might be used in your setup.

So in new messages you are basically creating text generation but who are assigning this role?

in the role of system where it acted as ai assistant and used tools available with prompt! provided,

the new message wants you to assign tools the role check which tool was used (first code)

then you need to use a specific attributed id to the tool used for the tool_call_id(second code, instruction actually givees you hint what to use)

then ask you to mention the tool_name used in generating the report for name(third code)

lastly to look at the content it tells tool to look at json.dumps(fourth code) but use the result where the tool execution and output was called by result. So if json.dumps is function, your output here is result i.e. function(output)

imagine this in an excel sheet where you need to look at a particular tool(role) so first you look at the id specification, then matching with its tool name and to look at the content look at results in tool function using json.dumps. If you imagine it is beautiful explanation of how a data analytics works on exel sheets matching columns to rows to get end results..

Regards

DP

1 Like

Thank you @Deepti_Prasad and @reinoudbosch . That was helpful!