USDT(Ethereum)
: 0xbef5adf343f46b79d408be6f527a1bec27bdd533
USDT(TRON)
: TCZazBQV4TtuZutGixN5LM1X1bC9bRy9JK
阿尔多泰bot在telegram上的实现
License: MIT License
aldotai-tg/aldotai_tg/plugin/ChatGPT.py
Lines 35 to 36 in 035e38f
此处可增加判断报错类型,例如:
try:
pass # Impl: OpenAI ChatGPT
except openai.error.OpenAIError as e:
if "maximum context length" in (e := str(e)):
# Exc: 超出最多 Token 限制
pass
return ...
超出最多 Token 限制时可尝试依次 pop()
内存中的对话数据,随后重新发起请求,该情况下一般无需 sleep
,可能的 impl 如下:
data_set: dict = {}
def pop_head():
# 从 data_set 中依次移除对话,保留 {"role": "system"}
pass
async def chat(*args, **kwargs):
try:
pass # Impl: OpenAI ChatGPT
except openai.error.OpenAIError as e:
if "maximum context length" in (e := str(e)):
pop_head()
return await chat(*args, **kwargs)
return ... # Impl: Handle other errors
需要注意的是,此处仅为大致思路,实际开发时建议加入 retries
等参数以防止出现过多重试。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.