Skip to content

Commit

Permalink
feat: support gemini pro system prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
douglarek committed May 2, 2024
1 parent 3bb95e1 commit 65a1bd5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions llms/googleai/googleai.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ var (
)

const (
CITATIONS = "citations"
SAFETY = "safety"
RoleModel = "model"
RoleUser = "user"
RoleTool = "tool"
CITATIONS = "citations"
SAFETY = "safety"
RoleSystem = "system"
RoleModel = "model"
RoleUser = "user"
RoleTool = "tool"
)

// Call implements the [llms.Model] interface.
Expand Down Expand Up @@ -208,7 +209,7 @@ func convertContent(content llms.MessageContent) (*genai.Content, error) {

switch content.Role {
case llms.ChatMessageTypeSystem:
return nil, ErrSystemRoleNotSupported
c.Role = RoleSystem
case llms.ChatMessageTypeAI:
c.Role = RoleModel
case llms.ChatMessageTypeHuman:
Expand Down Expand Up @@ -258,6 +259,10 @@ func generateFromMessages(ctx context.Context, model *genai.GenerativeModel, mes
if err != nil {
return nil, err
}
if mc.Role == RoleSystem {
model.SystemInstruction = content
continue
}
history = append(history, content)
}

Expand Down

0 comments on commit 65a1bd5

Please sign in to comment.