File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
src/main/kotlin/cc/unitmesh/devti/llms Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ class AzureOpenAIProvider(val project: Project) : LLMProvider {
50
50
private val timeout = Duration .ofSeconds(600 )
51
51
private var client = OkHttpClient ().newBuilder().readTimeout(timeout).build()
52
52
private val openAiVersion: String
53
+ private val maxTokenLength: Int
54
+ get() = AutoDevSettingsState .getInstance().fetchMaxTokenLength()
55
+
53
56
54
57
init {
55
58
val prompts = autoDevSettingsState.customPrompts
@@ -78,9 +81,10 @@ class AzureOpenAIProvider(val project: Project) : LLMProvider {
78
81
fun prompt (instruction : String , input : String ): String {
79
82
val promptText = " $instruction \n $input "
80
83
val systemMessage = ChatMessage (ChatMessageRole .USER .value(), promptText)
81
- if (historyMessageLength > 8192 ) {
84
+ if (historyMessageLength > maxTokenLength ) {
82
85
messages.clear()
83
86
}
87
+
84
88
messages.add(SimpleOpenAIFormat .fromChatMessage(systemMessage))
85
89
val requestText = Json .encodeToString<SimpleOpenAIBody >(
86
90
SimpleOpenAIBody (
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ class OpenAIProvider(val project: Project) : LLMProvider {
126
126
}
127
127
128
128
messages.add(systemMessage)
129
+ logger.info(" messages length: ${messages.size} " )
129
130
130
131
return ChatCompletionRequest .builder()
131
132
.model(openAiVersion)
You can’t perform that action at this time.
0 commit comments