File tree Expand file tree Collapse file tree 2 files changed +12
-26
lines changed
Expand file tree Collapse file tree 2 files changed +12
-26
lines changed Original file line number Diff line number Diff line change @@ -99,19 +99,19 @@ startListening({
9999 // saving to store agent_usage counter from the backend, only one chunk has this field.
100100 const { payload } = action;
101101
102- if ("refact_agent_request_available" in payload) {
103- const agentUsageCounter = getAgentUsageCounter(payload);
104-
105- dispatch(updateAgentUsage(agentUsageCounter ?? null));
106- }
107-
108- if ("refact_agent_max_request_num" in payload) {
109- const maxFreeAgentUsage = getMaxFreeAgentUsage(payload);
110- dispatch(updateMaxAgentUsageAmount(maxFreeAgentUsage));
111- }
112-
113102 if (isChatResponseChoice(payload)) {
114- const { usage } = payload;
103+ const {
104+ usage,
105+ refact_agent_max_request_num,
106+ refact_agent_request_available,
107+ } = payload;
108+ const actions = [
109+ updateAgentUsage(refact_agent_request_available),
110+ updateMaxAgentUsageAmount(refact_agent_max_request_num),
111+ ];
112+
113+ actions.forEach((action) => dispatch(action));
114+
115115 if (usage) {
116116 dispatch(setThreadUsage({ chatId: payload.id, usage }));
117117 }
Original file line number Diff line number Diff line change @@ -129,20 +129,6 @@ function replaceLastUserMessage(
129129 return result.concat([userMessage]);
130130}
131131
132- export function getAgentUsageCounter(response: ChatResponse): number | null {
133- if (isChatResponseChoice(response)) {
134- return response.refact_agent_request_available;
135- }
136- return null;
137- }
138-
139- export function getMaxFreeAgentUsage(response: ChatResponse): number {
140- if (isChatResponseChoice(response)) {
141- return response.refact_agent_max_request_num;
142- }
143- return 0;
144- }
145-
146132export function formatChatResponse(
147133 messages: ChatMessages,
148134 response: ChatResponse,
You can’t perform that action at this time.
0 commit comments