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 ...@@ -3,6 +3,7 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"llama/compiler"
displayindicator "llama/display-indicator" displayindicator "llama/display-indicator"
"llama/extraction" "llama/extraction"
ollamaimplementation "llama/ollama-implementation" ollamaimplementation "llama/ollama-implementation"
...@@ -14,11 +15,11 @@ func main() { ...@@ -14,11 +15,11 @@ func main() {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
var conversationContext []int // Variable to store conversation context 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)
fmt.Print("Enter your prompt (or type 'exit' to quit): ") for {
userPrompt, _ := reader.ReadString('\n')
userPrompt = strings.TrimSpace(userPrompt)
if userPrompt == "exit" { if userPrompt == "exit" {
fmt.Println("Exiting the program.") fmt.Println("Exiting the program.")
...@@ -50,6 +51,18 @@ func main() { ...@@ -50,6 +51,18 @@ func main() {
var generatedCode = extraction.Extract(response) var generatedCode = extraction.Extract(response)
fmt.Println("Ollama's response:", generatedCode) 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