Compare commits

...

13 Commits

Author SHA1 Message Date
github-actions[bot]
97666d9537 Update version to v1.4.104 and commit 2024-11-18 22:21:31 +00:00
Eugen Eisler
f7733f932b Merge pull request #1142 from mattjoyce/adhoc-pattern-feature
feat: add file-based pattern support
2024-11-18 23:20:34 +01:00
github-actions[bot]
29856e4749 Update version to v1.4.103 and commit 2024-11-18 09:13:56 +00:00
Eugen Eisler
47a797e884 Merge pull request #1133 from igophper/fix_gin_logger
fix: fix default gin
2024-11-18 10:13:12 +01:00
Eugen Eisler
d4079aa543 Merge pull request #1129 from xyb/screenshoot
add a screenshot of fabric
2024-11-18 10:12:59 +01:00
github-actions[bot]
62eb837422 Update version to v1.4.102 and commit 2024-11-18 09:12:25 +00:00
Eugen Eisler
8d81f8d3aa Merge pull request #1143 from mariozig/patch-1
Update docker image
2024-11-18 10:11:39 +01:00
Mario Zigliotto
e8acf9ca07 Update docker image 2024-11-17 10:48:38 -08:00
Matt Joyce
af4752d324 feat: add file-based pattern support
Allow patterns to be loaded directly from files using explicit path prefixes
(~/, ./, /, or \). This enables easier testing and iteration of patterns
without requiring installation into the fabric config structure.

- Supports relative paths (./pattern.txt, ../pattern.txt)
- Supports home directory expansion (~/patterns/test.txt)
- Supports absolute paths
- Maintains backwards compatibility with named patterns
- Requires explicit path markers to distinguish from pattern names

Example usage:
  fabric --pattern ./draft-pattern.txt
  fabric --pattern ~/patterns/my-pattern.txt
  fabric --pattern ../../shared-patterns/test.txt
2024-11-17 14:39:49 +11:00
github-actions[bot]
fbd1fbfc67 Update version to v1.4.101 and commit 2024-11-15 16:04:16 +00:00
Eugen Eisler
d1fe826f14 improve logging for missing setup steps 2024-11-15 17:03:13 +01:00
江杭辉
2ae26dc2a6 fix: fix default gin 2024-11-13 18:02:57 +08:00
Xie Yanbo
c396288ca7 add a screenshot of fabric 2024-11-13 11:37:01 +08:00
9 changed files with 72 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
# Use official golang image as builder
FROM golang:1.22.5-alpine AS builder
FROM golang:1.23.3-alpine AS builder
# Set working directory
WORKDIR /app
@@ -38,4 +38,4 @@ EXPOSE 8080
# Run the binary with debug output
ENTRYPOINT ["/fabric"]
CMD ["--serve"]
CMD ["--serve"]

View File

@@ -25,6 +25,7 @@
[Helper Apps](#helper-apps) •
[Meta](#meta)
![Screenshot of fabric](images/fabric-summarize.png)
</div>
## Navigation

View File

@@ -98,19 +98,36 @@ func (o *Chatter) BuildSession(request *common.ChatRequest, raw bool) (session *
contextContent = ctx.Content
}
var patternContent string
if request.PatternName != "" {
var pattern *fsdb.Pattern
if pattern, err = o.db.Patterns.GetApplyVariables(request.PatternName, request.PatternVariables); err != nil {
err = fmt.Errorf("could not find pattern %s: %v", request.PatternName, err)
return
}
if pattern.Pattern != "" {
patternContent = pattern.Pattern
}
var patternContent string
var pattern *fsdb.Pattern
if request.PatternName != "" {
pathStr := request.PatternName
// First determine if this looks like a file path at all
isFilePath := strings.HasPrefix(pathStr, "\\") ||
strings.HasPrefix(pathStr, "/") ||
strings.HasPrefix(pathStr, "~") ||
strings.HasPrefix(pathStr, ".")
if isFilePath {
// Use the new file-based pattern method
if pattern, err = o.db.Patterns.GetFromFile(pathStr, request.PatternVariables); err != nil {
err = fmt.Errorf("could not read pattern file %s: %v", pathStr, err)
return
}
} else {
// Existing database lookup
if pattern, err = o.db.Patterns.GetApplyVariables(request.PatternName, request.PatternVariables); err != nil {
err = fmt.Errorf("could not find pattern %s: %v", request.PatternName, err)
return
}
}
if pattern.Pattern != "" {
patternContent = pattern.Pattern
}
}
systemMessage := strings.TrimSpace(contextContent) + strings.TrimSpace(patternContent)
if request.Language != "" {
systemMessage = fmt.Sprintf("%s. Please use the language '%s' for the output.", systemMessage, request.Language)

View File

@@ -221,9 +221,15 @@ func (o *PluginRegistry) GetChatter(model string, modelContextLength int, stream
}
if ret.vendor == nil {
var errMsg string
if defaultModel == "" || defaultVendor == "" {
errMsg = "Please run, fabric --setup, and select default model and vendor."
} else {
errMsg = "could not find vendor."
}
err = fmt.Errorf(
"could not find vendor.\n Model = %s\n Model = %s\n Vendor = %s",
model, defaultModel, defaultVendor)
" Requested Model = %s\n Default Model = %s\n Default Vendor = %s.\n\n%s",
model, defaultModel, defaultVendor, errMsg)
return
}
return

BIN
images/fabric-summarize.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

View File

@@ -1 +1 @@
"1.4.100"
"1.4.104"

View File

@@ -66,3 +66,34 @@ type Pattern struct {
Description string
Pattern string
}
// GetFromFile reads a pattern from a file path and applies variables if provided
// this provides an ad-hoc way to use a pattern
func (o *PatternsEntity) GetFromFile(pathStr string, variables map[string]string) (ret *Pattern, err error) {
// Handle home directory expansion
if strings.HasPrefix(pathStr, "~/") {
var homedir string
if homedir, err = os.UserHomeDir(); err != nil {
return nil, fmt.Errorf("could not get home directory: %v", err)
}
pathStr = filepath.Join(homedir, pathStr[2:])
}
var content []byte
if content, err = os.ReadFile(pathStr); err != nil {
return nil, fmt.Errorf("could not read pattern file %s: %v", pathStr, err)
}
ret = &Pattern{
Name: pathStr,
Pattern: string(content),
}
if variables != nil && len(variables) > 0 {
for variableName, value := range variables {
ret.Pattern = strings.ReplaceAll(ret.Pattern, variableName, value)
}
}
return
}

View File

@@ -6,7 +6,7 @@ import (
)
func Serve(registry *core.PluginRegistry, address string) (err error) {
r := gin.Default()
r := gin.New()
// Middleware
r.Use(gin.Logger())

View File

@@ -1,3 +1,3 @@
package main
var version = "v1.4.100"
var version = "v1.4.104"