Code Monkey home page Code Monkey logo

watsonx-go's Introduction

watsonx-go

watsonx-go is a watsonx Client for Go

Install

go get -u github.com/IBM/watsonx-go

Usage

import (
  wx "github.com/IBM/watsonx-go/pkg/models"
)

Example Usage

export WATSONX_API_KEY="YOUR WATSONX API KEY"
export WATSONX_PROJECT_ID="YOUR WATSONX PROJECT ID"

Create a client:

client, _ := wx.NewClient()

Or pass in the required secrets directly:

client, err := wx.NewClient(
  wx.WithWatsonxAPIKey(apiKey),
  wx.WithWatsonxProjectID(projectID),
)

Generation:

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

println(result.Text)

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:

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:

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

Tests

Setup

export WATSONX_API_KEY="YOUR WATSONX API KEY"
export WATSONX_PROJECT_ID="YOUR WATSONX PROJECT ID"

Run

go test ./...

Pre-commit Hooks

Run the following command to run pre-commit formatting:

git config --local core.hooksPath .githooks/

Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.