Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
# llama_go_test
# 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 <API_ENDPOINT>
```

Replace `<API_ENDPOINT>` 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=<API_ENDPOINT>
go run main.go
```

Replace `<API_ENDPOINT>` with the actual API Endpoint URL.
27 changes: 27 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -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)
}