Skip to content

Commit

Permalink
refactor: support url and auth update on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
hanrw committed Apr 11, 2024
1 parent ce7c409 commit fe025e9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tddworks.openllm.api
package com.tddworks.openai.api

import com.tddworks.common.network.api.StreamChatResponse
import com.tddworks.common.network.api.StreamableRequest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tddworks.openllm.api
package com.tddworks.openai.api

import com.tddworks.common.network.api.StreamableRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tddworks.openllm.api
package com.tddworks.openai.api

/**
* Chat response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,13 @@ package com.tddworks.openai.api.chat.api
import kotlinx.serialization.Serializable

@Serializable
data class ChatCompletion(val id: String, val created: Long, val model: String, val choices: List<ChatChoice>)
data class ChatCompletion(val id: String, val created: Long, val model: String, val choices: List<ChatChoice>) {
companion object {
fun dummy() = ChatCompletion(
"chatcmpl-8Zu4AF8QMK3zFgdzXIPjFS4VkWErX",
1634160000,
"gpt-3.5-turbo",
listOf(ChatChoice.dummy())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class ChatCompletionChunk(
val choices: List<ChatChunk>,
) {
companion object {
fun fake() = ChatCompletionChunk(
fun dummy() = ChatCompletionChunk(
id = "fake-id",
`object` = "text",
created = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,10 @@ data class ChatCompletionRequest(
*
* @return A ComplicationRequest object with a single dummy message.
*/
fun dummy(): ChatCompletionRequest {
fun dummy(model: Model): ChatCompletionRequest {
return ChatCompletionRequest(
listOf(ChatMessage.UserMessage("dummy-content")),
listOf(ChatMessage.UserMessage("Hello! How can I assist you today?")),
model = model
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ data class ChatChoice(
* The reason why OpenAI stopped generating.
*/
@SerialName("finish_reason") val finishReason: FinishReason? = null,
)
) {
companion object {
fun dummy() = ChatChoice(
index = 0,
message = ChatMessage.SystemMessage("Hello! How can I assist you today?"),
finishReason = FinishReason.Stop
)
}
}

@Serializable
@JvmInline
Expand Down
File renamed without changes.

0 comments on commit fe025e9

Please sign in to comment.