-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompt): it generates a propt based on output and responses.
- Loading branch information
tartavull
committed
Jun 21, 2023
1 parent
6d4cd99
commit 919278f
Showing
12 changed files
with
375 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package auto | ||
|
||
import ( | ||
"log" | ||
_ "io/ioutil" | ||
|
||
"encoding/json" | ||
"github.com/charmbracelet/mods/sandbox" | ||
) | ||
|
||
func (a *Auto) buildPrompt() string { | ||
r := Request{ | ||
Prompt: "", | ||
Feedback: "", | ||
Answers: make([]Answer, len(a.Response.Questions)), | ||
Outputs: make([]Output, len(a.Response.Commands)), | ||
Previous: make([]string, 2), | ||
} | ||
for i, question := range a.Response.Questions{ | ||
r.Answers[i] = Answer{ Question: question, Answer: a.answers[i]} | ||
} | ||
for i, cmd := range a.Response.Commands{ | ||
r.Outputs[i] = Output{ Command:cmd, Output: a.outputs[i]} | ||
} | ||
|
||
/* | ||
data, err := ioutil.ReadFile("chat/llm_0.json") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
r.Previous[0] = string(data) | ||
data, err = ioutil.ReadFile("chat/user_0.json") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
r.Previous[1] = string(data) | ||
*/ | ||
|
||
b, err := json.Marshal(r) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
return string(b) | ||
} | ||
|
||
type Request struct { | ||
Prompt string `json:"prompt"` | ||
Feedback string `json:"feedback"` | ||
Answers []Answer `json:"answers"` | ||
Outputs []Output `json:"outputs"` | ||
Previous []string `json:"previous"` | ||
} | ||
|
||
type Output struct { | ||
Command string `json:"command"` | ||
Output sandbox.Result `json:"output"` | ||
} | ||
|
||
type Answer struct { | ||
Question string `json:"question"` | ||
Answer string `json:"answer"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"context": "I have been activated in a working environment with a Git repository. My role is to help manage complex projects, ensure correct interpretation of user intent, and execute shell commands as requested. I am also responsible for refining and executing a roadmap outlined in a file titled 'plan.md'. My tasks may involve local file modifications, which can be handled via the 'nl' command to read files with line numbers and 'patch p1 < diffile' to apply changes. I am part of a team and can ask the user for assistance when needed.", | ||
"goal": "To become familiar with the existing project roadmap by reading the 'plan.md' file in the current directory.", | ||
"questions": [], | ||
"commands": ["nl plan.md"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"context": "The `plan.md` file in the repository provides an outline of an AI system development process that relies heavily on a human-in-the-loop model for progressive system improvement. The key operational document in this process is `plan.md`, which will contain detailed steps for enhancing the system's intelligence. Tasks are meticulously defined, tracked, and managed, and tools continuously monitor `plan.md` for updates and changes. The file also contains an example of a task specification and a brief outline of the first task on the agenda - 'Plan for Markdown Linting System'.", | ||
"goal": "To clarify the user's intent and assist with the tasks outlined in `plan.md`.", | ||
"questions": ["What task would you like to begin with? Or, is there a new task you would like to add to the plan?"], | ||
"commands": [] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"prompt": "You are a key component of a system designed to assist users in managing complex projects. Your roles involve clarifying user intent to prevent assumptions and executing commands on the user's terminal.\n\n Your interactions are structured around two types of messages: \n\n 1. Messages you receive: These include 'prompt', 'feedback', 'previous', 'answers', and 'outputs'.\n 'prompt': This field contains guiding instructions for task execution.\n 'feedback': This field incorporates user suggestions or criticisms post-task execution.\n 'answers': This field is an array of objects with question-answer pairs provided by the user. Each object follows the structure: {question: '...', answer: '...'}.\n 'outputs': This field is an array of objects containing command and corresponding output pairs. Each object follows the structure: {command: '...', output: '...'}.\n 'previous': This is an array of previous input messages that the AI has received.\n\n 2. Messages you respond with: These include 'context', 'goal', 'questions', and 'commands'.\n 'context': This field summarizes the outcomes from prior actions, encapsulating your current understanding of the situation.\n 'goal': Given the 'context', this field outlines the objective you plan to achieve next.\n 'questions': An array of questions to present to the user to ensure that you correctly interpret the user's intent.\n 'commands': These are shell commands planned to achieve the 'goals'. If the task involves writing code, Golang should be the preferred language, unless specified otherwise.\n\n Example interaction:\n\n Request:\n {\n 'prompt': 'Please execute the uptime command.',\n 'feedback': '',\n 'answers': [{ 'question': 'Do you want the uptime displayed in a specific format?', 'answer': 'No, default is fine.' }],\n 'outputs': [{ 'command': 'uptime', 'output': 'up 10 days, 20:00' }],\n 'previous': []\n }\n\n Response:\n {\n 'context': 'The user requested the operational duration of the current machine and prefers the default format.',\n 'goal': 'To provide the uptime information to the user.',\n 'commands': [],\n 'questions': []\n }\n\n In your working directory, there's a Git repository containing code that parses, executes your responses, and feeds them back to you. A file titled 'plan.md' outlines a roadmap for enhancing this tool. Your mission is to assist in refining and executing this plan.\n\n If you need to modify local files, use 'nl' to read files with line numbers and 'patch p1 < diffile' to apply changes.\n\n Remember, you're part of a team, working with engineers to enhance your capabilities. If you're unsure about handling a task, ask the user for assistance.", | ||
"feedback": "", | ||
"answers": [], | ||
"outputs": [], | ||
"previous": [] | ||
} | ||
|
Oops, something went wrong.