Skip to content

Commit

Permalink
Update README (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Robby <h0rv@users.noreply.github.com>
  • Loading branch information
h0rv and h0rv authored Jan 28, 2024
1 parent f0318c5 commit ebae778
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# go-watsonx

A watsonx API Wrapper Client for Go
Zero dependency [watsonx](https://www.ibm.com/watsonx) API Client for Go

## Install

Expand Down Expand Up @@ -39,7 +39,22 @@ import (
println(result)
```

## Setup
## Development Setup

### Tests

#### Setup

```sh
export IBMCLOUD_API_KEY="YOUR IBM CLOUD API KEY"
export WATSONX_PROJECT_ID="YOUR WATSONX PROJECT ID"
```

#### Run

```sh
go test ./...
```

### Pre-commit Hooks

Expand Down
36 changes: 16 additions & 20 deletions models/test/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@ import (
"os"
"testing"

"github.com/h0rv/go-watsonx/models"
wx "github.com/h0rv/go-watsonx/models"
)

const (
DummyProjectID = "f47ac10b-58cc-4372-a567-0e02b2c3d479"
DummySpaceID = "c9d1e1b2-936c-4e70-9d54-21ed4049e131"
)

func getModel(t *testing.T) *models.Model {
// ENV Variables For Testing
apiKey := os.Getenv("API_KEY")
func getModel(t *testing.T) *wx.Model {
apiKey := os.Getenv(wx.IBMCloudAPIKeyEnvVarName)
projectID := os.Getenv(wx.WatsonxProjectIDEnvVarName)
if apiKey == "" {
// If the environment variable is not set, use a dummy value
apiKey = "your_dummy_api_key"
t.Fatal("No IBM Cloud API key provided")
}
if projectID == "" {
t.Fatal("No watsonx project ID provided")
}

// Create a test model with dummy data
model, err := models.NewModel(
model, err := wx.NewModel(
apiKey,
DummyProjectID,
models.WithModel(models.FLAN_UL2),
projectID,
wx.WithModel(wx.FLAN_UL2),
)
if err != nil {
t.Fatalf("Failed to create model for testing. Error: %v", err)
Expand Down Expand Up @@ -67,11 +63,11 @@ func TestGenerateText(t *testing.T) {
prompt := "Hi, who are you?"
result, err := model.GenerateText(
prompt,
models.WithTemperature(0.9),
models.WithTopP(.5),
models.WithTopK(10),
models.WithMaxNewTokens(512),
models.WithDecodingMethod(models.Greedy),
wx.WithTemperature(0.9),
wx.WithTopP(.5),
wx.WithTopK(10),
wx.WithMaxNewTokens(512),
wx.WithDecodingMethod(wx.Greedy),
)
if err != nil {
t.Fatalf("Expected no error, but got an error: %v", err)
Expand Down

0 comments on commit ebae778

Please sign in to comment.