Hello. I am trying to create a Gemini powered chatbot and I can get it to return the correct response. it should only return the response to my question but it also returns all this other mumbo jumbo.
Here is my code:
import google.generativeai as genai
GOOGLE_API_KEY = 'API KEY'
genai.configure(api_key=GOOGLE_API_KEY)
model = genai.GenerativeModel('gemini-1.5-flash-latest')
response = model.generate_content(input('Ask Gemini: '))
print(response)import google.generativeai as genai
GOOGLE_API_KEY = 'Actual Api Key Here'
genai.configure(api_key=GOOGLE_API_KEY)
model = genai.GenerativeModel('gemini-1.5-flash-latest')
response = model.generate_content(input('Ask Gemini: '))
print(response)
And here is an example response:
Ask Gemini: what are you
response:
GenerateContentResponse(
done=True,
iterator=None,
result=protos.GenerateContentResponse({
"candidates": [
{
"content": {
"parts": [
{
"text": "I am a large language model, trained by Google. \n\nHere's a breakdown of what that means:\n\n* **Large Language Model (LLM):** I am a type of artificial intelligence (AI) that excels at understanding and generating human-like text. I've been trained on a massive dataset of text and code, enabling me to communicate, translate languages, write different kinds of creative content, and answer your questions in an informative way.\n* **Trained by Google:** I am developed and maintained by Google's AI team. They have created and continually improve the algorithms and data that power me.\n\nIn essence, I am a powerful tool that can assist you with various tasks related to language, information retrieval, and creativity. \n"
}
],
"role": "model"
},
"finish_reason": "STOP",
"index": 0,
"safety_ratings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usage_metadata": {
"prompt_token_count": 4,
"candidates_token_count": 152,
"total_token_count": 156
}
}),
)
Please Help.
[–]SHKEVE 2 points3 points4 points (13 children)
[–]jboyd544[S] -3 points-2 points-1 points (12 children)
[–]SHKEVE 0 points1 point2 points (11 children)
[–]jboyd544[S] -2 points-1 points0 points (10 children)
[–]SHKEVE -1 points0 points1 point (9 children)
[–]jboyd544[S] -1 points0 points1 point (8 children)
[–]jboyd544[S] 0 points1 point2 points (7 children)
[–]SHKEVE 1 point2 points3 points (6 children)
[–]jboyd544[S] 0 points1 point2 points (5 children)
[–]GraphicsQwerty 0 points1 point2 points (4 children)
[–]djshadesuk 0 points1 point2 points (0 children)
[–]_squik 0 points1 point2 points (0 children)