-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab8e49
commit 2227379
Showing
11 changed files
with
123 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
core/src/commonMain/kotlin/com/xebia/functional/xef/llm/models/Messages.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.xebia.functional.xef.llm.models | ||
|
||
import com.xebia.functional.openai.generated.model.CompletionUsage | ||
|
||
data class MessagesWithUsage(val messages: List<String>, val usage: MessagesUsage?) | ||
|
||
data class MessageWithUsage(val message: String, val usage: MessagesUsage?) | ||
|
||
data class MessagesUsage(val completionTokens: Int, val promptTokens: Int, val totalTokens: Int) { | ||
companion object { | ||
operator fun invoke(usage: CompletionUsage) = | ||
MessagesUsage( | ||
completionTokens = usage.completionTokens, | ||
promptTokens = usage.promptTokens, | ||
totalTokens = usage.totalTokens | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
evaluator/src/main/kotlin/com/xebia/functional/xef/evaluator/models/TestModels.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
package com.xebia.functional.xef.evaluator.models | ||
|
||
import com.xebia.functional.xef.llm.models.MessageWithUsage | ||
import com.xebia.functional.xef.llm.models.MessagesUsage | ||
import kotlin.jvm.JvmSynthetic | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data class OutputDescription(val value: String) | ||
|
||
@Serializable | ||
data class OutputResponse(val description: OutputDescription, val value: String) { | ||
data class OutputResponse( | ||
val description: OutputDescription, | ||
val tokens: OutputTokens?, | ||
val value: String | ||
) { | ||
companion object { | ||
@JvmSynthetic | ||
suspend operator fun invoke( | ||
description: OutputDescription, | ||
block: suspend () -> String | ||
): OutputResponse = OutputResponse(description, block()) | ||
block: suspend () -> MessageWithUsage | ||
): OutputResponse { | ||
val response = block() | ||
return OutputResponse(description, response.usage?.let { OutputTokens(it) }, response.message) | ||
} | ||
} | ||
} | ||
|
||
@Serializable | ||
data class OutputTokens( | ||
val promptTokens: Int? = null, | ||
val completionTokens: Int? = null, | ||
val totalTokens: Int? = null | ||
) { | ||
companion object { | ||
@JvmSynthetic | ||
operator fun invoke(usage: MessagesUsage): OutputTokens = | ||
OutputTokens(usage.promptTokens, usage.completionTokens, usage.totalTokens) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.