Skip to content
Snippets Groups Projects
Commit f036324e authored by Ammar Ahmed's avatar Ammar Ahmed :speech_balloon:
Browse files

connected modules except database

parent 79e5fdc0
No related branches found
No related tags found
No related merge requests found
package main // package main
import ( // import (
"fmt" // "fmt"
"llama/compiler" // "llama/compiler"
displayindicator "llama/display-indicator" // displayindicator "llama/display-indicator"
"llama/extraction" // "llama/extraction"
ollamaimplementation "llama/ollama-implementation" // ollamaimplementation "llama/ollama-implementation"
"llama/promptlist" // "llama/promptlist"
) // )
func main() { // 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
//fmt.Print("Enter your prompt (or type 'exit' to quit): ") // //fmt.Print("Enter your prompt (or type 'exit' to quit): ")
//userPrompt, _ := reader.ReadString('\n') // //userPrompt, _ := reader.ReadString('\n')
//userPrompt = strings.TrimSpace(userPrompt) // //userPrompt = strings.TrimSpace(userPrompt)
promptList := promptlist.PromptList() // promptList := promptlist.PromptList()
fmt.Println(promptList) // fmt.Println(promptList)
var userPrompt = "" // var userPrompt = ""
for i := range promptList { // for i := range promptList {
fmt.Println(promptList[i]) // fmt.Println(promptList[i])
userPrompt = promptList[i] // userPrompt = promptList[i]
// //if userPrompt == "exit" {
// // fmt.Println("Exiting the program.")
// // break
// //}
// for {
// if userPrompt == "exit" { // if userPrompt == "exit" {
// fmt.Println("Exiting the program.") // fmt.Println("Exiting the program.")
// break // break
// } // }
for { // var modifiedPrompt = userPrompt + extraction.GoPrompt
if userPrompt == "exit" {
fmt.Println("Exiting the program.")
break
}
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 // // Generate response using Ollama API, passing the context
done := make(chan bool) // response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext)
go displayindicator.DisplayLoadingIndicator(done)
// Generate response using Ollama API, passing the context // // Signal the waiting indicator to stop
response, updatedContext, err := ollamaimplementation.GetOllamaResponse(modifiedPrompt, conversationContext) // done <- true
// Signal the waiting indicator to stop // if err != nil {
done <- true // fmt.Println("Error generating response:", err)
// continue
if err != nil { // }
fmt.Println("Error generating response:", err)
continue
}
// Update the conversation context with the response // // Update the conversation context with the response
conversationContext = updatedContext // conversationContext = updatedContext
generatedCode, err_extract := extraction.Extract(response) // Handle error with string // generatedCode, err_extract := extraction.Extract(response) // Handle error with string
if err_extract != nil { // if err_extract != nil {
fmt.Printf("The LLM gave a improper string in response: %v", response) // fmt.Printf("The LLM gave a improper string in response: %v", response)
userPrompt = "exit" // userPrompt = "exit"
continue // continue
} // }
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.Printf("Compiled successfully. Here is the output: %v", output) // fmt.Printf("Compiled successfully. Here is the output: %v", output)
userPrompt = "exit" // userPrompt = "exit"
} // }
} // }
} // }
} // }
func promptList() { // func promptList() {
panic("unimplemented") // panic("unimplemented")
} // }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment