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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user