title: [BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (4): Regarding the related modifications to the Gemini Pro server leading to...
published: false
date: 2024-05-03 00:00:00 UTC
tags:
canonical_url: https://www.evanlin.com/linebot-cloudfunc-firebase-gemini-workshop4/
---
# Bug: The original conversation suddenly has no response

Due to Google Gemini server modifications this morning, the Golang official package hasn't been updated in time. (https://github.com/google/generative-ai-go/issues/97)
This has caused the LINE Bot examples in my BwAI workshop, National Chengchi University and Taipei University courses to potentially fail to receive responses.
Although the official team is working on resolving the issue, this article will share how to bypass the problem using an alternative method.
### Situation:
Text questions are sent, but there is no response. However, sending photos can be answered correctly. Checking the log shows the error message "unknown field `usageMetadata`".

## Affected Projects:
- [https://github.com/kkdai/linebot-cf-firebase](https://github.com/kkdai/linebot-cf-firebase)
- [https://github.com/kkdai/linebot-cf-receipt](https://github.com/kkdai/linebot-cf-receipt)
- [https://github.com/kkdai/linebot-cf-namecard](https://github.com/kkdai/linebot-cf-namecard)
## Related Affected Articles:
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (2): Firebase Database gives LINEBot a super long memory](https://dev.to/evanlin/bwai-workshopgolang-line-oa-cloudfunction-geminipro-firebase-lu-xing-xiao-bang-shou-line-liao-tian-ji-qi-ren-2-firebase-database-rang-linebot-you-ge-chao-chang-ji-yi-2hg7-temp-slug-8338545)
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (3): Importing "Name Card Helper" and "Receipt Helper"](https://dev.to/evanlin/bwai-workshopgolang-line-oa-cloudfunction-geminipro-firebase-lu-xing-xiao-bang-shou-line-liao-tian-ji-qi-ren-3-dao-ru-ming-pian-xiao-bang-shou-gen-shou-ju-xiao-bang-shou--223m-temp-slug-1015142)
## Solution:
Please remember to update the latest version of the code to your cloud function and replace function.go, then redeploy.
- [https://github.com/kkdai/linebot-cf-firebase](https://github.com/kkdai/linebot-cf-firebase)
- [https://github.com/kkdai/linebot-cf-receipt](https://github.com/kkdai/linebot-cf-receipt)
- [https://github.com/kkdai/linebot-cf-namecard](https://github.com/kkdai/linebot-cf-namecard)
# Serious Discussion
According to [issue 97](https://github.com/google/generative-ai-go/issues/97), the main problem lies in the information processing part returned by SendMessage.
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY")))
if err != nil {
log.Fatal(err)
}
defer client.Close()
model := client.GenerativeModel("gemini-1.0-pro")
cs := model.StartChat()
msg := "hello"
fmt.Printf("== Me: %s\n== Model:\n", msg)
_, err = cs.SendMessage(ctx, genai.Text(msg))
if err != nil {
log.Fatal(err)
}
}
## Workaround
You can consider replacing `StartChat()` with the original `model.GenerateContent(ctx, genai.Text(text))`, but you won't be able to use `cs.History = Memory`. At this time, you can use
totalString := fmt.Sprintf("Memory:(%s), %s", string(jsonStr), req)
res, err := model.GenerateContent(ctx, genai.Text(totalString))
if err != nil {
log.Fatal(err)
}
Treat the previous discussion data as `Memory` and put it into the prompt. This is a way to handle it. Later, I found that the results were quite good.
# Article List:
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (1): Scenery Recognition Helper](https://dev.to/evanlin/bwai-workshopgolang-line-oa-cloudfunction-geminipro-firebase-lu-xing-xiao-bang-shou-line-liao-tian-ji-qi-ren-23j9-temp-slug-2266421)
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (2): Firebase Database gives LINEBot a super long memory](https://dev.to/evanlin/bwai-workshopgolang-line-oa-cloudfunction-geminipro-firebase-lu-xing-xiao-bang-shou-line-liao-tian-ji-qi-ren-2-firebase-database-rang-linebot-you-ge-chao-chang-ji-yi-2hg7-temp-slug-8338545)
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (3): Importing "Name Card Helper" and "Receipt Helper"](https://dev.to/evanlin/bwai-workshopgolang-line-oa-cloudfunction-geminipro-firebase-lu-xing-xiao-bang-shou-line-liao-tian-ji-qi-ren-3-dao-ru-ming-pian-xiao-bang-shou-gen-shou-ju-xiao-bang-shou--223m-temp-slug-1015142)
- [[BwAI workshop][Golang] LINE OA + CloudFunction + GeminiPro + Firebase = Travel Helper LINE Chatbot (4): Regarding the related modifications to the Gemini Pro server leading to the unknown field `usageMetadata` error message](https://www.evanlin.com/linebot-cloudfunc-firebase-gemini-workshop4/)
# Code List:
- [Name Card Helper (Old version using Golang + Notion)](https://github.com/kkdai/linebot-smart-namecard)
- [Receipt Helper (Python old version)](https://github.com/kkdai/linebot-receipt-gemini)
- [Image Recognition LINEBot](https://github.com/kkdai/linebot-cloudfunc-gemini-go)
- [Chatbot with long memory](https://github.com/kkdai/linebot-cf-firebase)
- [Name Card Helper (New version: Golang + Firebase RealtimeDB + Cloud Functions)](https://github.com/kkdai/linebot-cf-namecard)
- [Receipt Helper (New version: Python -> Golang + Firebase DB + Cloud Functions)](https://github.com/kkdai/linebot-cf-receipt)
Top comments (0)