from pyChatGPT import ChatGPT import os def read_token(): session_token_text="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..rZTgbQYSLSN-fX8o.N74lAfJIiSxsXjb6I8EEIQscpXJpSXdTOfUmUTTeqnhRxmuVCuAz_lFcrk8_9H7Pk4dWGKQaxW4EViyWXfp8tgiuQJZJCMd9N-2mKouGIKQWxXYaaHnJwusalk1Opl2pjCWerIvWlRDC5kG5-C0iRrxNd3hgFoRURRBcQXm_Fk7B2TO6jIoVdGdpA61MbwesIAxn1NkgZYpxVTUc847a0LByWdx5r0PVgymxbOfidLtIdA3T6nPXnxjI1qkxiQH7Xts7II_GiNcRnQ69-686E_JW3PFmez-LhEZiSOYMriMbqdZh_szrtFIofZPW4mX6BzyTQODay4li5-0RCiarzbZId2fjbylFuq3z6TfTnCyhloYIG_h0fJ0JECWE6jKnEkIg--pdQwtnDqEYdfxm2m0iYSrxqpPioCiB2qN6s4sYLQ-u0G7dPc9zFN50V8tMfPHkoaIh7TGLoCJSuqe0cEs1x2wVVMDunmnVBMSdfKhF1NizInKZ9ojiL7fgrRggw-Rz0zXdHjMFfCI9n0ZaWM3AUZPJoB2ZUT24_bYjaMDce-2cdrhJQGYiMKSq2dK0xiyklKZ9_2naqShyAMkstDR7SHelsfesTn7zmQO2KxOMwyxwKSB8rTY3GCftIwItJRVCtxxE8z5-21joDa1sujixO8Fq2UGmZiq0CpY-5lpo_a3bUr-Ut1rNmN_1zukPdVfLiL-a9YoCWr7H8bDCerk54gFdArtUZ7kF47DzgxDcvSdtCho5H26h0OAkJ125cbHIrTiotoRpzsaUxtsqv-gsucYZfyTaTq76TwC8X0rpJPljK6hGfu9U_nC5u0QLVQfaINO1PR9IyzsFmgdYupM2ecvNdQY_1IzBGl1FVo5y2cr-eb-CzBZMxAU7lI7D1bsu8p3Vwyxg_pZ1S8uUtUwo9evWOc6vaDVct1J3HiAZ_rjl3iA3c7XsjyuoXAnRarS6pEVIN-HH91eF2DysNRgeCTaFnRdBx3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SyuS9DIpbAckLj_BlfOLsfBnSsRd1oNvj1VTQSqq_7nT0Bv1u0cMeQy_3WGPAAdHvi8GP_qFxS6XqYr8luQc7_KhMIytY2fEFJISjZRpRr1zOu3qYGAiSXx9Emd7NAvjY1v0cQn11-vqdlZRM1Qz7lY8bexnOkfjjKVBQ5otsJ9s7sR5LU._A5iHP30u_uJKApc_1-TLg" # with open("session_token.txt") as fd: # session_token = fd.read() return session_token_text def chat(text,session_tokenz): try: loaded_session_token = os.environ['Newkeyz'] session_token = read_token() api = ChatGPT(session_token) resp = api.send_message(text) api.refresh_auth() api.reset_conversation() xyz = resp['message'] except: api = ChatGPT(session_tokenz) resp = api.send_message(text) api.refresh_auth() api.reset_conversation() return xyz import gradio as gr gr.Interface( chat, [gr.Textbox(label = ' 输入问题: '), gr.Textbox(label = ' 如果失败,你可以填写自己的session-token')], outputs = gr.outputs.Textbox(type="text",label="ChatGPT 回复你了:"), title = "ChatGPT 中文", description= "").launch(debug = True)