Skip to content

Commit

Permalink
Merge pull request #82 from conneroisu/feature/composio
Browse files Browse the repository at this point in the history
feature/composio
  • Loading branch information
conneroisu authored Oct 26, 2024
2 parents b25db86 + 97b4044 commit 258ed24
Show file tree
Hide file tree
Showing 55 changed files with 1,823 additions and 683 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/chron-models.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Commit Go Mod, Go Work, and Docs
name: Commit Go Generated Content

on:
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.1'
go-version: '1.23.2'

# Step 3: Run go mod download
- name: Run go mod download
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.23.1'
go-version: '1.23.2'
- name: Check out code
uses: actions/checkout@v3
- name: Install dependencies
run: |
go mod download
- name: Run Integration tests
env:
GROQ_KEY: ${{ secrets.GROQ_KEY }}
TOOLHOUSE_API_KEY: ${{ secrets.TOOLHOUSE_API_KEY }}
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
run: |
go test -race -tags=integration ./...
- name: Run Unit tests
Expand All @@ -35,8 +31,3 @@ jobs:
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=covprofile -service=github
# or use shogo82148/actions-goveralls
# - name: Send coverage
# uses: shogo82148/actions-goveralls@v1
# with:
# path-to-profile: covprofile
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23.1'
go-version: '1.23.2'
cache: true
- name: Install requirements
id: install-lint-requirements
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit Tests
on:
workflow_dispatch: {}
jobs:
test:
name: Test with Coverage
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.23.2'
- name: Check out code
uses: actions/checkout@v3
- name: Install dependencies
run: |
go mod download
- name: Run Integration tests
env:
GROQ_KEY: ${{ secrets.GROQ_KEY }}
TOOLHOUSE_API_KEY: ${{ secrets.TOOLHOUSE_API_KEY }}
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
run: |
go test -race -tags=integration ./...
- name: Run Unit tests
env:
GROQ_KEY: ${{ secrets.GROQ_KEY }}
TOOLHOUSE_API_KEY: ${{ secrets.TOOLHOUSE_API_KEY }}
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
UNIT: true
run: |
go test -race -covermode atomic -coverprofile=covprofile ./...
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
[![Coverage Status](https://coveralls.io/repos/github/conneroisu/groq-go/badge.svg?branch=main)](https://coveralls.io/github/conneroisu/groq-go?branch=main)
[![PhormAI](https://img.shields.io/badge/Phorm-Ask_AI-%23F2777A.svg?&logo=data:image/svg+xml)](https://www.phorm.ai/query?projectId=0634251d-5a98-4c37-ac2f-385b588ce3d3)

<a href="https://groq.com" target="_blank" rel="noopener noreferrer" style="width: 10px; height: 30px;">
<img
src="https://groq.com/wp-content/uploads/2024/03/PBG-mark1-color.svg"
alt="Powered by Groq for fast inference."
/>
</a>

## Features

- Supports all models from [Groq](https://wow.groq.com/) in a type-safe way.
Expand Down
3 changes: 0 additions & 3 deletions audio_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build !test
// +build !test

package groq

import (
Expand Down
157 changes: 52 additions & 105 deletions chat.go

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions examples/composio-github-star/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# composio-github-star

Adapted from the [quickstart](https://docs.composio.dev/introduction/intro/quickstart) guide.

Install the `composio` CLI and login to your account (also add github to your account if you haven't already)

```bash
pip install -U composio_core composio_openai

composio login

#Connect your Github so agents can use it
composio add github
```

Congratulations! You’ve just:

🔐 Authenticated your GitHub account with Composio
🛠 Fetched GitHub tools for the llm
⭐ Instructed the AI to star the conneroisu/groq-go repository
✅ Successfully executed the action on GitHub
74 changes: 74 additions & 0 deletions examples/composio-github-star/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package main

import (
"context"
"fmt"
"log/slog"
"os"

"github.com/conneroisu/groq-go"
"github.com/conneroisu/groq-go/extensions/composio"
"github.com/conneroisu/groq-go/pkg/test"
)

func main() {
if err := run(context.Background()); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func run(
ctx context.Context,
) error {
key, err := test.GetAPIKey("GROQ_KEY")
if err != nil {
return err
}
client, err := groq.NewClient(key)
if err != nil {
return err
}
key, err = test.GetAPIKey("COMPOSIO_API_KEY")
if err != nil {
return err
}
comp, err := composio.NewComposer(
key,
composio.WithLogger(slog.Default()),
)
if err != nil {
return err
}
tools, err := comp.GetTools(
ctx,
composio.WithApp("GITHUB"),
composio.WithUseCase("star-repo"),
)
if err != nil {
return err
}
chat, err := client.CreateChatCompletion(ctx, groq.ChatCompletionRequest{
Model: groq.ModelLlama3Groq70B8192ToolUsePreview,
Messages: []groq.ChatCompletionMessage{
{
Role: groq.ChatMessageRoleUser,
Content: `
You are a github star bot. You will be given a repo name and you will star it.
Star the repo conneroisu/groq-go on GitHub.
`,
},
},
MaxTokens: 2000,
Tools: tools,
})
if err != nil {
return err
}
resp, err := comp.Run(ctx, chat)
if err != nil {
return err
}
fmt.Println(resp)
return nil
}

Check warning on line 74 in examples/composio-github-star/main.go

View check run for this annotation

Codeac.io / Codeac Code Quality

package-comments

should have a package comment
33 changes: 33 additions & 0 deletions examples/e2b-go-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# e2b-go-project

This is an example of using groq-go to create a simple golang project using the e2b and groq api powered by the groq-go library.

## Usage

Make sure you have a groq key set in the environment variable `GROQ_KEY`.
Also, make sure that you have a e2b api key set in the environment variable `E2B_API_KEY`.

```bash
export GROQ_KEY=your-groq-key
export E2B_API_KEY=your-e2b-api-key
go run .
```

### System Prompt

```txt
Given the tools given to you, create a golang project with the following files:
<files>
main.go
utils.go
<files>
The main function should call the `utils.run() error` function.
The project should, when run, print the following:
<output>
Hello, World!
<output>
```
67 changes: 67 additions & 0 deletions examples/e2b-go-project/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package main

import (
"context"
"fmt"
"os"

"github.com/conneroisu/groq-go"
"github.com/conneroisu/groq-go/extensions/e2b"
)

func main() {
if err := run(context.Background()); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func run(
ctx context.Context,
) error {
key := os.Getenv("GROQ_KEY")
e2bKey := os.Getenv("E2B_API_KEY")
client, err := groq.NewClient(key)
if err != nil {
return err
}
sb, err := e2b.NewSandbox(
ctx,
e2bKey,
)
if err != nil {
return err
}
chat, err := client.CreateChatCompletion(ctx, groq.ChatCompletionRequest{
Model: groq.ModelLlama3Groq70B8192ToolUsePreview,
Messages: []groq.ChatCompletionMessage{
{
Role: groq.ChatMessageRoleUser,
Content: `
Given the tools given to you, create a golang project with the following files:
<files>
main.go
utils.go
<files>
The main function should call the "utils.run() error" function.
The project should, when run, print the following:
<output>
Hello, World!
<output>
`,
},
},
MaxTokens: 2000,
Tools: sb.GetTools(),
})
if err != nil {
return err
}
fmt.Println(chat.Choices[0].Message.Content)
return nil
}

Check warning on line 67 in examples/e2b-go-project/main.go

View check run for this annotation

Codeac.io / Codeac Code Quality

package-comments

should have a package comment
2 changes: 0 additions & 2 deletions examples/llava-blind/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Package main demonstrates an example application of groq-go.
package main

// url: https://cdnimg.webstaurantstore.com/images/products/large/87539/251494.jpg

import (
"context"
"fmt"
Expand Down
1 change: 1 addition & 0 deletions extensions/composio/.go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.23.1
3 changes: 3 additions & 0 deletions extensions/composio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# composio

Compose AI is a powerful tool for creating complex and high-quality compositions of ai tools. This package provides a client for the composio api easily accessible through the groq-go library.
Loading

0 comments on commit 258ed24

Please sign in to comment.