I am trying out the semantic kernel in C# for a project. I am using the ChatCompletionService with Azure OpenAI and a few simple plugins that I created. I am not able to figure out how to get the token usage for a query. Any help would be appreciated. For example, in this solution that microsoft has, is there a way to get the token usage after each question (GetStreamingChatMessageContentsAsync)? One link I found was about logging in open telmetry standard. But it does not log the token usage. Any help is appreciated.
Get the token usage from semantic kernel C#
526 Views Asked by buchipper At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in AZURE-OPENAI
- QA_Chain from Langchain does not recognize Azure OpenAi engine' or 'deployment_id
- Send out extra headers when using AzureChatOpenAI in Langchain python
- Azure OpenAI - Cache the question and answer
- Token usage of Content Filtered messages in Azure OpenAI Services
- AzureOpenAIModelFactory StreamingChatCompletions throws System NullReferenceException
- Is there a way via API to know what AI model the specified Azure Open AI endpoint (deployment) is configured to use?
- Download all chat history programmatically
- Azure OpenAI LangChain - (InvalidField) The vector field 'content_vector' must have the property 'vectorSearchConfiguration' set
- What is the request-per-minute rate limit for Azure openAI models for gpt-3.5-turbo?
- I am trying to make a docs question answering program with AzureOpenAI and Langchain
- Azure OpenAi Limit data to your content button not working as expected
- Azure OpenAI on your data - System message usage
- Azure Cognitive Search multiple sql tables
- Indexer in Azure Cognitive Search service not being created
- azure openai cognitive search data architecture for RAG
Related Questions in SEMANTIC-KERNEL
- SemanticKernel throws "Unrecognized request argument supplied: tools"
- How to intercept generated prompts of kernel in SemanticKernel?
- Python chatbot using semantic-kernel
- Azure Semantic Kernel Example with Embeddings and Pinecone
- StepWisePlanner is not compatible with the latest version of Microsoft.SemanticKernel (1.0.1)
- Semantic Kernel RAG Pattern Azure Open AI - Only Query Against My Data
- Semantic Kernel Version 1.0.1
- Semantic-Kernel throwing error when calling local Plugin
- Get the token usage from semantic kernel C#
- System.TypeLoadException: 'Could not load type 'Microsoft.SemanticKernel.Http.HttpOperationException
- Method not found exception when using Semantic Kernel in an Azure Functions app
- How to Test GPT-4 LLM Response in a C# .NET Application Without Using Prompt Flow?
- Loading a Huggingface Model with Microsofts Semantic Kernel in C# / VB.NET
- Enabling Cognitive Search in Microsoft Chat Copilot / Semantic Kernel
- Semantic Kernel: The integration of chat and text completion services into the context does not utilize the models as expected
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Considering the solution link you referenced in your question, one possible way to get this information is by making use of
Metadataproperty ofFunctionResult. Token information is contained inUsagekey in there which is of typeCompletionsUsage.Your code would be something like:
Please note that this information is not available just yet for streaming responses. For more details, please see this issue on GitHub: https://github.com/microsoft/semantic-kernel/issues/4691.