make install
or
pip install git+https://github.com/doublewinter0/xfyun-xinghuo
export IFLY_ACCOUNT=foo # 讯飞账号
export IFLY_PWD=bar # 讯飞密码
After
两天半
of packet capture research, I found that this token should be generated by calling a third-party js. It is a necessary parameter of the session interface and has a validity period of half an hour; in other words, as long as this parameter is passed in a certain session request, within half an hour You can make another request without passing this parameter. The token parameter will be updated every time the Web request is made, but during my test, it was possible to fix the parameter value, even for different accounts. So I guess this may be an encrypted base64 sequence of a fixed value that has nothing to do with the account, and is idempotent.
If you also have special packet capture skills, then I recommend that you use the GtToken you captured; I also provide a default GtToken, but I cannot guarantee that it will always be valid.
Here you need to set an environment variable GT_TOKEN_FILE
, which points to the file path where GtToken is saved, and the content of the file is the value of GtToken. for example:
export GT_TOKEN_FILE=/tmp/.GtToken
import asyncio
from iflygpt . core import ChatBot
async def main ():
bot = ChatBot ( 'foo' )
bot . login ()
print ( await bot . chat ( 123456 , '介绍一下西安市' , bot . gt_token )) # 123456 只是示例,需替换为你的会话 id
if __name__ == '__main__' :
asyncio . run ( main ())
iflygpt.exp.IflyGPTError: [geeError]
: GtToken is invalidIf our project is helpful to you, please give me a ️!
This project is for learning and communication purposes only. Commercial use is strictly prohibited, otherwise you will be responsible for the consequences.