1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3 30 31 32 33 34 3
""" 在指令列中,您只需執行一次,以便透過 pip 安裝套件: $ pip install google-generativeai "" import google.generativeai 為 genai genai.configure(api_key="<您的 API KEY") defaults = { 'model': 'models/chat-bison_001' <ph type = "x-smartling-void-element"><br /></ph> 我在想一個字,必須請你猜個字。但我不能只說單字我會給你一個線索,你必須猜測答案你的猜測應該只能使用一個字。" examples = [ [ "這隻毛小孩會動起來,更舒服地坐著。", 「枕頭?」 ], [ "這可能會在沙發上找到。", 「A cushion?」 ], [ "可以。好的,「雨天降落」、「雨傘嗎?」時,建議您使用這個選項。 ], [ "Next: 糟糕", "發生錯誤?" ], [ "Next: booboo", "A boo-boo?" ], [ 「不,這是一個字詞。」, "井字號?" ] ] messages = [ "這是很久以前的生物種類", "恐龍?", 「下一個:這是有葉子的食物」、 「Lettuce?」「你可以利用這項資訊來表達我的想法」、 「沙拉嗎?」 ] messages.append("NEXT REQUEST") response = genai.chat( **defaults, context=context, samples=examples, messages=messages ) print(response.last) # 針對您最近一次要求提出的 AI 回應