From 6192d3eacc111bf0cb773efb70f7dd68ec0ef3da Mon Sep 17 00:00:00 2001 From: ammar68 <ammaa@stud.ntnu.no> Date: Sun, 20 Oct 2024 13:41:03 +0200 Subject: [PATCH] handle extract error --- llama/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/llama/main.go b/llama/main.go index 84d29d8..7e2b774 100644 --- a/llama/main.go +++ b/llama/main.go @@ -48,7 +48,13 @@ func main() { // Update the conversation context with the response conversationContext = updatedContext - generatedCode, _ := extraction.Extract(response) // Handle error with string + generatedCode, err_extract := extraction.Extract(response) // Handle error with string + + if err_extract != nil { + fmt.Printf("The LLM gave a improper string in response: %v", response) + userPrompt = "exit" + continue + } fmt.Println("Ollama's response:", generatedCode) @@ -57,7 +63,7 @@ func main() { 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) + fmt.Printf("Compiled successfully. Here is the output: %v", output) userPrompt = "exit" } -- GitLab