(ctx context.Context, content string, selectedText string, conversationType chatv1.ConversationType)
| 85 | } |
| 86 | |
| 87 | func (s *ChatService) GetPrompt(ctx context.Context, content string, selectedText string, conversationType chatv1.ConversationType) (string, error) { |
| 88 | var tmpl *template.Template |
| 89 | switch conversationType { |
| 90 | case chatv1.ConversationType_CONVERSATION_TYPE_DEBUG: |
| 91 | tmpl = userPromptDebugTmpl |
| 92 | default: |
| 93 | tmpl = userPromptDefaultTmpl |
| 94 | } |
| 95 | |
| 96 | var userPromptBuffer bytes.Buffer |
| 97 | if err := tmpl.Execute(&userPromptBuffer, map[string]string{ |
| 98 | "UserInput": content, |
| 99 | "SelectedText": selectedText, |
| 100 | }); err != nil { |
| 101 | return "", err |
| 102 | } |
| 103 | return strings.TrimSpace(userPromptBuffer.String()), nil |
| 104 | } |
| 105 | |
| 106 | func (s *ChatService) InsertConversationToDB(ctx context.Context, userID bson.ObjectID, projectID string, modelSlug string, inappChatHistory []*chatv1.Message, openaiChatHistory responses.ResponseInputParam) (*models.Conversation, error) { |
| 107 | // Convert protobuf messages to BSON |
no test coverage detected