xp3-tool 1.0__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.
- xp3_tool/__init__.py +8 -0
- xp3_tool/xp3_tool.py +35 -0
- xp3_tool-1.0.dist-info/METADATA +21 -0
- xp3_tool-1.0.dist-info/RECORD +6 -0
- xp3_tool-1.0.dist-info/WHEEL +5 -0
- xp3_tool-1.0.dist-info/top_level.txt +1 -0
xp3_tool/__init__.py
ADDED
xp3_tool/xp3_tool.py
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
def uuid(length=16):
|
2
|
+
chars = string.ascii_letters + string.digits
|
3
|
+
return ''.join(random.choice(chars) for _ in range(length))
|
4
|
+
|
5
|
+
class CallAi:
|
6
|
+
def __init__(self,api_key,base_url,model=None):
|
7
|
+
self.api_key = api_key
|
8
|
+
self.base_url = base_url
|
9
|
+
self.client = OpenAI(
|
10
|
+
api_key = api_key,
|
11
|
+
base_url= base_url,
|
12
|
+
)
|
13
|
+
self.model = model if model else 'qwen-plus'
|
14
|
+
self._prompt = ""
|
15
|
+
self.inquiry = ""
|
16
|
+
|
17
|
+
@property
|
18
|
+
def prompt(self):
|
19
|
+
return self._prompt
|
20
|
+
|
21
|
+
@prompt.setter
|
22
|
+
def prompt(self,content):
|
23
|
+
self._prompt = content
|
24
|
+
|
25
|
+
def chat(self,text,top_p = 0.9, temperature = 0.7):
|
26
|
+
completion = self.client.chat.completions.create(
|
27
|
+
model= self.model,
|
28
|
+
messages=[
|
29
|
+
{'role': 'system', 'content': f'{self._prompt}'},
|
30
|
+
{'role': 'user', 'content': text}],
|
31
|
+
temperature = temperature,
|
32
|
+
top_p = top_p
|
33
|
+
)
|
34
|
+
reply = completion.choices[0].message.content
|
35
|
+
return reply
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: xp3_tool
|
3
|
+
Version: 1.0
|
4
|
+
Summary: xp_t3_tool
|
5
|
+
Home-page:
|
6
|
+
Author: XuPeng
|
7
|
+
Author-email: xupeng23456@126.com
|
8
|
+
License: MIT
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
15
|
+
Requires-Python: >=3.10.0
|
16
|
+
Description-Content-Type: text/markdown
|
17
|
+
Requires-Dist: openai
|
18
|
+
Requires-Dist: pandas
|
19
|
+
|
20
|
+
|
21
|
+
本模块提供了一个简单的 CallAi 类,用于与 OpenAI 兼容的 API 服务进行交互,支持设置提示词并发送对话请求。同时包含一个随机字符串生成工具函数,可用于生成指定长度的字母数字混合字符串。
|
@@ -0,0 +1,6 @@
|
|
1
|
+
xp3_tool/__init__.py,sha256=4ZGiCQFVB2PMhAw-R46lBT8cwsblQFrMdyrt9zZh0tQ,102
|
2
|
+
xp3_tool/xp3_tool.py,sha256=T0LmrQ9N7Q_LMXKVywFqw5281CSokEDtPNOoNDtMRPc,1090
|
3
|
+
xp3_tool-1.0.dist-info/METADATA,sha256=y8tq9rB5m1jbgBx7G-8S6XIv1tvDdKOzN18joDF7SUQ,869
|
4
|
+
xp3_tool-1.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
5
|
+
xp3_tool-1.0.dist-info/top_level.txt,sha256=-ZymY_DANWiYTM4HO3wt5TzrWmCz4QYuIOeMBZDWSvM,9
|
6
|
+
xp3_tool-1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
xp3_tool
|