diff --git a/README.md b/README.md index e48ea0b..210bdbd 100644 --- a/README.md +++ b/README.md @@ -1 +1,26 @@ -# llama_go_test \ No newline at end of file +# llama_go_test + +## Setting the API Endpoint + +You can set the API Endpoint for accessing the ollama API using either a command line argument or an environment variable. + +### Using Command Line Argument + +To set the API Endpoint using a command line argument, run the program with the API Endpoint as the first argument: + +```sh +go run main.go +``` + +Replace `` with the actual API Endpoint URL. + +### Using Environment Variable + +To set the API Endpoint using an environment variable, set the `OLLAMA_API_ENDPOINT` environment variable before running the program: + +```sh +export OLLAMA_API_ENDPOINT= +go run main.go +``` + +Replace `` with the actual API Endpoint URL. diff --git a/main.go b/main.go new file mode 100644 index 0000000..6d35d8e --- /dev/null +++ b/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + var apiEndpoint string + + // Check if API Endpoint is provided as a command line argument + if len(os.Args) > 1 { + apiEndpoint = os.Args[1] + } else { + // Check if API Endpoint is provided as an environment variable + apiEndpoint = os.Getenv("OLLAMA_API_ENDPOINT") + } + + // Print error message if API Endpoint is not provided + if apiEndpoint == "" { + fmt.Println("Error: API Endpoint is not provided. Please provide it as a command line argument or set the OLLAMA_API_ENDPOINT environment variable.") + return + } + + // Print the API Endpoint if it is provided + fmt.Println("API Endpoint:", apiEndpoint) +}