缺少代码差异信息,无法生成具体的commit message。请提供code differences内容以便分析并生成符合Angular规范的提交信息。
当您提供代码差异后,我将按照以下格式生成: ``` <type>(<scope>): <subject> <body> ``` 其中type会根据更改类型选择(feat、fix、docs、style、refactor等),scope表示影响范围,subject简要描述变更内容,body详细说明修改内容。
This commit is contained in:
47
康康/Services/HealthExportDialogue.swift
Normal file
47
康康/Services/HealthExportDialogue.swift
Normal file
@@ -0,0 +1,47 @@
|
||||
import Foundation
|
||||
|
||||
struct HealthExportDialogueTurn: Identifiable, Hashable, Sendable {
|
||||
enum Role: String, Sendable {
|
||||
case user
|
||||
case assistant
|
||||
|
||||
var transcriptLabel: String {
|
||||
switch self {
|
||||
case .user: return String(appLoc: "患者")
|
||||
case .assistant: return String(appLoc: "康康")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let id: UUID
|
||||
var role: Role
|
||||
var text: String
|
||||
var createdAt: Date
|
||||
|
||||
init(role: Role, text: String, createdAt: Date = .now, id: UUID = UUID()) {
|
||||
self.id = id
|
||||
self.role = role
|
||||
self.text = text
|
||||
self.createdAt = createdAt
|
||||
}
|
||||
|
||||
static func user(_ text: String) -> HealthExportDialogueTurn {
|
||||
HealthExportDialogueTurn(role: .user, text: text)
|
||||
}
|
||||
|
||||
static func assistant(_ text: String) -> HealthExportDialogueTurn {
|
||||
HealthExportDialogueTurn(role: .assistant, text: text)
|
||||
}
|
||||
|
||||
static func transcript(from turns: [HealthExportDialogueTurn]) -> String {
|
||||
turns
|
||||
.compactMap { turn -> String? in
|
||||
let cleaned = turn.text
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
.replacingOccurrences(of: "\n", with: " ")
|
||||
guard !cleaned.isEmpty else { return nil }
|
||||
return "\(turn.role.transcriptLabel): \(cleaned)"
|
||||
}
|
||||
.joined(separator: "\n")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user