nfls (password as usual)

直接跑

终端 python3 [文件名]

#python 3.8.10

import os
import requests
import base64
import time
headers = {
    'Accept': '*/*',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Cookie': '__jsluid_h=ccf419d55fa290539ca2493ed334592d; csrfToken=lLG4pgDMZuP4CecslsrYoXuP',
    'Pragma': 'no-cache',
    'Referer': 'http://www.nfls.com.cn:10448/home',
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36' \
}
def main():
    std_io=True            #是否开启控制台输入输出
    default_folder=True    #是否开启默认读写路径(开启后请在 text 文件内输入内容,在 result 文件内获取内容,若没有请自行创建)
    multi_reply=True      #是否开启重复询问(开启此选项需要关闭文件 IO)
    tip=True              #是否显示提示语

    sentence=''
    ofile=''
    if std_io==False and multi_reply==True:
        print("Error: Cannot Open File_io and multi_reply at the same time / 请关闭文件 IO 或重复询问")
        exit(1)
    while True:
        if std_io==True:
            if tip==True:
                sentence=input('请输入语句:')
            else:
                sentence=input('You:')
        elif default_folder==True:
            with open('./text','r') as f:
                sentence=f.read()
            ofile='./result'
        else:
            file=input('读取文件路径:')
            with open(file, 'r') as f:
                sentence=f.read()
            ofile=input('输出文件路径:')
        if tip==True:
            print("请求已发送,根据 GPT 回复长度,可能有半分钟左右的延时,请不要频繁拉取结果")
        payload = {
            "model": "Qwen/Qwen2-VL-7B-Instruct-GPTQ-Int8",
            "messages": [
                {"role": "system", "content": sentence},
            ],
            "temperature": 0.7,
            "top_p": 0.8,
            "repetition_penalty": 1.05,
            "max_tokens": 1024
        }
        response = requests.post('http://www.nfls.com.cn:10448/v1/chat/completions', json=payload, headers=headers)
        if(response.status_code != 200):
            print(response.content)
        response_json = response.json()
        print('')
        if std_io==True:
            print("GPT:")
            print(response_json['choices'][0]['message']['content'] + '\n')
        else:
            with open(ofile,'w') as f:
                f.write(response_json['choices'][0]['message']['content'] + '\n')
        if multi_reply==False:
            if tip==True:
                print("回复已完成")
            break
if __name__ == '__main__':
    main()
posted @ 2024-11-26 06:30  HaneDaniko  阅读(16)  评论(1编辑  收藏  举报