Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README #3

Merged
merged 1 commit into from
Jan 28, 2024
Merged
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
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
Loading