Jasminexixi commited on
Commit
98f08d5
·
verified ·
1 Parent(s): 7393080

Update 4.微调模型.py

Browse files
Files changed (1) hide show
  1. 4.微调模型.py +25 -20
4.微调模型.py CHANGED
@@ -1,20 +1,25 @@
1
- import openai
2
- from openai import OpenAI
3
- client = OpenAI(
4
- api_key="sk-efzevxcijheyfqsytcerxsdbxvfbwaeelhdafoqggfkqmtda", # 从https://cloud.siliconflow.cn/account/ak获取
5
- base_url="https://api.siliconflow.cn/v1"
6
- )
7
- #用户与大语言模型对话输入口
8
- messages = [
9
- {"role": "user", "content": "生成自动写诗的基于transformer架构的代码"},
10
- ]
11
-
12
- response = client.chat.completions.create(
13
- model="ft:LoRA/Qwen/Qwen2.5-7B-Instruct:d6788ch719ns73fkjprg:HAHA:ownnqofepdhkkexoivhi-ckpt_step_11",
14
- messages=messages,
15
- stream=True,
16
- max_tokens=4096
17
- )
18
-
19
- for chunk in response:
20
- print(chunk.choices[0].delta.content, end='')
 
 
 
 
 
 
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()