Skip to content
Snippets Groups Projects
Commit 38c3cca9 authored by Ammar Ahmed's avatar Ammar Ahmed :speech_balloon:
Browse files

add fixing errors prompt. Handle compiler output

parent 56324761
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"llama/compiler"
displayindicator "llama/display-indicator"
"llama/extraction"
ollamaimplementation "llama/ollama-implementation"
......@@ -14,12 +15,12 @@ func main() {
reader := bufio.NewReader(os.Stdin)
var conversationContext []int // Variable to store conversation context
for {
fmt.Print("Enter your prompt (or type 'exit' to quit): ")
userPrompt, _ := reader.ReadString('\n')
userPrompt = strings.TrimSpace(userPrompt)
for {
if userPrompt == "exit" {
fmt.Println("Exiting the program.")
break
......@@ -50,6 +51,18 @@ func main() {
var generatedCode = extraction.Extract(response)
fmt.Println("Ollama's response:", generatedCode)
var output string
var er error
output, er = compiler.CompileStringToGo(generatedCode)
if er != nil {
userPrompt = output + "\nFollowing are the errors, please fix the code. Write it again, and write only source code along with same test cases with no further explanation. The format should be ```rust <yourcode + testcases> ```"
} else {
fmt.Println("Compiled successfully. Here is the output: %v", output)
userPrompt = "exit"
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment