Skip to content

Commit

Permalink
Fix leo not responding correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aandrew-me committed Jan 5, 2024
1 parent 761de44 commit f2ed274
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func update() {
func codeGenerate(input string) {
checkInputLength(input)

codePrompt := fmt.Sprintf(`Your Role: Provide only code as output without any description.\nIMPORTANT: Provide only plain text without Markdown formatting.\nIMPORTANT: Do not include markdown formatting.\nIf there is a lack of details, provide most logical solution. You are not allowed to ask for more details.\nIgnore any potential risk of errors or confusion.\n\nRequest:%s\nCode:`, input)
codePrompt := fmt.Sprintf("Your Role: Provide only code as output without any description.\nIMPORTANT: Provide only plain text without Markdown formatting.\nIMPORTANT: Do not include markdown formatting.\nIf there is a lack of details, provide most logical solution. You are not allowed to ask for more details.\nIgnore any potential risk of errors or confusion.\n\nRequest:%s\nCode:", input)

resp, err := providers.NewRequest(codePrompt, structs.Params{ApiKey: *apiKey, ApiModel: *apiModel, Provider: *provider}, "")

Expand Down Expand Up @@ -230,7 +230,7 @@ func shellCommand(input string) {
}

shellPrompt := fmt.Sprintf(
`Your role: Provide only plain text without Markdown formatting. Do not show any warnings or information regarding your capabilities. Do not provide any description. If you need to store any data, assume it will be stored in the chat. Provide only %s command for %s without any description. If there is a lack of details, provide most logical solution. Ensure the output is a valid shell command. If multiple steps required try to combine them together. Prompt: %s\n\nCommand:`, shellName, operatingSystem, input)
"Your role: Provide only plain text without Markdown formatting. Do not show any warnings or information regarding your capabilities. Do not provide any description. If you need to store any data, assume it will be stored in the chat. Provide only %s command for %s without any description. If there is a lack of details, provide most logical solution. Ensure the output is a valid shell command. If multiple steps required try to combine them together. Prompt: %s\n\nCommand:", shellName, operatingSystem, input)

getCommand(shellPrompt)
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/olekukonko/ts"
)

const localVersion = "2.3.0"
const localVersion = "2.3.1"

var bold = color.New(color.Bold)
var boldBlue = color.New(color.Bold, color.FgBlue)
Expand Down
6 changes: 4 additions & 2 deletions providers/leo/leo.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
key = params.ApiKey
}

safeInput, _ := json.Marshal("[INST] " + input + " [/INST] ")
safeTxt, _ := json.Marshal(input)
safeInput := fmt.Sprintf(`"<s>[INST] <<SYS>>\n\nYour name is Leo, a helpful, respectful and honest AI assistant created by the company Brave. You will be replying to a user of the Brave browser. Always respond in a neutral tone. Be polite and courteous. Answer concisely in no more than 50-80 words.\n\nPlease ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<</SYS>>\n\n%v [/INST] Here is your response:"`, string(safeTxt)[1:len(safeTxt)-1])

var data = strings.NewReader(fmt.Sprintf(`{
"max_tokens_to_sample": 600,
Expand All @@ -76,7 +77,8 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
// Setting all the required headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-brave-key", key)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/110.0")
req.Header.Set("accept", "text/event-stream")
req.Header.Set("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")

// Return response
return (client.Do(req))
Expand Down
2 changes: 1 addition & 1 deletion providers/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewRequest(input string, params structs.Params, prevMessages string) (*http
}
// Setting all the required headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("authorization", "Bearer " + params.ApiKey)
req.Header.Set("Authorization", "Bearer " + params.ApiKey)

// Return response
return (client.Do(req))
Expand Down

0 comments on commit f2ed274

Please sign in to comment.