Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
h0rv authored Aug 23, 2024
1 parent b977dce commit 5b52db1
Showing 1 changed file with 35 additions and 40 deletions.
75 changes: 35 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ Generation:

```go
result, _ := client.GenerateText(
"meta-llama/llama-3-70b-instruct",
"meta-llama/llama-3-1-8b-instruct",
"Hi, who are you?",
wx.WithTemperature(0.9),
wx.WithTopP(.5),
wx.WithTopK(10),
wx.WithTemperature(0.4),
wx.WithMaxNewTokens(512),
)

Expand All @@ -57,46 +55,15 @@ Stream Generation:

```go
dataChan, _ := client.GenerateTextStream(
"meta-llama/llama-3-70b-instruct",
"Hi, who are you?",
wx.WithTemperature(0.9),
wx.WithTopP(.5),
wx.WithTopK(10),
wx.WithMaxNewTokens(512),
"meta-llama/llama-3-1-8b-instruct",
"Hi, who are you?",
wx.WithTemperature(0.4),
wx.WithMaxNewTokens(512),
)

generatedText := ""

for data := range dataChan {
generatedText += data.Text
print(data.Text) // print the result as it's being generated
}

println(generatedText)
```

Note: The `GenerateTextStream` function is ideal for long text generation tasks, especially when using Server-Sent Events (SSE) for real-time text streaming.

### Customization
If you want to use Watsonx test environment, choose one of the following methods:

#### Option 1: Using Environment Variables

Specify the Watsonx URL and IAM endpoint using environment variables:
```sh
export WATSONX_URL_HOST="us-south.ml.test.cloud.ibm.com"
export WATSONX_IAM_HOST="iam.test.cloud.ibm.com"
```

#### Option 2: Using the `NewClient` Function Parameters

Specify the Watsonx URL and IAM endpoint through the parameters of the NewClient function:
```go
client, err := wx.NewClient(
wx.WithURL("us-south.ml.test.cloud.ibm.com"),
wx.WithIAM("iam.test.cloud.ibm.com"),
wx.WithWatsonxAPIKey(apiKey),
wx.WithWatsonxProjectID(projectID),
)
```

## Development Setup
Expand Down Expand Up @@ -124,6 +91,34 @@ Run the following command to run pre-commit formatting:
git config --local core.hooksPath .githooks/
```

### Using Test Environment

There are two methods for configuring the watsonx client to be used with the test environment:

#### Option 1: Using Environment Variables

Specify the Watsonx URL and IAM endpoint using environment variables:

```sh
export WATSONX_URL_HOST="us-south.ml.test.cloud.ibm.com"
export WATSONX_IAM_HOST="iam.test.cloud.ibm.com"
```

#### Option 2: Using the `NewClient` Function Parameters

Specify the Watsonx URL and IAM endpoint through the parameters of the NewClient function:

```go
client, err := wx.NewClient(
wx.WithURL("us-south.ml.test.cloud.ibm.com"),
wx.WithIAM("iam.test.cloud.ibm.com"),
wx.WithWatsonxAPIKey(apiKey),
wx.WithWatsonxProjectID(projectID),
)
```

---

## Resources

- [watsonx REST API Docs](https://cloud.ibm.com/apidocs/watsonx-ai)
Expand Down

0 comments on commit 5b52db1

Please sign in to comment.