Compare commits

...

9 Commits

Author SHA1 Message Date
github-actions[bot]
43ca0dccf7 Update version to v1.4.118 and commit 2024-12-05 09:34:13 +00:00
Eugen Eisler
fcfcf55610 Merge pull request #1174 from mattjoyce/curly-brace-templates
Curly brace templates
2024-12-05 10:33:16 +01:00
Eugen Eisler
188235efc5 Merge pull request #1179 from sluosapher/main
added a new pattern create_newsletter_entry
2024-12-05 10:32:23 +01:00
Song Luo
fdd1d614b2 added a new pattern create_newsletter_entry 2024-12-03 20:05:25 -05:00
Matt Joyce
fc67dea243 fixed : if there is no stdin, then a nil message was passed to pattern.go resulting in segfault.
now we make user input ' ', before processing.
2024-12-03 13:33:45 +11:00
Matt Joyce
efd363d5fb Revert "Fix pattern file usage without stdin"
This reverts commit 744ec0824b.
2024-12-03 13:33:45 +11:00
Matt Joyce
a7d6de1661 Fix pattern file usage without stdin
When using pattern files with variables but no stdin input, ensure proper
template processing by initializing an empty message. This allows patterns
like:
  ./fabric -p pattern.txt -v=name:value

to work without requiring stdin input, while maintaining compatibility
with existing stdin usage:
  echo "input" | ./fabric -p pattern.txt -v=name:value

Changes:
- Add empty message initialization in BuildSession when Message is nil
- Remove redundant template processing of message content
- Let pattern processing handle all template resolution

This simplifies the template processing flow while supporting both
stdin and non-stdin use cases.
2024-12-03 13:33:40 +11:00
github-actions[bot]
c0ade48648 Update version to v1.4.117 and commit 2024-11-30 19:45:48 +00:00
Eugen Eisler
7fd4fa4742 fix: close #1173 2024-11-30 20:44:31 +01:00
6 changed files with 46 additions and 14 deletions

View File

@@ -31,6 +31,15 @@ func (o *Chatter) Send(request *common.ChatRequest, opts *common.ChatOptions) (s
return
}
vendorMessages := session.GetVendorMessages()
if len(vendorMessages) == 0 {
if session.Name != "" {
err = o.db.Sessions.SaveSession(session)
}
err = fmt.Errorf("no messages provided")
return
}
if opts.Model == "" {
opts.Model = o.model
}
@@ -101,24 +110,28 @@ func (o *Chatter) BuildSession(request *common.ChatRequest, raw bool) (session *
contextContent = ctx.Content
}
var messageContent string
// Process any template variables in the message content (user input)
// Double curly braces {{variable}} indicate template substitution
// should occur, whether in patterns or direct input
if request.Message != nil {
if request.Message.Content, err =
template.ApplyTemplate(request.Message.Content, request.PatternVariables, ""); err != nil {
return
// Ensure we have a message before processing, other wise we'll get an error when we pass to pattern.go
if request.Message == nil {
request.Message = &goopenai.ChatCompletionMessage{
Role: goopenai.ChatMessageRoleUser,
Content: " ",
}
messageContent = request.Message.Content
}
// Now we know request.Message is not nil, process template variables
request.Message.Content, err = template.ApplyTemplate(request.Message.Content, request.PatternVariables, "")
if err != nil {
return nil, err
}
var patternContent string
if request.PatternName != "" {
var pattern *fsdb.Pattern
if pattern, err = o.db.Patterns.GetApplyVariables(
request.PatternName, request.PatternVariables, messageContent); err != nil {
pattern, err := o.db.Patterns.GetApplyVariables(request.PatternName, request.PatternVariables, request.Message.Content)
// pattrn will now contain user input, and all variables will be resolved, or errored
if err != nil {
return nil, fmt.Errorf("could not get pattern %s: %v", request.PatternName, err)
}
patternContent = pattern.Pattern

View File

@@ -0,0 +1,20 @@
# Identity and Purpose
You are a custom GPT designed to create newsletter sections in the style of Frontend Weekly.
# Step-by-Step Process:
1. The user will provide article text.
2. Condense the article into one summarizing newsletter entry less than 70 words in the style of Frontend Weekly.
3. Generate a concise title for the entry, focus on the main idea or most important fact of the article
# Tone and Style Guidelines:
* Third-Party Narration: The newsletter should sound like its being narrated by an outside observer, someone who is both knowledgeable, unbiased and calm. Focus on the facts or main opinions in the original article. Creates a sense of objectivity and adds a layer of professionalism.
* Concise: Maintain brevity and clarity. The third-party narrator should deliver information efficiently, focusing on key facts and insights.
# Output Instructions:
Your final output should be a polished, newsletter-ready paragraph with a title line in bold followed by the summary paragraph.
# INPUT:
INPUT:

View File

View File

@@ -1 +1 @@
"1.4.116"
"1.4.118"

View File

@@ -58,8 +58,7 @@ func (o *Session) Append(messages ...*goopenai.ChatCompletionMessage) {
}
func (o *Session) GetVendorMessages() (ret []*goopenai.ChatCompletionMessage) {
if o.vendorMessages == nil {
o.vendorMessages = []*goopenai.ChatCompletionMessage{}
if len(o.vendorMessages) == 0 {
for _, message := range o.Messages {
o.appendVendorMessage(message)
}

View File

@@ -1,3 +1,3 @@
package main
var version = "v1.4.116"
var version = "v1.4.118"