You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I verified that the issue exists in the latest chatgpt release
Verify webapp is working
I verify that the ChatGPT webapp is working properly for this account.
Environment details
Typescript, Visual Studio Code
Describe the Bug
Not a bug, but hoping to get some guidance.
Not very familiar with Typescript, but hoping to make a couple of changes to pre-existing code using this awesome ChatGPT API.
I want to grab and store the token usage for each prompt and response to and from openai. But idk how to grab the token response. The code snippet I have is below:
public async callOpenAI(prompt: string, messageId: string): Promise<any> {
console.log('mid:' + messageId)
if (messageId == '') {
const res = await oraPromise(this.api.sendMessage(prompt),
{
text: prompt,
})
return res
} else {
const res = await oraPromise(
this.api.sendMessage(prompt, {
parentMessageId: messageId
}),
{
text: prompt,
}
)
return res
}
}
}
Would be great if someone could tell me how I can edit/add to this so I can get the token usage. I read through some of the issues and someone recommended looking at 'details'? Where would I add this because I tried several ways doesn't seem to work.
Many thanks!
The text was updated successfully, but these errors were encountered:
Verify latest release
chatgpt
releaseVerify webapp is working
Environment details
Typescript, Visual Studio Code
Describe the Bug
Not a bug, but hoping to get some guidance.
Not very familiar with Typescript, but hoping to make a couple of changes to pre-existing code using this awesome ChatGPT API.
I want to grab and store the token usage for each prompt and response to and from openai. But idk how to grab the token response. The code snippet I have is below:
Would be great if someone could tell me how I can edit/add to this so I can get the token usage. I read through some of the issues and someone recommended looking at 'details'? Where would I add this because I tried several ways doesn't seem to work.
Many thanks!
The text was updated successfully, but these errors were encountered: