Skip to content

Commit

Permalink
feat(BE-215): ollama fim api support
Browse files Browse the repository at this point in the history
 - OllamaOpenAIProvider support ollama generate api
 - code clean
 - add ut
  • Loading branch information
hanrw committed Jun 19, 2024
1 parent e181a2e commit 6dc1b4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import app.cash.turbine.test
import com.tddworks.anthropic.api.messages.api.*
import com.tddworks.anthropic.api.mockHttpClient
import com.tddworks.common.network.api.ktor.internal.DefaultHttpRequester
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
import org.junit.jupiter.api.Assertions.assertEquals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ value class OllamaModel(val value: String) {
val LLAMA2 = OllamaModel("llama2")
val LLAMA3 = OllamaModel("llama3")
val CODE_LLAMA = OllamaModel("codellama")
val DEEPSEEK_CODER = OllamaModel("deepseek-coder:6.7b")
val DEEPSEEK_CODER = OllamaModel("deepseek-coder:6.7b-base")
val MISTRAL = OllamaModel("mistral")
val availableModels = listOf(LLAMA2, LLAMA3, CODE_LLAMA, MISTRAL, DEEPSEEK_CODER)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class OllamaModelTest {

@Test
fun `should return correct latest API model name`() {
assertEquals("deepseek-coder:6.7b", OllamaModel.DEEPSEEK_CODER.value)
assertEquals("deepseek-coder:6.7b-base", OllamaModel.DEEPSEEK_CODER.value)
assertEquals("llama3", OllamaModel.LLAMA3.value)
assertEquals("llama2", OllamaModel.LLAMA2.value)
assertEquals("codellama", OllamaModel.CODE_LLAMA.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,29 @@ import com.tddworks.ollama.api.json.JsonLenient
import com.tddworks.ollama.api.prettyJson
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import kotlin.test.assertFalse

class OllamaGenerateResponseTest {

@Test
fun `should retrun dummy OllamaGenerateResponse`() {
// When
val response = OllamaGenerateResponse.dummy()

// Then
assertFalse(response.done)
assertEquals("some-model", response.model)
assertEquals("createdAt", response.createdAt)
assertEquals("response", response.response)
assertEquals("doneReason", response.doneReason)
assertEquals(10, response.evalCount)
assertEquals(1000, response.loadDuration)
assertEquals(10, response.promptEvalCount)
assertEquals(1000, response.evalDuration)
assertEquals(1000, response.promptEvalDuration)

}

@Test
fun `should convert to generate response from stream json with done`() {
// Given
Expand Down

0 comments on commit 6dc1b4f

Please sign in to comment.