-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BE-190): As a user, i want able to use ollama-client
- add OllamaApi - add unit test - code clean & refactor
- Loading branch information
Showing
24 changed files
with
435 additions
and
162 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
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
38 changes: 0 additions & 38 deletions
38
ollama-client/ollama-client-core/src/commonMain/kotlin/com/tddworks/ollama/api/Model.kt
This file was deleted.
Oops, something went wrong.
47 changes: 42 additions & 5 deletions
47
ollama-client/ollama-client-core/src/commonMain/kotlin/com/tddworks/ollama/api/Ollama.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,12 +1,49 @@ | ||
package com.tddworks.ollama.api | ||
|
||
import com.tddworks.ollama.api.chat.OllamaChat | ||
import com.tddworks.ollama.api.internal.OllamaApi | ||
|
||
/** | ||
* @author hanrw | ||
* @date 2024/4/14 17:32 | ||
* Interface for interacting with the Ollama API. | ||
*/ | ||
class Ollama { | ||
interface Ollama : OllamaChat { | ||
|
||
companion object { | ||
const val BASE_URL = "https://ollama.com" | ||
const val ANTHROPIC_VERSION = "1.0.0" | ||
const val BASE_URL = "localhost" | ||
const val PORT = 11434 | ||
const val PROTOCOL = "http" | ||
} | ||
|
||
/** | ||
* This function returns the base URL as a string. | ||
* | ||
* @return a string representing the base URL | ||
*/ | ||
fun baseUrl(): String | ||
|
||
/** | ||
* This function returns the port as an integer. | ||
* | ||
* @return an integer representing the port | ||
*/ | ||
fun port(): Int | ||
|
||
/** | ||
* This function returns the protocol as a string. | ||
* | ||
* @return a string representing the protocol | ||
*/ | ||
fun protocol(): String | ||
} | ||
|
||
fun Ollama( | ||
baseUrl: () -> String = { Ollama.BASE_URL }, | ||
port: () -> Int = { Ollama.PORT }, | ||
protocol: () -> String = { Ollama.PROTOCOL }, | ||
): Ollama { | ||
return OllamaApi( | ||
baseUrl = baseUrl(), | ||
port = port(), | ||
protocol = protocol() | ||
) | ||
} |
9 changes: 0 additions & 9 deletions
9
ollama-client/ollama-client-core/src/commonMain/kotlin/com/tddworks/ollama/api/OllamaApi.kt
This file was deleted.
Oops, something went wrong.
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
14 changes: 14 additions & 0 deletions
14
...ma-client/ollama-client-core/src/commonMain/kotlin/com/tddworks/ollama/api/OllamaModel.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,14 @@ | ||
package com.tddworks.ollama.api | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlin.jvm.JvmInline | ||
|
||
@Serializable | ||
@JvmInline | ||
value class OllamaModel(val value: String) { | ||
companion object { | ||
val LLAMA2 = OllamaModel("llama2") | ||
val CODE_LLAMA = OllamaModel("codellama") | ||
val MISTRAL = OllamaModel("mistral") | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...nt/ollama-client-core/src/commonMain/kotlin/com/tddworks/ollama/api/internal/OllamaApi.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,25 @@ | ||
package com.tddworks.ollama.api.internal | ||
|
||
import com.tddworks.di.getInstance | ||
import com.tddworks.ollama.api.Ollama | ||
import com.tddworks.ollama.api.chat.OllamaChat | ||
|
||
class OllamaApi( | ||
private val baseUrl: String, | ||
private val port: Int, | ||
private val protocol: String, | ||
) : Ollama, OllamaChat by getInstance() { | ||
|
||
override fun baseUrl(): String { | ||
return baseUrl | ||
} | ||
|
||
override fun port(): Int { | ||
return port | ||
} | ||
|
||
override fun protocol(): String { | ||
return protocol | ||
} | ||
|
||
} |
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
Oops, something went wrong.