Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
azure-open-ai-embeddings-sales
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 11f33aca
authored
Feb 25, 2024
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加智普AI
1 parent
48f75806
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
.vscode/PythonImportHelper-v2-Completion.json
code/test/test04_zhipu.py
.vscode/PythonImportHelper-v2-Completion.json
View file @
11f33ac
...
...
@@ -1050,6 +1050,14 @@
"documentation"
:
{}
},
{
"label"
:
"AzureOpenAI"
,
"importPath"
:
"openai"
,
"description"
:
"openai"
,
"isExtraImport"
:
true
,
"detail"
:
"openai"
,
"documentation"
:
{}
},
{
"label"
:
"AutoTokenizer"
,
"importPath"
:
"transformers"
,
"description"
:
"transformers"
,
...
...
@@ -1115,6 +1123,14 @@
"documentation"
:
{}
},
{
"label"
:
"ZhipuAI"
,
"importPath"
:
"zhipuai"
,
"description"
:
"zhipuai"
,
"isExtraImport"
:
true
,
"detail"
:
"zhipuai"
,
"documentation"
:
{}
},
{
"label"
:
"HTMLResponse"
,
"importPath"
:
"fastapi.responses"
,
"description"
:
"fastapi.responses"
,
...
...
@@ -2381,6 +2397,24 @@
"documentation"
:
{}
},
{
"label"
:
"client"
,
"kind"
:
5
,
"importPath"
:
"code.test.test04_zhipu"
,
"description"
:
"code.test.test04_zhipu"
,
"peekOfCode"
:
"client = ZhipuAI(
\n
api_key=
\"
ac92c959bb3b9092c6f2e0da45cb3acf.kSuemdoJcPgFxieY
\"\n
) # 填写您自己的APIKey
\n
completion = client.chat.completions.create(
\n
model=
\"
glm-4
\"
, # 填写需要调用的模型名称
\n
messages=[
\n
{
\n
\"
role
\"
:
\"
user
\"
,
\n
\"
content
\"
:
\"
作为一名营销专家,请为我的产品创作一个吸引人的slogan
\"
,
\n
},"
,
"detail"
:
"code.test.test04_zhipu"
,
"documentation"
:
{}
},
{
"label"
:
"completion"
,
"kind"
:
5
,
"importPath"
:
"code.test.test04_zhipu"
,
"description"
:
"code.test.test04_zhipu"
,
"peekOfCode"
:
"completion = client.chat.completions.create(
\n
model=
\"
glm-4
\"
, # 填写需要调用的模型名称
\n
messages=[
\n
{
\n
\"
role
\"
:
\"
user
\"
,
\n
\"
content
\"
:
\"
作为一名营销专家,请为我的产品创作一个吸引人的slogan
\"
,
\n
},
\n
{
\n
\"
role
\"
:
\"
assistant
\"
,
\n
\"
content
\"
:
\"
当然,为了创作一个吸引人的slogan,请告诉我一些关于您产品的信息
\"
,"
,
"detail"
:
"code.test.test04_zhipu"
,
"documentation"
:
{}
},
{
"label"
:
"get"
,
"kind"
:
2
,
"importPath"
:
"code.test.test_fastApi"
,
...
...
code/test/test04_zhipu.py
0 → 100644
View file @
11f33ac
from
openai
import
AzureOpenAI
from
zhipuai
import
ZhipuAI
# gets the API Key from environment variable AZURE_OPENAI_API_KEY
client
=
ZhipuAI
(
api_key
=
"ac92c959bb3b9092c6f2e0da45cb3acf.kSuemdoJcPgFxieY"
)
# 填写您自己的APIKey
completion
=
client
.
chat
.
completions
.
create
(
model
=
"glm-4"
,
# 填写需要调用的模型名称
messages
=
[
{
"role"
:
"user"
,
"content"
:
"作为一名营销专家,请为我的产品创作一个吸引人的slogan"
,
},
{
"role"
:
"assistant"
,
"content"
:
"当然,为了创作一个吸引人的slogan,请告诉我一些关于您产品的信息"
,
},
{
"role"
:
"user"
,
"content"
:
"智谱AI开放平台"
},
{
"role"
:
"assistant"
,
"content"
:
"智启未来,谱绘无限一智谱AI,让创新触手可及!"
},
{
"role"
:
"user"
,
"content"
:
"创造一个更精准、吸引人的slogan"
},
],
)
# 普通输出
print
(
completion
.
choices
[
0
]
.
message
)
print
(
completion
.
usage
)
print
(
completion
.
choices
[
0
]
.
message
.
content
)
print
(
completion
.
model_dump_json
(
indent
=
2
))
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment