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 回應
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
39
const { DiscussServiceClient } = requirements("@google-ai/generativelanguage");
const { GoogleAuth } =需要("google-auth-library");
const MODEL_NAME = "models/chat-bison-001";
const API_KEY = "<您的 API 金鑰>";
const API
KEYService<目標用戶端>.<新的 API 金鑰>
const API
<ph type="x-smartling-void-element"><br /></ph>我在想一個字,必須請你猜個字。但我不能只說單字我會給你一個線索,你必須猜測答案猜測應該要只包含一個字。";
const examples = [
{
"input": {
"content": "這件事可以一直貼合,導致更舒適地坐著。"
},
"output": {
"content": "枕頭"
}
},
{
"input": {
"content": "您可能會在沙發上找到這個問題。"
},
"output": {
"content": "是 cushion?"
}
},
{
"input": {
"content": "可以。好的,這個工具適合用於從天空墜落的地方"
},
"output": {
"content": "雨傘?"
}
},
{
"input": {
"content": "Next: 糟糕"
},
"output": {
"content": "發生錯誤嗎?"
}
},
{
"input": {
"content": "Next: booboo"
},
"output": {
"content": "酒鬼?"
}
},
{
"input": {
"content": "不是,也沒關係"
},
"output": {
"content": "傷口了嗎?"
}
}
];
const messages = [
{
"content": "這是很久以前的生物"
},
{
"content": "恐龍?"
},
{
"content": "Next: 那是失蹤的食物"
},
{
"content": "Lettuce?"
},
{
"content": "你的想法可以加深思考"
},
{
"content": "沙拉?"
}
];
messages.push({ "content": "NEXT REQUEST" });
client.generateMessage({
// required,該模型要用於產生結果模型:MODEL_NAME,
// optional, 0.0 一律使用最高機率
結果
溫度:0.25,
messages.push