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
35
40
"""
在命令行中,只需运行一次,即可通过 pip 安装软件包:
$ pip install google-generativeai
"""
import google.generativeai as genai
genai.configure(api_key="YOUR API KEY")
defaults = {
'model': 'models/chat_context'0, temp_context 'top'1', "temp_bison-001',
我正在想一个词,需要你猜猜这个。但我不能说这个词本身。我会给你提示,你来猜猜。您应该只能猜出单个词。"
examples = [
[
"它能融入羽毛,让坐着更舒适。",
“枕头?”
],
[
“您可能会在沙发上发现这件事。”,
“一个垫子?”
]、
[
“可以。好的,继续播放。当水滴从天上掉下来时,您可以使用以下选项、“是一把伞吗?”
],
[
"Next: 糟糕",
“出现错误?”
],
[
"Next: booboo",
"A booboo?"],
[
“不,这是另一个词”,
“伤了?”
]
]
messages = [
"这种生物生活得很久了",
"恐龙?",
“下一篇:这是有叶子的食物”,
“生菜?”,
“你可以用以下时间来做我想要的东西”
“沙拉?”
]
messages.append("NEXT REQUEST")
response = genai.chat(
**defaults,
context=context,
examples=examples,
messages=messages
)
print(response.last) # AI 对您最近的请求的响应
1
2
3
4
5
6
7
8
9
10
11
4
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
9
8
7
8
7
8
const { DiscussServiceClient } = required("@google-ai/generativelanguage");
const { GoogleAuth } = required("google-auth-library");
const MODEL_NAME = "models/chat-bison-001";
const API_KEY = "YOUR API KEY";
const brand's KEY's = new Discus我正在想一个词,需要你猜猜这个。但我不能说这个词本身。我会给你提示,你来猜猜。您应该只能猜出单个词。";
const examples = [
{
"input": {
"content": "它是用来放置羽毛的,所以坐起来会更舒适。"
},
"output": {
"content": "A pillow?"
}
},
{
"input": {
"content": "您可能在沙发上会发现它。"
},
"output": {
"content": "缓冲?"
}
},
{
"input": {
"content": "可以。好的,继续播放。当掉落从天空中落下时,您可以使用下面的代码"
},
"output": {
"content": "An umbrella?"
}
},
{
"input": {
"content": "Next: 糟糕"
},
"output": {
"content": "出现错误?"
}
},
{
"input": {
"content": "Next: booboo"
},
"output": {
"content": "嘘?"
}
},
{
"input": {
"content": "No, another word for that"
},
"output": {
"content": "受伤了?"
}
}
];
const messages = [
{
"content": "这种生物生活得很久了"
},
{
"content": "恐龙?"
},
{
"content": "Next: 这是有叶子的食物"
},
{
"content": "Lettuce?"
},
{
"content": "您可以用它来做出我所想的东西"
},
{
"content": "沙拉?"
}
];
messages.push({ "content": "NEXT REQUEST" });
client.generateMessage({
// required, which model to use to generate the result)
model: MODEL_NAME,
// optional, 0.0 始终使用最高可能性的结果
temperature: 0.25,
// optional, how, how many don't generate results to generate leads
|