fix: stream response model name and cost
This commit is contained in:
@@ -32,7 +32,6 @@ export default function ChatBOX(props: {
|
|||||||
|
|
||||||
const messagesEndRef = createRef();
|
const messagesEndRef = createRef();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("ref", messagesEndRef);
|
|
||||||
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [showRetry, showGenerating, generatingMessage]);
|
}, [showRetry, showGenerating, generatingMessage]);
|
||||||
|
|
||||||
@@ -57,6 +56,7 @@ export default function ChatBOX(props: {
|
|||||||
const allChunkMessage: string[] = [];
|
const allChunkMessage: string[] = [];
|
||||||
setShowGenerating(true);
|
setShowGenerating(true);
|
||||||
for await (const i of client.processStreamResponse(response)) {
|
for await (const i of client.processStreamResponse(response)) {
|
||||||
|
chatStore.responseModelName = i.model;
|
||||||
responseTokenCount += 1;
|
responseTokenCount += 1;
|
||||||
allChunkMessage.push(i.choices[0].delta.content ?? "");
|
allChunkMessage.push(i.choices[0].delta.content ?? "");
|
||||||
setGeneratingMessage(allChunkMessage.join(""));
|
setGeneratingMessage(allChunkMessage.join(""));
|
||||||
@@ -79,6 +79,7 @@ export default function ChatBOX(props: {
|
|||||||
cost += sum * (models[chatStore.responseModelName]?.price?.prompt ?? 0);
|
cost += sum * (models[chatStore.responseModelName]?.price?.prompt ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("cost", cost);
|
||||||
chatStore.cost += cost;
|
chatStore.cost += cost;
|
||||||
addTotalCost(cost);
|
addTotalCost(cost);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user