@@ -96,14 +96,19 @@ func InitLLMHoneypot(config LLMHoneypot) *LLMHoneypot {
96
96
return & config
97
97
}
98
98
99
- func buildPrompt ( histories [] Message , protocol tracer. Protocol , command string ) ([]Message , error ) {
99
+ func ( llmHoneypot * LLMHoneypot ) buildPrompt ( command string ) ([]Message , error ) {
100
100
var messages []Message
101
+ var prompt string
101
102
102
- switch protocol {
103
+ switch llmHoneypot . Protocol {
103
104
case tracer .SSH :
105
+ prompt = systemPromptVirtualizeLinuxTerminal
106
+ if llmHoneypot .CustomPrompt != "" {
107
+ prompt = llmHoneypot .CustomPrompt
108
+ }
104
109
messages = append (messages , Message {
105
110
Role : SYSTEM .String (),
106
- Content : systemPromptVirtualizeLinuxTerminal ,
111
+ Content : prompt ,
107
112
})
108
113
messages = append (messages , Message {
109
114
Role : USER .String (),
@@ -113,13 +118,17 @@ func buildPrompt(histories []Message, protocol tracer.Protocol, command string)
113
118
Role : ASSISTANT .String (),
114
119
Content : "/home/user" ,
115
120
})
116
- for _ , history := range histories {
121
+ for _ , history := range llmHoneypot . Histories {
117
122
messages = append (messages , history )
118
123
}
119
124
case tracer .HTTP :
125
+ prompt = systemPromptVirtualizeHTTPServer
126
+ if llmHoneypot .CustomPrompt != "" {
127
+ prompt = llmHoneypot .CustomPrompt
128
+ }
120
129
messages = append (messages , Message {
121
130
Role : SYSTEM .String (),
122
- Content : systemPromptVirtualizeHTTPServer ,
131
+ Content : prompt ,
123
132
})
124
133
messages = append (messages , Message {
125
134
Role : USER .String (),
@@ -214,18 +223,7 @@ func (llmHoneypot *LLMHoneypot) ExecuteModel(command string) (string, error) {
214
223
var err error
215
224
var prompt []Message
216
225
217
- if llmHoneypot .CustomPrompt != "" {
218
- prompt = append (prompt , Message {
219
- Role : SYSTEM .String (),
220
- Content : llmHoneypot .CustomPrompt ,
221
- })
222
- prompt = append (prompt , Message {
223
- Role : USER .String (),
224
- Content : command ,
225
- })
226
- } else {
227
- prompt , err = buildPrompt (llmHoneypot .Histories , llmHoneypot .Protocol , command )
228
- }
226
+ prompt , err = llmHoneypot .buildPrompt (command )
229
227
230
228
if err != nil {
231
229
return "" , err
0 commit comments