lzell / AIProxySwift

Client for AIProxy
https://www.aiproxy.pro
73 stars 9 forks source link

Need usage object in OpenAIChatCompletionRequestBody response model of OpenAI module #43

Closed fizz-viva closed 2 months ago

fizz-viva commented 2 months ago

"usage": { "completion_tokens" = 61; "completion_tokens_details" = { "reasoning_tokens" = 0; }; "prompt_tokens" = 94; "total_tokens" = 155; }

Can we get the usage object in the response model please?

lzell commented 2 months ago

@fizz-viva this is now available on the main branch and in AIProxySwift release 0.24.0. Please see this PR for usage instructions: https://github.com/lzell/AIProxySwift/pull/45

Thanks for the feedback!

fizz-viva commented 2 months ago

@lzell ah, great. Thanks a lot.

fizz-viva commented 2 months ago

`public struct OpenAIChatUsage: Decodable { /// Number of tokens in the generated completion. let completionTokens: Int?

/// Number of tokens in the prompt.
let promptTokens: Int?

/// Total number of tokens used in the request (prompt + completion).
let totalTokens: Int?

/// Breakdown of tokens used in a completion.
let completionTokensDetails: Details?

private enum CodingKeys: String, CodingKey {
    case completionTokens = "completion_tokens"
    case promptTokens = "prompt_tokens"
    case totalTokens = "total_tokens"
    case completionTokensDetails = "completion_tokens_details"
}

}`

Hey @lzell did you forget to make properties public to access outside of the package? Please have a look and make them accessible publicly.

lzell commented 2 months ago

@fizz-viva whoops! Fixed now on main and version v0.24.1