From 2c7379f16aa167212ff2c71a600d7eafde09fe8a Mon Sep 17 00:00:00 2001 From: Sivert2101 <89571140+Sivert2101@users.noreply.github.com> Date: Mon, 21 Oct 2024 12:07:37 +0200 Subject: [PATCH] update of the automatic file --- llama/main_automatic.go | 62 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/llama/main_automatic.go b/llama/main_automatic.go index 47d13cb..d9859ea 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" } + } } -- GitLab