1
0
mirror of https://github.com/fumiama/deepinfra.git synced 2026-06-08 20:10:42 +08:00

feat(model): add Cloner to Protocol

This commit is contained in:
源文雨
2025-12-22 00:31:08 +08:00
parent 541d66a361
commit 0f52825474
4 changed files with 30 additions and 0 deletions

View File

@@ -21,6 +21,10 @@ type Requester interface {
Header(key string, h http.Header) // Header decorator
}
type Cloner interface {
Clone() Cloner
}
type MessageBuilder[T any] interface {
System(prompt string) T
User(prompt ...Content) T
@@ -32,4 +36,5 @@ type Protocol interface {
Outputer
Requester
MessageBuilder[Protocol]
Cloner
}

View File

@@ -188,3 +188,12 @@ func (opai *GenAI) Assistant(prompt ...Content) Protocol {
})
return opai
}
func (opai *GenAI) Clone() Cloner {
x := new(GenAI)
*x = *opai
x.SystemInstruction = nil
x.Contents = nil
x.Candidates = nil
return x
}

View File

@@ -101,3 +101,11 @@ func (ollm *OLLaMA) Assistant(prompt ...Content) Protocol {
})
return ollm
}
func (ollm *OLLaMA) Clone() Cloner {
x := new(OLLaMA)
*x = *ollm
x.Messages = nil
x.Message = nil
return x
}

View File

@@ -155,3 +155,11 @@ func (opai *OpenAI) User(prompt ...Content) Protocol {
func (opai *OpenAI) Assistant(prompt ...Content) Protocol {
return opai.normal("assistant", prompt...)
}
func (opai *OpenAI) Clone() Cloner {
x := new(OpenAI)
*x = *opai
x.Choices = nil
x.Messages = nil
return x
}