isrpa 0.9.6__py3-none-any.whl → 0.9.8__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 +1 -1
- isrpa/llm_chat.py +54 -0
- {isrpa-0.9.6.dist-info → isrpa-0.9.8.dist-info}/METADATA +1 -1
- {isrpa-0.9.6.dist-info → isrpa-0.9.8.dist-info}/RECORD +6 -5
- {isrpa-0.9.6.dist-info → isrpa-0.9.8.dist-info}/WHEEL +0 -0
- {isrpa-0.9.6.dist-info → isrpa-0.9.8.dist-info}/top_level.txt +0 -0
isrpa/credentials.py
CHANGED
isrpa/llm_chat.py
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
from typing import Optional, Dict, Any, List, Union
|
2
|
+
from volcenginesdkarkruntime import Ark
|
3
|
+
|
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
|
+
"""
|
23
|
+
try:
|
24
|
+
# 初始化客户端
|
25
|
+
client = Ark(api_key="f0f8b460-c4ea-42a4-a951-5e2e454022ee")
|
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
|
+
|
45
|
+
# 调用聊天补全API
|
46
|
+
completion = client.chat.completions.create(**default_params)
|
47
|
+
|
48
|
+
# 获取响应内容
|
49
|
+
response = completion.choices[0].message.content
|
50
|
+
|
51
|
+
return response
|
52
|
+
|
53
|
+
except Exception as e:
|
54
|
+
return f"AI查询时出错: {str(e)}"
|
@@ -2,10 +2,11 @@ isrpa/OCR.py,sha256=nSDmVLo_z9GV7GUY57xBh2kumERG5_xtpUPxeF6ziQE,2509
|
|
2
2
|
isrpa/Template.py,sha256=UP1uovLvJzXEPGo_hzLrIYOu3vZP8Cf6m3G2hGzQ6XA,1958
|
3
3
|
isrpa/Template_Exception.py,sha256=an6eQ1NMB8a9R-J0yyMdwHIZcZeDtdV5f7fWKZQsZ3s,819
|
4
4
|
isrpa/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
5
|
-
isrpa/credentials.py,sha256=
|
5
|
+
isrpa/credentials.py,sha256=Qgitrm2pKgA1E_iGPg12Qq2Ka52pgTQCBHnT2U62ZHs,3999
|
6
|
+
isrpa/llm_chat.py,sha256=jTuK9wcm3X36V9lXuGuTCdNup_zi2NeG2GuYHzO7gm4,1541
|
6
7
|
isrpa/message.py,sha256=N0s6hMaC5S-Pi4EhwcSp-ngfBTBQyW6ymU9sI9dUSeE,11329
|
7
8
|
isrpa/utils.py,sha256=uPCb1A1vDB0nTlII2BJz9kS0amk7mvzVA7ilI-UYA8Q,51439
|
8
|
-
isrpa-0.9.
|
9
|
-
isrpa-0.9.
|
10
|
-
isrpa-0.9.
|
11
|
-
isrpa-0.9.
|
9
|
+
isrpa-0.9.8.dist-info/METADATA,sha256=LWf7tYP1P5yEyX8DHayHPmQgV8W_Z2fPZzufCbILKAU,511
|
10
|
+
isrpa-0.9.8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
11
|
+
isrpa-0.9.8.dist-info/top_level.txt,sha256=J5HJbtR2WAeKnW1rrpkiuapwnlswv3RgM-riyZD87o0,6
|
12
|
+
isrpa-0.9.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|