INNER CODE UNIT · Go

gptCompletion

sozercan/kubectl-ai · cmd/cli/completion.go:51

func gptCompletion(ctx context.Context, client oaiClients, prompts []string) (string, error) {
	temp := float32(*temperature)
	var prompt strings.Builder

	// read from stdin
	stat, _ := os.Stdin.Stat()
	if (stat.Mode() & os.ModeCharDevice) == 0 {
		stdin, err := io.ReadAll(os.Stdin)
		if err != nil {
			return "", err
		}
		fmt.Fprintf(&prompt, "Depending on the input, either edit or append to the input YAML. Do not generate new YAML without including the input YAML either original or edited.\nUse the following YAML as the input: \n%s\n", string(stdin))
	}

	for _, p := range prompts {
		fmt.Fprintf(&prompt, "%s", p)
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…