Skip to content

Commit

Permalink
Merge pull request #4 from cpunion/readme
Browse files Browse the repository at this point in the history
docs: update README and example code
  • Loading branch information
cpunion authored Dec 10, 2024
2 parents 4466085 + b21faf7 commit 1136aec
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ A cross-platform Go library for interacting with multiple AI providers' APIs, in
[![Go Report Card](https://goreportcard.com/badge/github.com/cpunion/go-aisuite)](https://goreportcard.com/report/github.com/cpunion/go-aisuite)
[![Go Reference](https://pkg.go.dev/badge/github.com/cpunion/go-aisuite.svg)](https://pkg.go.dev/github.com/cpunion/go-aisuite)


## Features

- Unified interface for multiple AI providers
Expand Down Expand Up @@ -50,13 +49,17 @@ import (
)

func main() {
// Initialize client with API keys
c := client.New(&client.APIKey{
// Set your OpenAI API key or leave empty to use environment variable OPENAI_API_KEY
OpenAI: "",
// Set your Anthropic API key or leave empty to use environment variable ANTHROPIC_API_KEY
Anthropic: "",
})
// Initialize client with environment variables
c := client.New(nil)

// Or initialize client with API keys
// c := client.New(&client.APIKey{
// OpenAI: "", // Set your OpenAI API key or keep empty to use OPENAI_API_KEY env
// Anthropic: "", // Set your Anthropic API key or keep empty to use ANTHROPIC_API_KEY env
// Groq: "", // Set your Groq API key or keep empty to use GROQ_API_KEY env
// Gemini: "", // Set your Gemini API key or keep empty to use GEMINI_API_KEY env
// Sambanova: "", // Set your SambaNova API key or keep empty to use SAMBANOVA_API_KEY env
// })

// Make a chat completion request
resp, err := c.ChatCompletion(context.Background(), aisuite.ChatCompletionRequest{
Expand Down Expand Up @@ -96,8 +99,11 @@ import (
func main() {
// Initialize client with API keys
c := client.New(&client.APIKey{
OpenAI: "", // Set your OpenAI API key or use OPENAI_API_KEY env
Anthropic: "", // Set your Anthropic API key or use ANTHROPIC_API_KEY env
OpenAI: "", // Set your OpenAI API key or keep empty to use OPENAI_API_KEY env
Anthropic: "", // Set your Anthropic API key or keep empty to use ANTHROPIC_API_KEY env
Groq: "", // Set your Groq API key or keep empty to use GROQ_API_KEY env
Gemini: "", // Set your Gemini API key or keep empty to use GEMINI_API_KEY env
Sambanova: "", // Set your SambaNova API key or keep empty to use SAMBANOVA_API_KEY env
})

// Create a streaming chat completion request
Expand Down
18 changes: 11 additions & 7 deletions examples/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import (
)

func main() {
// Initialize client with API keys
c := client.New(&client.APIKey{
// Set your OpenAI API key or leave empty to use environment variable OPENAI_API_KEY
OpenAI: "",
// Set your Anthropic API key or leave empty to use environment variable ANTHROPIC_API_KEY
Anthropic: "",
})
// Initialize client with environment variables
c := client.New(nil)

// Or initialize client with API keys
// c := client.New(&client.APIKey{
// OpenAI: "", // Set your OpenAI API key or keep empty to use OPENAI_API_KEY env
// Anthropic: "", // Set your Anthropic API key or keep empty to use ANTHROPIC_API_KEY env
// Groq: "", // Set your Groq API key or keep empty to use GROQ_API_KEY env
// Gemini: "", // Set your Gemini API key or keep empty to use GEMINI_API_KEY env
// Sambanova: "", // Set your SambaNova API key or keep empty to use SAMBANOVA_API_KEY env
// })

// Make a chat completion request
resp, err := c.ChatCompletion(context.Background(), aisuite.ChatCompletionRequest{
Expand Down
9 changes: 9 additions & 0 deletions examples/chat/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"testing"
)

func TestChatMain(t *testing.T) {
main()
}
7 changes: 5 additions & 2 deletions examples/stream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import (
func main() {
// Initialize client with API keys
c := client.New(&client.APIKey{
OpenAI: "", // Set your OpenAI API key or use OPENAI_API_KEY env
Anthropic: "", // Set your Anthropic API key or use ANTHROPIC_API_KEY env
OpenAI: "", // Set your OpenAI API key or keep empty to use OPENAI_API_KEY env
Anthropic: "", // Set your Anthropic API key or keep empty to use ANTHROPIC_API_KEY env
Groq: "", // Set your Groq API key or keep empty to use GROQ_API_KEY env
Gemini: "", // Set your Gemini API key or keep empty to use GEMINI_API_KEY env
Sambanova: "", // Set your SambaNova API key or keep empty to use SAMBANOVA_API_KEY env
})

// Create a streaming chat completion request
Expand Down
7 changes: 7 additions & 0 deletions examples/stream/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "testing"

func TestChatMain(t *testing.T) {
main()
}

0 comments on commit 1136aec

Please sign in to comment.