Task 3. Prompt the model to call your functions In this task, you will test the model's…
- User
Task 3. Prompt the model to call your functions In this task, you will test the model's ability to respond effectively to different queries.
- Test that the model responds with it's own answer for non-math related questions.
response = chat.send_message("Tell me a joke.") handle_response(response)
- Test the model with the following prompt and print the result to the console: "I have 7 pizzas each with 16 slices. How many slices do I have?"
response = chat.send_message("I have 7 pizzas each with 16 slices. How many slices do I have?") handle_response(response)
- Next, test the model with the following prompt and print the result to the console: "Doug brought 3 pizzas. Andrew brought 4 pizzas. How many pizzas did they bring together?"
response = chat.send_message("Doug brought 3 pizzas. Andrew brought 4 pizzas. How many pizzas did they bring together?") handle_response(response)
- Test the model with the following prompt and print the result to the console: "Doug brought 3 pizzas. Andrew brought 4 pizzas. There are 16 slices per pizza. How many slices are there?"
response = chat.send_message("Doug brought 3 pizzas. Andrew brought 4 pizzas. There are 16 slices per pizza. How many slices are there?") handle_response(response)
- Test the model with the following prompt and print the result to the console: "Doug brought 4 pizzas, but Andrew dropped 2 on the ground. How many pizzas are left?"
response = chat.send_message("Doug brought 4 pizzas, but Andrew dropped 2 on the ground. How many pizzas are left?") handle_response(response)
6. Save your notebook.Click Check my progress to verify the objective.
Please test the model with the prompt 'I have 7 pizzas each with 16 slices. How many slices do I have?'. Test the model with prompts to see it call your functions and display the results.
Please test the model with the prompt 'I have 7 pizzas each with 16 slices. How many slices do I have?'.
change my code for this given task
response = chat.send_message("Reverse the following string: Hello world") handle_response(response) response = chat.send_message("Remove the white spaces from the following word: hello @ world. com") response = chat.send_message("Remove the white spaces from the following word: hello @ world. com") handle_response(response) response = chat.send_message("Reverse the following string and remove spaces: I do not understand the new sentence.") handle_response(response)
response = chat.send_message("Tell me a fact. Then remove the spaces in the fact text and then reverse the fact text.") print(response.candidates[0].content.parts[0].text) handle_response(response) - Assistant
- User
Task 2. Define functions in Python Define functions to add and multiply two numbers in Python Define a function to take two input numbers and add them together. Then define another function to multiply two inputs. Keep the print statements in the template below in your functions, so you can see when they are being executed.
- Assistant
- User
NameError Traceback (most recent call last) Cell In[18], line 22 19 math_tools = FunctionDeclarations() 21 # Initialize the model with gemini-1.5-pro-001, the tools, a temperature of 0, and system instructions. ---> 22 model = initialize_model( 23 model_name='gemini-1.5-pro-001', 24 tools=math_tools, 25 temperature=0, 26 instructions=( 27 "Fulfill the user's instructions. " 28 "If asked to add or multiply numbers, call the provided functions. " 29 "You may call one function after the other if needed. " 30 "Repeat the result to the user." 31 ) 32 ) 34 # Run the following snippet to initialize the model to start a new chat. 35 chat = model.start_chat()
NameError: name 'initialize_model' is not defined
- Assistant