isrpa 0.9.7__py3-none-any.whl → 0.9.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isrpa/credentials.py +0 -20
- isrpa/llm_chat.py +45 -15
- isrpa/utils.py +0 -8
- {isrpa-0.9.7.dist-info → isrpa-0.9.9.dist-info}/METADATA +1 -1
- isrpa-0.9.9.dist-info/RECORD +12 -0
- isrpa-0.9.7.dist-info/RECORD +0 -12
- {isrpa-0.9.7.dist-info → isrpa-0.9.9.dist-info}/WHEEL +0 -0
- {isrpa-0.9.7.dist-info → isrpa-0.9.9.dist-info}/top_level.txt +0 -0
isrpa/credentials.py
CHANGED
@@ -14,9 +14,7 @@ def store_key(key_name,key_value,user_name):
|
|
14
14
|
|
15
15
|
"""
|
16
16
|
# address = os.environ.get("address", "192.168.12.249")
|
17
|
-
print(address)
|
18
17
|
url = f"{address}/console/api/user_credentials"
|
19
|
-
print(url)
|
20
18
|
headers = {
|
21
19
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
22
20
|
}
|
@@ -26,11 +24,8 @@ def store_key(key_name,key_value,user_name):
|
|
26
24
|
'certificate_value': encode(key_value),
|
27
25
|
'user_name': user_name
|
28
26
|
}
|
29
|
-
print(data)
|
30
27
|
response = requests.post(url, headers=headers, json=data)
|
31
28
|
if response.status_code != 200:
|
32
|
-
print("请求失败,状态码:", response.status_code)
|
33
|
-
print(response.text)
|
34
29
|
return "failure"
|
35
30
|
json = response.json()
|
36
31
|
return json['certificate_key']
|
@@ -43,11 +38,8 @@ def get_key(key_name, user_name):
|
|
43
38
|
"""
|
44
39
|
# address = os.environ.get("address", "192.168.12.249")
|
45
40
|
url = f"{address}/console/api/user_credentials?certificate_key={key_name}&user_name={user_name}"
|
46
|
-
print(url)
|
47
41
|
response = requests.get(url)
|
48
42
|
if response.status_code != 200:
|
49
|
-
print("请求失败,状态码:", response.status_code)
|
50
|
-
print(response.text)
|
51
43
|
return "failure"
|
52
44
|
json = response.json()
|
53
45
|
|
@@ -61,7 +53,6 @@ def delete_key(key_name,user_name):
|
|
61
53
|
"""
|
62
54
|
# address = os.environ.get("address", "192.168.12.249")
|
63
55
|
url = f"{address}/console/api/user_credentials"
|
64
|
-
print(url)
|
65
56
|
headers = {
|
66
57
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
67
58
|
}
|
@@ -70,7 +61,6 @@ def delete_key(key_name,user_name):
|
|
70
61
|
'certificate_key': key_name,
|
71
62
|
'user_name': user_name
|
72
63
|
}
|
73
|
-
print(data)
|
74
64
|
requests.delete(url, headers=headers, json=data)
|
75
65
|
|
76
66
|
def list(user_name):
|
@@ -80,11 +70,8 @@ def list(user_name):
|
|
80
70
|
"""
|
81
71
|
# address = os.environ.get("address", "192.168.12.249")
|
82
72
|
url = f"{address}/console/api/user_credentials/list?user_name={user_name}"
|
83
|
-
print(url)
|
84
73
|
response = requests.get(url)
|
85
74
|
if response.status_code != 200:
|
86
|
-
print("请求失败,状态码:", response.status_code)
|
87
|
-
print(response.text)
|
88
75
|
return "failure"
|
89
76
|
json = response.json()
|
90
77
|
|
@@ -98,11 +85,8 @@ def exist(key_name, user_name):
|
|
98
85
|
"""
|
99
86
|
# address = os.environ.get("address", "192.168.12.249")
|
100
87
|
url = f"{address}/console/api/user_credentials?certificate_key={key_name}&user_name={user_name}"
|
101
|
-
print(url)
|
102
88
|
response = requests.get(url)
|
103
89
|
if response.status_code != 200:
|
104
|
-
print("请求失败,状态码:", response.status_code)
|
105
|
-
print(response.text)
|
106
90
|
return False
|
107
91
|
|
108
92
|
|
@@ -114,7 +98,6 @@ def encode(certificate_value):
|
|
114
98
|
key_name:凭证key
|
115
99
|
"""
|
116
100
|
url = f"{address}/console/api/get_encode_credentials"
|
117
|
-
print(url)
|
118
101
|
headers = {
|
119
102
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
120
103
|
}
|
@@ -122,11 +105,8 @@ def encode(certificate_value):
|
|
122
105
|
data = {
|
123
106
|
'certificate_value': certificate_value,
|
124
107
|
}
|
125
|
-
print(data)
|
126
108
|
response = requests.post(url, headers=headers, json=data)
|
127
109
|
if response.status_code != 200:
|
128
|
-
print("请求失败,状态码:", response.status_code)
|
129
|
-
print(response.text)
|
130
110
|
return "failure"
|
131
111
|
json = response.json()
|
132
112
|
return json['certificate_value']
|
isrpa/llm_chat.py
CHANGED
@@ -1,24 +1,54 @@
|
|
1
|
+
from typing import Optional, Dict, Any, List, Union
|
1
2
|
from volcenginesdkarkruntime import Ark
|
2
|
-
#暂不统计消耗的token,后续要统计再改,无法传递token没法用dify的大模型,先保证这个功能能用起来
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
def ai_query(
|
6
|
+
query: str,
|
7
|
+
context: Optional[List[Dict[str, str]]] = None,
|
8
|
+
model: str = "deepseek-v3-250324",
|
9
|
+
**kwargs
|
10
|
+
) -> Union[str, Dict[str, Any]]:
|
11
|
+
"""
|
12
|
+
向AI发送查询,支持对话上下文和函数调用
|
13
|
+
|
14
|
+
参数:
|
15
|
+
query: 用户查询文本
|
16
|
+
context: 之前的对话上下文(role/content格式)
|
17
|
+
model: 使用的AI模型
|
18
|
+
**kwargs: 其他API参数(temperature, max_tokens等)
|
19
|
+
|
20
|
+
返回:
|
21
|
+
普通回答: 返回字符串
|
22
|
+
"""
|
6
23
|
try:
|
7
24
|
# 初始化客户端
|
8
25
|
client = Ark(api_key="f0f8b460-c4ea-42a4-a951-5e2e454022ee")
|
9
26
|
|
27
|
+
# 构建消息列表
|
28
|
+
messages = []
|
29
|
+
|
30
|
+
# 添加上下文(如果有)
|
31
|
+
if context:
|
32
|
+
messages.extend(context)
|
33
|
+
|
34
|
+
# 添加当前查询
|
35
|
+
messages.append({"role": "user", "content": query})
|
36
|
+
|
37
|
+
# 设置默认参数
|
38
|
+
default_params = {
|
39
|
+
"model": model,
|
40
|
+
"messages": messages,
|
41
|
+
"max_tokens": kwargs.get("max_tokens", 2048),
|
42
|
+
"temperature": kwargs.get("temperature", 0.5)
|
43
|
+
}
|
44
|
+
|
10
45
|
# 调用聊天补全API
|
11
|
-
completion = client.chat.completions.create(
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
temperature=0.5 # 温度参数
|
18
|
-
)
|
19
|
-
|
20
|
-
# 返回AI生成的内容
|
21
|
-
return completion.choices[0].message.content
|
46
|
+
completion = client.chat.completions.create(**default_params)
|
47
|
+
|
48
|
+
# 获取响应内容
|
49
|
+
response = completion.choices[0].message.content
|
50
|
+
|
51
|
+
return response
|
22
52
|
|
23
53
|
except Exception as e:
|
24
|
-
return f"
|
54
|
+
return f"AI查询时出错: {str(e)}"
|
isrpa/utils.py
CHANGED
@@ -22,7 +22,6 @@ def getPath(user_name):
|
|
22
22
|
# address = os.environ.get("address", "192.168.12.249")
|
23
23
|
|
24
24
|
url = f"{address}/client/getPath"
|
25
|
-
print(url)
|
26
25
|
headers = {
|
27
26
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
28
27
|
}
|
@@ -30,10 +29,8 @@ def getPath(user_name):
|
|
30
29
|
data = {
|
31
30
|
'user_name': user_name
|
32
31
|
}
|
33
|
-
print(data)
|
34
32
|
response = requests.post(url, headers=headers, json=data)
|
35
33
|
if response.status_code != 200:
|
36
|
-
print("请求失败,状态码:", response.status_code)
|
37
34
|
return "failure"
|
38
35
|
return response.json()
|
39
36
|
|
@@ -49,7 +46,6 @@ def upload_file(file_path, dest_file, user_name):
|
|
49
46
|
|
50
47
|
# address = os.environ.get("address", "192.168.12.249")
|
51
48
|
url = f"{address}/client/noticeUpload"
|
52
|
-
print(url)
|
53
49
|
headers = {
|
54
50
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
55
51
|
}
|
@@ -59,7 +55,6 @@ def upload_file(file_path, dest_file, user_name):
|
|
59
55
|
'dest_file': dest_file,
|
60
56
|
'user_name': user_name
|
61
57
|
}
|
62
|
-
print(data)
|
63
58
|
requests.post(url, headers=headers, json=data)
|
64
59
|
|
65
60
|
|
@@ -73,7 +68,6 @@ def vCode(image: str, code_type, apiKey, secretKey):
|
|
73
68
|
:return:
|
74
69
|
"""
|
75
70
|
url = "https://ai.i-search.com.cn/ocr/v2/vCode"
|
76
|
-
print(url)
|
77
71
|
headers = {
|
78
72
|
'Content-Type': 'application/json', # 说明请求体是 JSON 格式
|
79
73
|
}
|
@@ -85,11 +79,9 @@ def vCode(image: str, code_type, apiKey, secretKey):
|
|
85
79
|
'apiKey': apiKey,
|
86
80
|
'secretKey': secretKey
|
87
81
|
}
|
88
|
-
print(data)
|
89
82
|
response = requests.post(url, headers=headers, json=data)
|
90
83
|
status_code = response.status_code
|
91
84
|
if status_code != 200:
|
92
|
-
print("请求失败,状态码:", status_code)
|
93
85
|
return {"error_msg": "failure", "error_code": status_code}
|
94
86
|
return response.json()
|
95
87
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
isrpa/OCR.py,sha256=nSDmVLo_z9GV7GUY57xBh2kumERG5_xtpUPxeF6ziQE,2509
|
2
|
+
isrpa/Template.py,sha256=UP1uovLvJzXEPGo_hzLrIYOu3vZP8Cf6m3G2hGzQ6XA,1958
|
3
|
+
isrpa/Template_Exception.py,sha256=an6eQ1NMB8a9R-J0yyMdwHIZcZeDtdV5f7fWKZQsZ3s,819
|
4
|
+
isrpa/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
5
|
+
isrpa/credentials.py,sha256=B9CKBgvik7U9YwwXIgtDb1jUfZuNcditLzyaL_-0arw,3342
|
6
|
+
isrpa/llm_chat.py,sha256=jTuK9wcm3X36V9lXuGuTCdNup_zi2NeG2GuYHzO7gm4,1541
|
7
|
+
isrpa/message.py,sha256=N0s6hMaC5S-Pi4EhwcSp-ngfBTBQyW6ymU9sI9dUSeE,11329
|
8
|
+
isrpa/utils.py,sha256=Du2_yQJlB-JBm6Y6a3kT74mOGCtM3XffyX_5_cFudRI,51213
|
9
|
+
isrpa-0.9.9.dist-info/METADATA,sha256=BV0HEf3Ixu5wLaOjR4GlbopVrgc5ZmGz_Vtmj1CvE3Q,511
|
10
|
+
isrpa-0.9.9.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
11
|
+
isrpa-0.9.9.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
|
12
|
+
isrpa-0.9.9.dist-info/RECORD,,
|
isrpa-0.9.7.dist-info/RECORD
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
isrpa/OCR.py,sha256=nSDmVLo_z9GV7GUY57xBh2kumERG5_xtpUPxeF6ziQE,2509
|
2
|
-
isrpa/Template.py,sha256=UP1uovLvJzXEPGo_hzLrIYOu3vZP8Cf6m3G2hGzQ6XA,1958
|
3
|
-
isrpa/Template_Exception.py,sha256=an6eQ1NMB8a9R-J0yyMdwHIZcZeDtdV5f7fWKZQsZ3s,819
|
4
|
-
isrpa/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
5
|
-
isrpa/credentials.py,sha256=Qgitrm2pKgA1E_iGPg12Qq2Ka52pgTQCBHnT2U62ZHs,3999
|
6
|
-
isrpa/llm_chat.py,sha256=lrufXl2JnnezXPF3FOMmmQFbqMTLjhCy7ujJTWeu460,863
|
7
|
-
isrpa/message.py,sha256=N0s6hMaC5S-Pi4EhwcSp-ngfBTBQyW6ymU9sI9dUSeE,11329
|
8
|
-
isrpa/utils.py,sha256=uPCb1A1vDB0nTlII2BJz9kS0amk7mvzVA7ilI-UYA8Q,51439
|
9
|
-
isrpa-0.9.7.dist-info/METADATA,sha256=Y_yaHUXMpR5uicuMfDZ1Mh88aQF_ol7-yiDl-lOdHn0,511
|
10
|
-
isrpa-0.9.7.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
11
|
-
isrpa-0.9.7.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
|
12
|
-
isrpa-0.9.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|