Skip to content

Commit 9a730e7

Browse files
author
jinhaiyang
committed
【web_search】web_search
1 parent fb05da7 commit 9a730e7

File tree

12 files changed

+1548
-1548
lines changed

12 files changed

+1548
-1548
lines changed
Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,111 @@
1-
# import logging
2-
# import logging.config
3-
# import zhipuai
4-
# from zhipuai import ZhipuAI
5-
# import json
6-
#
7-
# def test_assistant(logging_conf) -> None:
8-
# logging.config.dictConfig(logging_conf) # type: ignore
9-
# client = ZhipuAI() # 填写您自己的APIKey
10-
# try:
11-
#
12-
# generate = client.assistant.conversation(
13-
# assistant_id="659e54b1b8006379b4b2abd6",
14-
# messages=[
15-
# {
16-
# "role": "user",
17-
# "content": [{
18-
# "type": "text",
19-
# "text": "帮我搜索下智谱的cogvideox发布时间"
20-
# }]
21-
# }
22-
# ],
23-
# stream=True,
24-
# attachments=None,
25-
# metadata=None,
26-
# request_id="request_1790291013237211136",
27-
# user_id="12345678"
28-
# )
29-
# for assistant in generate:
30-
# print(assistant)
31-
#
32-
# except zhipuai.core._errors.APIRequestFailedError as err:
33-
# print(err)
34-
# except zhipuai.core._errors.APIInternalError as err:
35-
# print(err)
36-
# except zhipuai.core._errors.APIStatusError as err:
37-
# print(err)
38-
#
39-
# def test_assistant_query_support(logging_conf) -> None:
40-
# logging.config.dictConfig(logging_conf) # type: ignore
41-
# client = ZhipuAI() # 填写您自己的APIKey
42-
# try:
43-
#
44-
# response = client.assistant.query_support(
45-
# assistant_id_list=[],
46-
# request_id="request_1790291013237211136",
47-
# user_id="12345678"
48-
# )
49-
# print(response)
50-
#
51-
# except zhipuai.core._errors.APIRequestFailedError as err:
52-
# print(err)
53-
# except zhipuai.core._errors.APIInternalError as err:
54-
# print(err)
55-
# except zhipuai.core._errors.APIStatusError as err:
56-
# print(err)
57-
#
58-
# def test_assistant_query_conversation_usage(logging_conf) -> None:
59-
# logging.config.dictConfig(logging_conf) # type: ignore
60-
# client = ZhipuAI() # 填写您自己的APIKey
61-
# try:
62-
# response = client.assistant.query_conversation_usage(
63-
# assistant_id="659e54b1b8006379b4b2abd6",
64-
# request_id="request_1790291013237211136",
65-
# user_id="12345678"
66-
# )
67-
# print(response)
68-
# except zhipuai.core._errors.APIRequestFailedError as err:
69-
# print(err)
70-
# except zhipuai.core._errors.APIInternalError as err:
71-
# print(err)
72-
# except zhipuai.core._errors.APIStatusError as err:
73-
# print(err)
74-
#
75-
#
76-
# def test_translate_api(logging_conf) -> None:
77-
# logging.config.dictConfig(logging_conf) # type: ignore
78-
# client = ZhipuAI() # 填写您自己的APIKey
79-
# try:
80-
# translate_response = client.assistant.conversation(
81-
# assistant_id="9996ijk789lmn012o345p999",
82-
# messages=[
83-
# {
84-
# "role": "user",
85-
# "content": [{
86-
# "type": "text",
87-
# "text": "你好呀"
88-
# }]
89-
# }
90-
# ],
91-
# stream=True,
92-
# attachments=None,
93-
# metadata=None,
94-
# request_id="request_1790291013237211136",
95-
# user_id="12345678",
96-
# extra_parameters = {
97-
# "translate": {
98-
# "from": "zh",
99-
# "to": "en"
100-
# }
101-
# }
102-
# )
103-
# for chunk in translate_response:
104-
# print(chunk.choices[0].delta)
105-
# #print(translate_response)
106-
# except zhipuai.core._errors.APIRequestFailedError as err:
107-
# print(err)
108-
# except zhipuai.core._errors.APIInternalError as err:
109-
# print(err)
110-
# except zhipuai.core._errors.APIStatusError as err:
111-
# print(err)
1+
import logging
2+
import logging.config
3+
import zhipuai
4+
from zhipuai import ZhipuAI
5+
import json
6+
7+
def test_assistant(logging_conf) -> None:
8+
logging.config.dictConfig(logging_conf) # type: ignore
9+
client = ZhipuAI() # 填写您自己的APIKey
10+
try:
11+
12+
generate = client.assistant.conversation(
13+
assistant_id="659e54b1b8006379b4b2abd6",
14+
messages=[
15+
{
16+
"role": "user",
17+
"content": [{
18+
"type": "text",
19+
"text": "帮我搜索下智谱的cogvideox发布时间"
20+
}]
21+
}
22+
],
23+
stream=True,
24+
attachments=None,
25+
metadata=None,
26+
request_id="request_1790291013237211136",
27+
user_id="12345678"
28+
)
29+
for assistant in generate:
30+
print(assistant)
31+
32+
except zhipuai.core._errors.APIRequestFailedError as err:
33+
print(err)
34+
except zhipuai.core._errors.APIInternalError as err:
35+
print(err)
36+
except zhipuai.core._errors.APIStatusError as err:
37+
print(err)
38+
39+
def test_assistant_query_support(logging_conf) -> None:
40+
logging.config.dictConfig(logging_conf) # type: ignore
41+
client = ZhipuAI() # 填写您自己的APIKey
42+
try:
43+
44+
response = client.assistant.query_support(
45+
assistant_id_list=[],
46+
request_id="request_1790291013237211136",
47+
user_id="12345678"
48+
)
49+
print(response)
50+
51+
except zhipuai.core._errors.APIRequestFailedError as err:
52+
print(err)
53+
except zhipuai.core._errors.APIInternalError as err:
54+
print(err)
55+
except zhipuai.core._errors.APIStatusError as err:
56+
print(err)
57+
58+
def test_assistant_query_conversation_usage(logging_conf) -> None:
59+
logging.config.dictConfig(logging_conf) # type: ignore
60+
client = ZhipuAI() # 填写您自己的APIKey
61+
try:
62+
response = client.assistant.query_conversation_usage(
63+
assistant_id="659e54b1b8006379b4b2abd6",
64+
request_id="request_1790291013237211136",
65+
user_id="12345678"
66+
)
67+
print(response)
68+
except zhipuai.core._errors.APIRequestFailedError as err:
69+
print(err)
70+
except zhipuai.core._errors.APIInternalError as err:
71+
print(err)
72+
except zhipuai.core._errors.APIStatusError as err:
73+
print(err)
74+
75+
76+
def test_translate_api(logging_conf) -> None:
77+
logging.config.dictConfig(logging_conf) # type: ignore
78+
client = ZhipuAI() # 填写您自己的APIKey
79+
try:
80+
translate_response = client.assistant.conversation(
81+
assistant_id="9996ijk789lmn012o345p999",
82+
messages=[
83+
{
84+
"role": "user",
85+
"content": [{
86+
"type": "text",
87+
"text": "你好呀"
88+
}]
89+
}
90+
],
91+
stream=True,
92+
attachments=None,
93+
metadata=None,
94+
request_id="request_1790291013237211136",
95+
user_id="12345678",
96+
extra_parameters = {
97+
"translate": {
98+
"from": "zh",
99+
"to": "en"
100+
}
101+
}
102+
)
103+
for chunk in translate_response:
104+
print(chunk.choices[0].delta)
105+
#print(translate_response)
106+
except zhipuai.core._errors.APIRequestFailedError as err:
107+
print(err)
108+
except zhipuai.core._errors.APIInternalError as err:
109+
print(err)
110+
except zhipuai.core._errors.APIStatusError as err:
111+
print(err)
Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
1-
# # -*- coding: utf-8 -*-
2-
#
3-
# from zhipuai import ZhipuAI
4-
# import zhipuai
5-
#
6-
# import logging
7-
# import logging.config
8-
#
9-
#
10-
# def test_completions_charglm(logging_conf):
11-
# logging.config.dictConfig(logging_conf) # type: ignore
1+
# -*- coding: utf-8 -*-
2+
3+
from zhipuai import ZhipuAI
4+
import zhipuai
5+
6+
import logging
7+
import logging.config
8+
9+
10+
def test_completions_charglm(logging_conf):
11+
logging.config.dictConfig(logging_conf) # type: ignore
12+
client = ZhipuAI() # 请填写您自己的APIKey
13+
try:
14+
response = client.chat.completions.create(
15+
model="charglm-3", # 填写需要调用的模型名称
16+
messages=[
17+
{
18+
"role": "user",
19+
"content": "请问你在做什么"
20+
}
21+
],
22+
meta={
23+
"user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。",
24+
"bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。",
25+
"bot_name": "苏梦远",
26+
"user_name": "陆星辰"
27+
},
28+
user_id="12345678"
29+
)
30+
print(response)
31+
32+
33+
except zhipuai.core._errors.APIRequestFailedError as err:
34+
print(err)
35+
except zhipuai.core._errors.APIInternalError as err:
36+
print(err)
37+
except zhipuai.core._errors.APIStatusError as err:
38+
print(err)
39+
40+
41+
42+
def test_async_completions():
43+
client = ZhipuAI() # 请填写您自己的APIKey
44+
try:
45+
response = client.chat.asyncCompletions.create(
46+
model="charglm", # 填写需要调用的模型名称
47+
messages=[
48+
{
49+
"role": "user",
50+
"content": "请问你在做什么"
51+
}
52+
],
53+
meta={
54+
"user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。",
55+
"bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。",
56+
"bot_name": "苏梦远",
57+
"user_name": "陆星辰"
58+
},
59+
)
60+
print(response)
61+
62+
63+
64+
except zhipuai.core._errors.APIRequestFailedError as err:
65+
print(err)
66+
except zhipuai.core._errors.APIInternalError as err:
67+
print(err)
68+
except zhipuai.core._errors.APIStatusError as err:
69+
print(err)
70+
71+
# def test_retrieve_completion_result():
1272
# client = ZhipuAI() # 请填写您自己的APIKey
1373
# try:
14-
# response = client.chat.completions.create(
15-
# model="charglm-3", # 填写需要调用的模型名称
16-
# messages=[
17-
# {
18-
# "role": "user",
19-
# "content": "请问你在做什么"
20-
# }
21-
# ],
22-
# meta={
23-
# "user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。",
24-
# "bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。",
25-
# "bot_name": "苏梦远",
26-
# "user_name": "陆星辰"
27-
# },
28-
# user_id="12345678"
29-
# )
74+
# response = client.chat.asyncCompletions.retrieve_completion_result(id="1014908592669352541650991")
3075
# print(response)
3176
#
3277
#
3378
# except zhipuai.core._errors.APIRequestFailedError as err:
3479
# print(err)
3580
# except zhipuai.core._errors.APIInternalError as err:
3681
# print(err)
37-
# except zhipuai.core._errors.APIStatusError as err:
38-
# print(err)
39-
#
40-
#
41-
#
42-
# def test_async_completions():
43-
# client = ZhipuAI() # 请填写您自己的APIKey
44-
# try:
45-
# response = client.chat.asyncCompletions.create(
46-
# model="charglm", # 填写需要调用的模型名称
47-
# messages=[
48-
# {
49-
# "role": "user",
50-
# "content": "请问你在做什么"
51-
# }
52-
# ],
53-
# meta={
54-
# "user_info": "我是陆星辰,是一个男性,是一位知名导演,也是苏梦远的合作导演。我擅长拍摄音乐题材的电影。苏梦远对我的态度是尊敬的,并视我为良师益友。",
55-
# "bot_info": "苏梦远,本名苏远心,是一位当红的国内女歌手及演员。在参加选秀节目后,凭借独特的嗓音及出众的舞台魅力迅速成名,进入娱乐圈。她外表美丽动人,但真正的魅力在于她的才华和勤奋。苏梦远是音乐学院毕业的优秀生,善于创作,拥有多首热门原创歌曲。除了音乐方面的成就,她还热衷于慈善事业,积极参加公益活动,用实际行动传递正能量。在工作中,她对待工作非常敬业,拍戏时总是全身心投入角色,赢得了业内人士的赞誉和粉丝的喜爱。虽然在娱乐圈,但她始终保持低调、谦逊的态度,深得同行尊重。在表达时,苏梦远喜欢使用“我们”和“一起”,强调团队精神。",
56-
# "bot_name": "苏梦远",
57-
# "user_name": "陆星辰"
58-
# },
59-
# )
60-
# print(response)
61-
#
62-
#
63-
#
64-
# except zhipuai.core._errors.APIRequestFailedError as err:
65-
# print(err)
66-
# except zhipuai.core._errors.APIInternalError as err:
67-
# print(err)
68-
# except zhipuai.core._errors.APIStatusError as err:
69-
# print(err)
70-
#
71-
# # def test_retrieve_completion_result():
72-
# # client = ZhipuAI() # 请填写您自己的APIKey
73-
# # try:
74-
# # response = client.chat.asyncCompletions.retrieve_completion_result(id="1014908592669352541650991")
75-
# # print(response)
76-
# #
77-
# #
78-
# # except zhipuai.core._errors.APIRequestFailedError as err:
79-
# # print(err)
80-
# # except zhipuai.core._errors.APIInternalError as err:
81-
# # print(err)
82-
#
83-
# # if __name__ == "__main__":
84-
# # test_retrieve_completion_result()
82+
83+
# if __name__ == "__main__":
84+
# test_retrieve_completion_result()

0 commit comments

Comments
 (0)