Closed Songjiadong closed 7 months ago
@Songjiadong you need to check the mysql encode method.
@SimFG question能存入中文,answer是乱码,不是mysql的编码问题,我想知道是否在往数据库存储的过程中json序列化没有ensure_ascii没有设置false,没有找到触发写入机制的地方
here is the code line of saving data: https://github.com/zilliztech/GPTCache/blob/acc20f05400dabdcde451194e9bb73b986747685/gptcache/adapter/adapter.py#L257
@SimFG 谢谢,我跟着你的代码跟踪了一下,应该是在langchain_community.cache.py的问题
handled_data = _dumps_generations(return_val)
put(prompt, handled_data, cache_obj=_gptcache)
或者在GPTCache的adapt/api.py 的put方法将其解码一下再传入,也可以解决问题
@SimFG 另外我还想资讯你一个问题,现有的缓存采用的是langchain全局的方式入库的,如果我想加入session我该如何操作,我看咱官网之前有LangChainLLMs
,但是使用报错
you may not be able to use the seesion function. Currently, langchan llms is not maintained because they update too quickly. So you may need to implement a session-like function outside yourself
Current Behavior
cache存入数据库中编码是16进制乱码不是汉字,我尝试用post_func 进行修改,跟踪输出是正确的汉字,但存入数据库中,依然是16进制数据
Expected Behavior
No response
Steps To Reproduce
No response
Environment
No response
Anything else?
No response