Update README.md
Browse files
README.md
CHANGED
@@ -13,6 +13,141 @@ tags:
|
|
13 |
- qwen2
|
14 |
- sft
|
15 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
### Training hyperparameters
|
18 |
The following hyperparameters were used during training:
|
|
|
13 |
- qwen2
|
14 |
- sft
|
15 |
---
|
16 |
+
### Python demo
|
17 |
+
User: 给我写一个Python代码用于实现建立ES索引,给出示例代码</br>
|
18 |
+
Assistant: 以下是一个简单的Python代码示例,用于实现建立ES(Elasticsearch)索引:
|
19 |
+
|
20 |
+
```python
|
21 |
+
from elasticsearch import Elasticsearch
|
22 |
+
|
23 |
+
# 创建Elasticsearch客户端
|
24 |
+
es = Elasticsearch()
|
25 |
+
|
26 |
+
# 创建索引
|
27 |
+
def create_index(index_name):
|
28 |
+
# 创建索引映射
|
29 |
+
mapping = {
|
30 |
+
"mappings": {
|
31 |
+
"properties": {
|
32 |
+
"name": {"type": "text"},
|
33 |
+
"age": {"type": "integer"}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
# 创建索引
|
39 |
+
es = es.create(index=index_name, body=mappinging)
|
40 |
+
|
41 |
+
# 打印结果
|
42 |
+
print("创建索引结果:")
|
43 |
+
print(res)
|
44 |
+
|
45 |
+
# 删除索引
|
46 |
+
def delete_index(index_name):
|
47 |
+
# 删除索引
|
48 |
+
res = es.delete(index=index_name)
|
49 |
+
|
50 |
+
# 打印结果
|
51 |
+
print("删除索引结果")
|
52 |
+
print(res)
|
53 |
+
|
54 |
+
# 更新索引
|
55 |
+
def update_index(index_name, doc_type, id, doc):
|
56 |
+
# 更新索引
|
57 |
+
res = es.update(index=index_name, doc_type=doc_type, id=id, body=doc)
|
58 |
+
|
59 |
+
# 打印结果
|
60 |
+
print("更新索引结果")
|
61 |
+
print(res)
|
62 |
+
|
63 |
+
# 插入索引
|
64 |
+
def insert_index(index_name, doc_type, id, doc):
|
65 |
+
# 插入索引
|
66 |
+
res = es.index(index=index_name, doc_type=doc_type, id=id, body=doc)
|
67 |
+
|
68 |
+
# 打印结果
|
69 |
+
print("插入索引结果")
|
70 |
+
print(res)
|
71 |
+
|
72 |
+
# 查询索引
|
73 |
+
def query_index(index_name, doc_type, id):
|
74 |
+
# 查询索引
|
75 |
+
res = es.get(index=index_name, doc_type=doc_type, id=id)
|
76 |
+
|
77 |
+
# 打印结果
|
78 |
+
print("查询索引结果")
|
79 |
+
print(res)
|
80 |
+
|
81 |
+
# 创建索引
|
82 |
+
create_index("my_index")
|
83 |
+
|
84 |
+
# 查询索引
|
85 |
+
query_index("my_index", "my_type", "1")
|
86 |
+
|
87 |
+
# 插入索引
|
88 |
+
insert_index("my_index", "my_type", "1", {"name": "John", "age": 30})
|
89 |
+
|
90 |
+
# 更新索引
|
91 |
+
update_index("my_index", "my_type", "1", {"doc": "John has updated his profile."})
|
92 |
+
|
93 |
+
# 删除索引
|
94 |
+
delete_index("my_index")
|
95 |
+
```
|
96 |
+
|
97 |
+
注意: 以上代码只是一个基本示例,实际使用时需要根据具体需求进行修改和 调整。例如,你可能需要使用
|
98 |
+
|
99 |
+
|
100 |
+
User: 写一个Python代码用于实现扫描固定目录下的,指定文件,我将输入文件名和目录,如果在每日的8点没有生成文件,则通过xml方式调用短信接口SM001发通知。</br>
|
101 |
+
Assistant: 以下是一个Python代码示例,用于实现扫描固定目录下的指定文件。如果在每日的8点没有生成文件,则通过XML方式调用短信接口SM001发通知。
|
102 |
+
|
103 |
+
```python
|
104 |
+
import os
|
105 |
+
import datetime
|
106 |
+
import xml.etree.ElementTree as ET
|
107 |
+
import requests
|
108 |
+
|
109 |
+
# 输入文件名和 目录
|
110 |
+
file_name = "example.txt"
|
111 |
+
directory = "/path/to/directory/"
|
112 |
+
|
113 |
+
# 检查文件是否存在
|
114 |
+
def check_file_exists(file_name, directory):
|
115 |
+
return os.path.isfile(os.path.join(directory, file_name))
|
116 |
+
|
117 |
+
# 检查是否为8点
|
118 |
+
def is_it_eight():
|
119 |
+
return datetime.datetime.now().hour == 8
|
120 |
+
|
121 |
+
# 发送短信
|
122 |
+
def send_sms(message):
|
123 |
+
# 这里需要你设置短信接口SM001的API接口和 �key
|
124 |
+
url = "http://sms.com/api/send"
|
125 |
+
data = {"message": message}
|
126 |
+
response = requests.post(url, data=data)
|
127 |
+
return response
|
128 |
+
|
129 |
+
# 主程序
|
130 |
+
def main():
|
131 |
+
# 检查文件是否存在
|
132 |
+
if check_file_exists(file_name, directory):
|
133 |
+
# 文件存在,不发送短信
|
134 |
+
print("文件存在,不发送短信")
|
135 |
+
else else:
|
136 |
+
# 文件不存在,发送短信
|
137 |
+
if is_it_eight():
|
138 |
+
# 在是8点,发送短信
|
139 |
+
message = f"文件{file_name}在{directory}目录下不存在,请检查"
|
140 |
+
send_sms(message)
|
141 |
+
else else:
|
142 |
+
# 不是8点,不发送短信
|
143 |
+
print("不是8点,不发送短信")
|
144 |
+
|
145 |
+
if __name__ == "__main__":
|
146 |
+
main()
|
147 |
+
```
|
148 |
+
|
149 |
+
注意: 以上代码只是一个基本示例,实际使用时需要根据具体需求进行修改和 调整。例如,你可能需要使用真实的API接口,真实的的短信接口key等.
|
150 |
+
|
151 |
|
152 |
### Training hyperparameters
|
153 |
The following hyperparameters were used during training:
|