Update 4.微调模型.py
Browse files
4.微调模型.py
CHANGED
|
@@ -1,20 +1,25 @@
|
|
| 1 |
-
import openai
|
| 2 |
-
from openai import OpenAI
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
from openai import OpenAI
|
| 3 |
+
while True:
|
| 4 |
+
a=input()
|
| 5 |
+
client = OpenAI(
|
| 6 |
+
api_key="sk-efzevxcijheyfqsytcerxsdbxvfbwaeelhdafoqggfkqmtda", # 从https://cloud.siliconflow.cn/account/ak获取
|
| 7 |
+
base_url="https://api.siliconflow.cn/v1"
|
| 8 |
+
)
|
| 9 |
+
#用户与大语言模型对话输入口
|
| 10 |
+
messages = [
|
| 11 |
+
{"role": "user", "content": a },
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
response = client.chat.completions.create(
|
| 15 |
+
model="ft:LoRA/Qwen/Qwen2.5-7B-Instruct:d6788ch719ns73fkjprg:HAHA:ownnqofepdhkkexoivhi-ckpt_step_11",
|
| 16 |
+
messages=messages,
|
| 17 |
+
stream=True,
|
| 18 |
+
max_tokens=4096
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
for chunk in response:
|
| 22 |
+
print(chunk.choices[0].delta.content, end='');
|
| 23 |
+
print('\n')
|
| 24 |
+
if a=="结束对话":
|
| 25 |
+
exit()
|