mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
string based system prompts
This commit is contained in:
+1
-1
@@ -79,7 +79,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().
|
||||
StringVar(&configFile, "config", "", "config file (default is $HOME/.mcp.json)")
|
||||
rootCmd.PersistentFlags().
|
||||
StringVar(&systemPromptFile, "system-prompt", "", "system prompt json file")
|
||||
StringVar(&systemPromptFile, "system-prompt", "", "system prompt text or path to system prompt json file")
|
||||
rootCmd.PersistentFlags().
|
||||
IntVar(&messageWindow, "message-window", 40, "number of messages to keep in context")
|
||||
rootCmd.PersistentFlags().
|
||||
|
||||
+20
-13
@@ -121,25 +121,32 @@ func LoadMCPConfig(configFile string) (*Config, error) {
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
// LoadSystemPrompt loads system prompt from file
|
||||
func LoadSystemPrompt(filePath string) (string, error) {
|
||||
if filePath == "" {
|
||||
// LoadSystemPrompt loads system prompt from file or returns the string directly
|
||||
func LoadSystemPrompt(input string) (string, error) {
|
||||
if input == "" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
v := viper.New()
|
||||
v.SetConfigFile(filePath)
|
||||
// Check if input is a file that exists
|
||||
if _, err := os.Stat(input); err == nil {
|
||||
// Treat as file path
|
||||
v := viper.New()
|
||||
v.SetConfigFile(input)
|
||||
|
||||
if err := v.ReadInConfig(); err != nil {
|
||||
return "", fmt.Errorf("error reading system prompt file: %v", err)
|
||||
if err := v.ReadInConfig(); err != nil {
|
||||
return "", fmt.Errorf("error reading system prompt file: %v", err)
|
||||
}
|
||||
|
||||
systemPrompt := v.GetString("systemPrompt")
|
||||
if systemPrompt == "" {
|
||||
return "", fmt.Errorf("systemPrompt field not found in config file")
|
||||
}
|
||||
|
||||
return systemPrompt, nil
|
||||
}
|
||||
|
||||
systemPrompt := v.GetString("systemPrompt")
|
||||
if systemPrompt == "" {
|
||||
return "", fmt.Errorf("systemPrompt field not found in config file")
|
||||
}
|
||||
|
||||
return systemPrompt, nil
|
||||
// Treat as direct string
|
||||
return input, nil
|
||||
}
|
||||
|
||||
// createDefaultConfig creates a default .mcphost.yml file in the user's home directory
|
||||
|
||||
Reference in New Issue
Block a user