v1.2.6.1 openai timeout
This commit is contained in:
parent
63c0dc5595
commit
a8d54fa78f
2
.gitignore
vendored
2
.gitignore
vendored
@ -30,4 +30,4 @@ out/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
logs/aitrainer.log
|
||||
logs/
|
||||
|
@ -7,6 +7,7 @@ import com.aallam.openai.api.chat.ChatMessage
|
||||
import com.aallam.openai.client.OpenAI
|
||||
import com.aallam.openai.api.completion.CompletionRequest
|
||||
import com.aallam.openai.api.completion.TextCompletion
|
||||
import com.aallam.openai.api.http.Timeout
|
||||
import com.aallam.openai.api.logging.LogLevel
|
||||
import com.aallam.openai.api.model.Model
|
||||
import com.aallam.openai.api.model.ModelId
|
||||
@ -16,6 +17,8 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@Service
|
||||
class OpenAIService(@Value("\${openai.key}") private val openaiKey: String, private val modelName: String?, private val temperature: Double?) {
|
||||
|
||||
@ -26,7 +29,8 @@ class OpenAIService(@Value("\${openai.key}") private val openaiKey: String, priv
|
||||
private suspend fun connect(modelName: String) {
|
||||
val config = OpenAIConfig(
|
||||
token = openaiKey,
|
||||
logLevel = LogLevel.All
|
||||
logLevel = LogLevel.All,
|
||||
timeout = Timeout(socket = 300.seconds)
|
||||
)
|
||||
openAI = OpenAI(config)
|
||||
modelId = ModelId(modelName)
|
||||
|
Loading…
Reference in New Issue
Block a user