Comments (4)
Oh great! Thank you for your cool hint on onnx!
from higlabo.
Please see ChatCompletionStreamWithUsageResult method in OpenAIPlayground.cs file.
GetUsageResult method is key method.
var p = new ChatCompletionsParameter();
p.AddUserMessage($"How to enjoy coffee");
p.Model = "gpt-4o";
p.Stream_Options = new
{
include_usage = true,
};
var result = new ChatCompletionStreamResult();
await foreach (string text in cl.ChatCompletionsStreamAsync(p, result, CancellationToken.None))
{
Console.Write(text);
}
Console.WriteLine();
Console.WriteLine();
var usage = result.GetUsageResult();
if (usage != null)
{
Console.WriteLine("------------------------");
Console.WriteLine("Prompt tokne: " + usage.Prompt_Tokens);
Console.WriteLine("Completion tokne: " + usage.Completion_Tokens);
Console.WriteLine("Total tokne: " + usage.Total_Tokens);
}
from higlabo.
Thank you! It works awesome as always. By the way, have you research the question of price optimisation of image recognition? For example I have pretty typical documents which I recognize with gpt-o4 model. It costs usually like this:
Prompt token: 1117
Completion token: 228
Total tokne: 1345
Which way would you suggest me to go to optimise it? I guess training own image to text model (for typical layouts) is the best way?
from higlabo.
The best way to reduce price is to use local LLM.
You can get various model on HuggingFace and you can use it by ONNX from C#.
I think that LLM will be more intelligence in this year, so it it worth to watch.
from higlabo.
Related Issues (20)
- Check if mail is bounced HOT 3
- HigLabo.Mapper Can not Convert Array To List HOT 6
- Generate code C# for call SQL User-defined Functions ? HOT 1
- Activate pop3 tls1.2 HOT 1
- Missing HigLabo.Core.EnumToLowerStringConverter Type when executing code HOT 3
- Unable to open the saved image file HOT 7
- Any implementation of OpenAI assistants API for old .net framework 4? HOT 2
- Assistants API with Azure OpenAI - Resource not found HOT 12
- Method not found: 'Boolean HigLabo.Core.ServerSentEventLine.IsEvent() HOT 8
- What is the best approach to add more context to the question HOT 5
- Temperature support (recently added) HOT 6
- AssistantDeltaObject deserialization error if Annotation contains file citations HOT 4
- Are you planning to add vector store usage for file search support? HOT 3
- Any way to avoid using local files in whisper transcription? HOT 2
- RSS library does not extract channel's `lastBuildDate` HOT 1
- RSS item should have multiple categories HOT 3
- RSS item should extract author from `<dc:creator>` element HOT 18
- Any way to make thread id live between OpenAIClient instances? (assistants api) HOT 4
- OpenAI Assistant - Attaching a file not working HOT 2
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 higlabo.