mirror of
https://github.com/fumiama/deepinfra.git
synced 2026-06-12 14:06:35 +08:00
fix(model): still use string in system prompt
This commit is contained in:
@@ -63,7 +63,7 @@ func (l *Log[T]) Add(grp int64, item T, isbot bool) {
|
|||||||
func (l *Log[T]) Modelize(p model.Protocol, grp int64, sysp string, isusersystem bool) deepinfra.Model {
|
func (l *Log[T]) Modelize(p model.Protocol, grp int64, sysp string, isusersystem bool) deepinfra.Model {
|
||||||
m := p
|
m := p
|
||||||
if sysp != "" && !isusersystem {
|
if sysp != "" && !isusersystem {
|
||||||
m.System(model.NewContentText(sysp))
|
m.System(sysp)
|
||||||
}
|
}
|
||||||
l.mu.RLock()
|
l.mu.RLock()
|
||||||
defer l.mu.RUnlock()
|
defer l.mu.RUnlock()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type Requester interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MessageBuilder[T any] interface {
|
type MessageBuilder[T any] interface {
|
||||||
System(prompt ...Content) T
|
System(prompt string) T
|
||||||
User(prompt ...Content) T
|
User(prompt ...Content) T
|
||||||
Assistant(prompt ...Content) T
|
Assistant(prompt ...Content) T
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,9 +166,9 @@ func (cs Contents) ToGenAIParts() []GenAIPart {
|
|||||||
return ps
|
return ps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opai *GenAI) System(prompt ...Content) Protocol {
|
func (opai *GenAI) System(prompt string) Protocol {
|
||||||
opai.SystemInstruction = &GenAIContent{
|
opai.SystemInstruction = &GenAIContent{
|
||||||
Parts: Contents(prompt).ToGenAIParts(),
|
Parts: []GenAIPart{{Text: prompt}},
|
||||||
}
|
}
|
||||||
return opai
|
return opai
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ func (ollm *OLLaMA) OutputRaw() Contents {
|
|||||||
return Contents{NewContentText(ollm.Message.Content)}
|
return Contents{NewContentText(ollm.Message.Content)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ollm *OLLaMA) System(prompt ...Content) Protocol {
|
func (ollm *OLLaMA) System(prompt string) Protocol {
|
||||||
ollm.Messages = make([]OLLaMAMessage, 1, 8)
|
ollm.Messages = make([]OLLaMAMessage, 1, 8)
|
||||||
ollm.Messages[0] = OLLaMAMessage{
|
ollm.Messages[0] = OLLaMAMessage{
|
||||||
Role: "system",
|
Role: "system",
|
||||||
Content: prompt[0].Text,
|
Content: prompt,
|
||||||
}
|
}
|
||||||
return ollm
|
return ollm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func (opai *OpenAI) OutputRaw() Contents {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opai *OpenAI) System(prompt ...Content) Protocol {
|
func (opai *OpenAI) System(prompt string) Protocol {
|
||||||
opai.Messages = make([]OpenAIMessage, 1, 8)
|
opai.Messages = make([]OpenAIMessage, 1, 8)
|
||||||
raw, err := json.Marshal(&prompt)
|
raw, err := json.Marshal(&prompt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user