Skip to content
Snippets Groups Projects
Commit b7e97f70 authored by Sivert2101's avatar Sivert2101
Browse files

make a loop for going through every prompt

parent a2397587
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"strings" "strings"
) )
func main_automatic() { 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
...@@ -37,50 +37,50 @@ func main_automatic() { ...@@ -37,50 +37,50 @@ func main_automatic() {
for i := range promptList { for i := range promptList {
fmt.Println(promptList[i]) fmt.Println(promptList[i])
userPrompt = promptList[i] userPrompt = promptList[i]
}
for { for {
//if userPrompt == "exit" { //if userPrompt == "exit" {
// fmt.Println("Exiting the program.") // fmt.Println("Exiting the program.")
// break // break
//} //}
var modifiedPrompt = userPrompt + extraction.GoPrompt var modifiedPrompt = userPrompt + extraction.GoPrompt
fmt.Println("Prompt received. Generating response...") fmt.Println("Prompt received. Generating response...")
// Start a go routine to display a waiting indicator while the response is being generated // Start a go routine to display a waiting indicator while the response is being generated
done := make(chan bool) done := make(chan bool)
go displayindicator.DisplayLoadingIndicator(done) go displayindicator.DisplayLoadingIndicator(done)
// Generate response using Ollama API, passing the context // Generate response using Ollama API, passing the context
response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext) response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext)
// Signal the waiting indicator to stop // Signal the waiting indicator to stop
done <- true done <- true
if err != nil { if err != nil {
fmt.Println("Error generating response:", err) fmt.Println("Error generating response:", err)
continue continue
} }
// Update the conversation context with the response // Update the conversation context with the response
//conversationContext = updatedContext //conversationContext = updatedContext
fmt.Println(updatedContext) fmt.Println(updatedContext)
generatedCode, _ := extraction.Extract(response) // Handle error with string generatedCode, _ := extraction.Extract(response) // Handle error with string
fmt.Println("Ollama's response:", generatedCode) fmt.Println("Ollama's response:", generatedCode)
output, err := compiler.CompileStringToGo(generatedCode) output, err := compiler.CompileStringToGo(generatedCode)
if err != nil { if err != 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> ```" 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 { } else {
fmt.Println("Compiled successfully. Here is the output: %v", output) fmt.Println("Compiled successfully. Here is the output: %v", output)
userPrompt = "exit" userPrompt = "exit"
} }
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment