diff --git a/llama/main_automatic.go b/llama/main_automatic.go index 289bfc7e106c0e77f665d4967bfc6186fc95035e..47d13cb387c7aa4c7dc7a7dc1580f87b4118446a 100644 --- a/llama/main_automatic.go +++ b/llama/main_automatic.go @@ -11,7 +11,7 @@ import ( "strings" ) -func main_automatic() { +func main() { //reader := bufio.NewReader(os.Stdin) var conversationContext []int // Variable to store conversation context @@ -37,50 +37,50 @@ func main_automatic() { for i := range promptList { fmt.Println(promptList[i]) userPrompt = promptList[i] - } - for { + 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 - } + if err != nil { + fmt.Println("Error generating response:", err) + continue + } - // Update the conversation context with the response - //conversationContext = updatedContext - fmt.Println(updatedContext) + // Update the conversation context with the response + //conversationContext = 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 { - 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" - } + 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" + } + } } }