Comments (1)
This is because if the token limit you set is exceeded during message output, ChatLengthException is automatically generated, tokens are emptied as much as ChatConfig.extra_token_margin (approximately 500 tokens) and then automatically retransmitted. This is inefficient because the number of queries sent to openai increases, but this method was adopted because the user does not have to worry about the token limit.
check the log And check how many times token limit exceeded
occurred.
except ChatLengthException:
api_logger.error("token limit exceeded")
if len(user_chat_context.user_message_histories) == len(user_chat_context.ai_message_histories):
deleted_while_overriding: int | None = await MessageManager.set_message_history_safely(
user_chat_context=user_chat_context,
role=ChatRoles.AI,
index=-1,
new_content=content_buffer.replace(ChatConfig.continue_message, "")
+ ChatConfig.continue_message,
update_cache=False,
extra_token_margin=ChatConfig.extra_token_margin,
)
if deleted_while_overriding is not None:
deleted_histories += deleted_while_overriding
else:
deleted_histories = await MessageManager.add_message_history_safely(
user_chat_context=user_chat_context,
role=ChatRoles.AI,
content=content_buffer,
update_cache=False,
extra_token_margin=ChatConfig.extra_token_margin,
)
continue
from llmchat.
Related Issues (20)
- Save embeddings metadata to MySQL HOT 2
- Overlap embeddings HOT 2
- Trash bin HOT 1
- Add minimum hardware requirement
- Token conservation HOT 2
- production fails on debian 11 HOT 1
- docker-compose-lan HOT 1
- Separate container for web HOT 6
- Fails on Docker swarm HOT 12
- Make qdrant collection name a constant HOT 2
- Chatroles.system default startup TMPL HOT 2
- Message prefix/suffix HOT 2
- Default system message HOT 7
- Modular architecture HOT 5
- Universal Sentence Encoder for embedding HOT 1
- New key before chatting is unnecessary
- [Feature Request] Support InternLM
- Can't login in web UI HOT 6
- How can I switch to local LLM engine HOT 3
- Fail to run api in docker HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llmchat.