Add custom MCP profiles and reusable workspace libraries
This commit is contained in:
@@ -285,8 +285,10 @@ struct CompatibleEndpoint: InferenceProvider {
|
||||
let delta: Piece?
|
||||
let finish_reason: String?
|
||||
}
|
||||
struct Usage: Decodable { let completion_tokens: Int? }
|
||||
let error: Failure?
|
||||
let choices: [Choice]?
|
||||
let usage: Usage?
|
||||
}
|
||||
|
||||
func models() async throws -> [String] {
|
||||
@@ -317,6 +319,9 @@ struct CompatibleEndpoint: InferenceProvider {
|
||||
if payload.isEmpty { continue }
|
||||
let frame = try JSONDecoder().decode(Frame.self, from: Data(payload.utf8))
|
||||
if let error = frame.error { throw StudioError(error.message) }
|
||||
if let tokens = frame.usage?.completion_tokens, tokens >= 0 {
|
||||
continuation.yield(.metrics(ProviderMetrics(tokens: tokens, seconds: 0)))
|
||||
}
|
||||
guard let choice = frame.choices?.first else { continue }
|
||||
if choice.finish_reason == "tool_calls" || !(choice.delta?.tool_calls ?? []).isEmpty {
|
||||
continuation.yield(.committed)
|
||||
|
||||
Reference in New Issue
Block a user