scripts/ollama-translate/main.go

34 lines
647 B
Go
Raw Normal View History

2024-06-11 07:06:29 +02:00
package main
import (
"flag"
"fmt"
2024-06-11 07:29:31 +02:00
"os"
2024-06-11 07:06:29 +02:00
)
var (
inputFile = flag.String("i", "", "input file")
2024-06-11 07:29:31 +02:00
model = flag.String("m", "llama3", "model file")
2024-06-11 07:06:29 +02:00
)
func main() {
flag.Parse()
2024-06-11 07:29:31 +02:00
if *inputFile == "" {
fmt.Println("No input file specified")
os.Exit(1)
}
ollamaHost := os.Getenv("OLLAMA_HOST")
if ollamaHost == "" {
fmt.Println("OLLAMA_HOST environment variable not set")
os.Exit(1)
}
ollama := NewOllama(ollamaHost)
res, err := ollama.Generate(*model, "Could you translate the following text into English? 'Mijn fietsband is lek. Wat moet ik nu doen'")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
2024-06-11 07:06:29 +02:00
2024-06-11 07:29:31 +02:00
fmt.Println(res)
2024-06-11 07:06:29 +02:00
}