Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support patterns from external resources #235

Closed
gwpl opened this issue Mar 18, 2024 · 7 comments
Closed

Feature request: Support patterns from external resources #235

gwpl opened this issue Mar 18, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@gwpl
Copy link

gwpl commented Mar 18, 2024

As example step number one and inspiration, imagine:

cat file | mods --pattern fabric:extract_wisdom

that would fetch (or use cached) pattern from https://github.com/danielmiessler/fabric/tree/main/patterns and use it.

Of course this could be extended in future to other providers.

(Maybe it's actually worth to be project by itself and be modular, sth like "pattern provider" from which tools like this one could get patterns/prompts etc...)

cross-linking: TheR1D/shell_gpt#518

@gwpl gwpl changed the title Support patterns from external resources Feature request: Support patterns from external resources Mar 18, 2024
caarlos0 added a commit that referenced this issue Apr 3, 2024
This allows to set a role message to either a http/https URL or a
filepath (prefixed with `file://`).

Solves #235

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Member

caarlos0 commented Apr 3, 2024

would #245 do it?

you can do things like:

roles:
  "create_summary":
    - https://raw.githubusercontent.com/danielmiessler/fabric/main/patterns/create_summary/system.md

wdyt?

@bradyjoslin
Copy link
Contributor

Pulled down the branch and tried it out, this is a powerful new feature for getting better responses. Like the flexibility of a URL or file as the source.

@bradyjoslin
Copy link
Contributor

bradyjoslin commented Apr 13, 2024

After living with this for a few days it became tedious configuring individual roles in the settings file and mapping them to a growing library of markdown files. Made this addition locally - now when I want to define a new role, I simply create a new markdown file and a role is dynamically defined based on the filename.

roles-directory: Contains role definitions in markdown. Each filename acts as the role name.

# mods.yml settings file

...
# Directory containing roles defined in markdown.
roles-directory: /path/to/roles
...
// config.go

type Config struct {
...
RolesDirectory    string              `yaml:"roles-directory" env:"ROLES_DIRECTORY"`
...
}
// mods.go
// Appends roles from roles-directory to cfg.Roles

func (m *Mods) startCompletionCmd(content string) tea.Cmd {
...
  if cfg.RolesDirectory != "" {
	  roles := make(map[string][]string)
  
	  err := filepath.Walk(cfg.RolesDirectory, func(path string, info os.FileInfo, err error) error {
		  if err != nil {
			  return err
		  }
		  if !info.IsDir() && strings.HasSuffix(info.Name(), ".md") && info.Name() != "README.md" {
			  name := strings.TrimSuffix(info.Name(), ".md")
			  roles[name] = append(roles[name], "file://"+path)
		  }
		  return nil
	  })
  
	  if err != nil {
		  return modsError{
			  err:    err,
			  reason: "Could not read roles from roles directory",
		  }
	  }
  
	  for k, v := range roles {
		  cfg.Roles[k] = v
	  }
  }
...
}

caarlos0 added a commit that referenced this issue Apr 15, 2024
This allows to set a role message to either a http/https URL or a
filepath (prefixed with `file://`).

Solves #235

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Member

yeah, that might be a good idea as well...

another one would be to generate yaml, something like:

find . -name 'system.md' | while read -r line; do
	echo "  - $(basename $(dirname $line)):"
	echo "    - $(readlink -f $line)"
done

@bradyjoslin
Copy link
Contributor

Agree, YAML generation outside of mods similar to your suggestion is likely sufficient and avoids feature bloat in mods, as this need may be more of an edge case. Thanks @caarlos0.

@caarlos0
Copy link
Member

okay, gonna close this then!

thanks everyone!

@caarlos0 caarlos0 added the enhancement New feature or request label Apr 25, 2024
@caarlos0 caarlos0 self-assigned this Apr 25, 2024
@gwpl
Copy link
Author

gwpl commented Apr 28, 2024

It looks like #245 is merged! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants