Gemini Pro Vertex AI Chat Prompt Requests Getting Blocked

So, I am trying to build a chatbot for which I am using gemini pro’s chat prompt to keep the context intact. Here is the code that I am using:
"

from vertexai.preview.generative_models import GenerativeModel, ChatSession
from vertexai.preview.generative_models import (
HarmCategory,
HarmBlockThreshold )
from google.cloud.aiplatform_v1beta1.types.content import SafetySetting
from promptTemplates import *
import vertexai
import os

vertexai.init(project=‘context-score’, location=‘us-central1’)
os.environ[‘GOOGLE_APPLICATION_CREDENTIALS’] = “context-score-gcp-creds.json”

safety_config = {
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
}

base_model = GenerativeModel(“gemini-pro”)

def getResponse(prompt, config , chat= None :disappointed_face:
try:
if chat == None:
response = base_model.generate_content(prompt , generation_config=config, safety_settings=safety_config)
else:

response = chat.send_message(prompt , generation_config=config, safety_settings=safety_config)
print(response)

content = response.text
input_token_count = response._raw_response.usage_metadata.prompt_token_count
output_token_count = response._raw_response.usage_metadata.candidates_token_count

response_dict = {‘content’:content, ‘input_token_count’: input_token_count, “output_token_count”:output_token_count}
return response_dict

except Exception as e:
print('Error Occurred inferencing gemini_pro: ’ , str(e))
return None

chat_model = base_model.start_chat()
config = {
“max_output_tokens”: 1024,
“temperature”: 0.0,
“top_p”: 1
}

if name == ‘main’:
print(summarizationTemplate.format(conversation=conversation))
summary= getResponse(summarizationTemplate.format(conversation=conversation), config=config, chat=chat_model)[‘content’]
#print(summary)
print(analysisTemplate.format(ai_character_name=ai_character_name,
user_character_name=user_character_name,
description=description,
summary=summary,
query=query))
analysis= getResponse(analysisTemplate.format(ai_character_name=ai_character_name,
user_character_name=user_character_name,
description=description,
summary=summary,
query=query), config=config, chat=chat_model)
print(analysis)
"

Everytime the second prompt is ran I am getting the following error:
"
The response was blocked.
"

I am not getting this error when using the base model by generating content, or I am inferencing a simple, “Hey, How are you doing?”. But the specific prompt, I am getting an error. What seems to be the issue here?.

I am putting the entire output here:
"

Summarize the below conversation
Conversation: ```
Manager at TATA AIA: Hey, How can I help you?
Sales Employee at TATA AIA: Good morning, I hope you’re doing well. I wanted to discuss something that’s been on my mind lately. I’ve noticed that many of our newer sales colleagues seem to be getting preferential treatment in terms of opportunities, despite my longer tenure and experience here at TATA AIA. I’m sure there’s a good explanation for this, but I was hoping you could clarify how assignments are distributed and reassure me that the process is aligned with our company policies on equality and fair treatment.
Manager at TATA AIA: Sure, how exactly do you mean that they are given more opportunities? Is there any specific event in your mind?
Sales Employee at TATA AIA: Thank you for your willingness to understand the situation. I’ve noticed that newer employees are often assigned to high-profile clients or given leads that have a higher conversion potential. For instance, last week, a new colleague was tasked with a portfolio that traditionally would be handled by a more experienced team member. I’m keen on understanding how these decisions are made and ensuring they align with our company’s policies on equal opportunity.
Manager at TATA AIA: I dont think any of this is happening in our company. You should stick to the task given to you
Sales Employee at TATA AIA: I appreciate your perspective, but as I’ve observed, it seems that newer employees are often assigned opportunities that many of us with longer tenure are interested in. Could we perhaps review the criteria for opportunity distribution together? I want to ensure that my understanding is aligned with company policies and that we’re all given equal chances based on merit and experience.

Guidelines for summarization: ```
- Create an accurate point-by-point outline of the conversation. Focus exclusively on the spoken content, avoiding any assumptions or external context.
- Ensure each participant's contributions are equally represented. Detail what each character has said in a short, precise and succinct manner.
- Avoid adding any external information or interpretations that are not stated or implied by the conversation participants.
- Keep the outline brief, short, precise and succinct focusing solely on the key points and information presented by each speaker.

candidates {
content {
role: “model”
parts {
text: “- Sales Employee:\n - Noticed newer colleagues receiving preferential treatment in terms of opportunities.\n - Concerned about the fairness of opportunity distribution.\n - Requested clarification on how assignments are made.\n - Wanted to ensure alignment with company policies on equality and fair treatment.\n\n\n- Manager:\n - Asked for specific examples of preferential treatment.\n - Denied the existence of any preferential treatment.\n - Suggested the Sales Employee stick to their assigned tasks.\n\n\n- Sales Employee:\n - Provided an example of a newer colleague being assigned a high-profile client.\n - Reiterated the desire to understand the criteria for opportunity distribution.\n - Wanted to ensure equal chances based on merit and experience.”
}
}
finish_reason: STOP
safety_ratings {
category: HARM_CATEGORY_HARASSMENT
probability: NEGLIGIBLE
}
safety_ratings {
category: HARM_CATEGORY_HATE_SPEECH
probability: NEGLIGIBLE
}
safety_ratings {
category: HARM_CATEGORY_SEXUALLY_EXPLICIT
probability: NEGLIGIBLE
}
safety_ratings {
category: HARM_CATEGORY_DANGEROUS_CONTENT
probability: NEGLIGIBLE
}
}
usage_metadata {
prompt_token_count: 476
candidates_token_count: 148
total_token_count: 624
}

There is a conversation that is going on between a Sales Employee at TATA AIA and a Manager at TATA AIA.
The Sales Employee at TATA AIA is talking to the Manager at TATA AIA for the following: A sales employee who feels that newer employees are being given preferential treatment or better opportunities despite their longer tenure and experience is talking to his/her manager for resolution.
Here is the summary of the conversation till now: ```- Sales Employee:

  • Noticed newer colleagues receiving preferential treatment in terms of opportunities.

  • Concerned about the fairness of opportunity distribution.

  • Requested clarification on how assignments are made.

  • Wanted to ensure alignment with company policies on equality and fair treatment.

  • Manager:

  • Asked for specific examples of preferential treatment.

  • Denied the existence of any preferential treatment.

  • Suggested the Sales Employee stick to their assigned tasks.

  • Sales Employee:

  • Provided an example of a newer colleague being assigned a high-profile client.

  • Reiterated the desire to understand the criteria for opportunity distribution.

  • Wanted to ensure equal chances based on merit and experience.```

The Manager at TATA AIA replied to it by saying the following:

Manager at TATA AIA's Recent Response: "We at TATA AIA definitely condemn any kind of favouritism and I ensure you that we will look into this. Could you give me some example / instance so that I can better understand the extent to which you believe this is going on?"

Given this, provide me with a short, precise and succinct analysis on what the Manager at TATA AIA is proposing on the following steps:

Step 1. Understanding the Message: First, ensure that you have correctly understood Manager at TATA AIA has said. If the response is completely irrelevant to the ongoing discussion then say so and DONOT proceed with the rest of the analysis steps.
Step 2. Role Reversal: Check the Manager at TATA AIA tries to reverse the role by giving a response / reply / question. Pay attention to any attempts to shift the responsibility or focus from themselves to you and say as so and DONOT proceed with the rest of the analysis steps.
Step 3. Emotional Tone: Gauge the emotional tone of their message. Understanding their emotional state can guide the tone and content of your reply.
Step 4. Intent Behind the Message: Try to discern the intent behind their words. Are they seeking information, expressing a need, voicing a concern, or offering a suggestion? This will help you respond appropriately.
Step 5. Underlying Assumptions or Beliefs: Consider any assumptions or beliefs that may underpin their message. This insight can help you address any underlying issues or concerns in your reply.
Step 6. Immediate Context: Take into account the immediate context of the conversation. What topics were discussed just before this point? How does their message fit into the overall flow of the conversation?
Step 7: Finally provide with an overall Analysis by combining all the analysis steps.

Error Occurred inferencing gemini_pro: The response was blocked.
None
"

2 Likes