diff --git a/llama/main_automatic.go b/llama/main_automatic.go index 47d13cb387c7aa4c7dc7a7dc1580f87b4118446a..d9859eaeb9ae61ffc7c1646aabcafd6d3f083786 100644 --- a/llama/main_automatic.go +++ b/llama/main_automatic.go @@ -38,49 +38,47 @@ func main() { fmt.Println(promptList[i]) userPrompt = promptList[i] - for { + //if userPrompt == "exit" { + // fmt.Println("Exiting the program.") + // break + //} - //if userPrompt == "exit" { - // fmt.Println("Exiting the program.") - // 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 + done := make(chan bool) + go displayindicator.DisplayLoadingIndicator(done) - // Start a go routine to display a waiting indicator while the response is being generated - done := make(chan bool) - go displayindicator.DisplayLoadingIndicator(done) + // Generate response using Ollama API, passing the context + response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext) - // Generate response using Ollama API, passing the context - response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext) + // Signal the waiting indicator to stop + done <- true - // Signal the waiting indicator to stop - done <- true - - if err != nil { - fmt.Println("Error generating response:", err) - continue - } - - // Update the conversation context with the response - //conversationContext = updatedContext - fmt.Println(updatedContext) + if err != nil { + fmt.Println("Error generating response:", err) + continue + } - generatedCode, _ := extraction.Extract(response) // Handle error with string + // Update the conversation context with the response + //conversationContext = updatedContext + fmt.Println(updatedContext) - fmt.Println("Ollama's response:", generatedCode) + generatedCode, _ := extraction.Extract(response) // Handle error with string - output, err := compiler.CompileStringToGo(generatedCode) + fmt.Println("Ollama's response:", generatedCode) - 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> ```" - } else { - fmt.Println("Compiled successfully. Here is the output: %v", output) - userPrompt = "exit" - } + output, err := compiler.CompileStringToGo(generatedCode) + if err != nil { + fmt.Println("There were an error in the code that was compiled") + 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" } + } }