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

feature/composio #82

Merged
merged 36 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f2e0354
added e2b emulating test server and unit test for sandbox
conneroisu Oct 19, 2024
09e2228
added toolhouse test server method on the test server
conneroisu Oct 19, 2024
9728fc3
remove default logger from test server
conneroisu Oct 19, 2024
89017ae
run tidy on go.mod and go.sum in generate-models
conneroisu Oct 19, 2024
13c7add
remove generate e2b kernels
conneroisu Oct 19, 2024
900d516
model out more of the interface and remove unused struct for subscrib…
conneroisu Oct 20, 2024
658095e
save local testing progress
conneroisu Oct 20, 2024
aa5522a
added start to exmaple of e2b module
conneroisu Oct 20, 2024
353e6f3
added start of composio extension
conneroisu Oct 20, 2024
c6f84b9
made a composio example for better development
conneroisu Oct 20, 2024
8e4f9b4
added request builders to composio
conneroisu Oct 20, 2024
e503fb6
added composio client comment to new composio client
conneroisu Oct 20, 2024
26e913d
change to subscribestdout and subscribestderr and subscribeexit
conneroisu Oct 22, 2024
22bda71
Added get tools params
conneroisu Oct 22, 2024
e46e0cf
update go version
conneroisu Oct 23, 2024
1f8d3fd
make toolhouse execution more efficient and implement composio execution
conneroisu Oct 23, 2024
7d66abb
moved tools to pkg/tools
conneroisu Oct 23, 2024
288f0c2
added retru log to sandbox.read
conneroisu Oct 24, 2024
5384431
broke out the tet servers into their own files for each service
conneroisu Oct 24, 2024
8bcb569
working composion extension
conneroisu Oct 24, 2024
2e523c3
optimize readability in composio and make sure e2b is concurrent safe
conneroisu Oct 25, 2024
258b727
added composio test server function
conneroisu Oct 25, 2024
3768bd3
added unit test which is triggered by a workflow dispatch
conneroisu Oct 25, 2024
53ff10e
update go versions in workflows
conneroisu Oct 25, 2024
cb4ed1a
finished composio inferface
conneroisu Oct 25, 2024
c6187bc
removed unit test in composio
conneroisu Oct 25, 2024
aa77e3a
added auther interface to composio client and cleaned up getconnected…
conneroisu Oct 25, 2024
daec461
rename unit test inside auth_test
conneroisu Oct 25, 2024
f9a40ce
adjust to new connected account response/struct
conneroisu Oct 25, 2024
601f0d4
add with base url to options for composio
conneroisu Oct 25, 2024
e8de7dd
add label to options for e2b
conneroisu Oct 25, 2024
098f05e
remove uneeffectual ctx declaration in unit test
conneroisu Oct 25, 2024
b7a1e14
clean up the error message return for the tooling wrapper
conneroisu Oct 25, 2024
eea3a1b
more readable tools in e2b.tools
conneroisu Oct 25, 2024
b9db1a4
added encoding functions to test package
conneroisu Oct 25, 2024
97b4044
finish this composio integration
conneroisu Oct 26, 2024
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
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,35 +1,33 @@
// 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"
"os"

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

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

func run(
ctx context.Context,
) error {
key := os.Getenv("GROQ_KEY")
client, err := groq.NewClient(key)
if err != nil {
return err
}

response, err := client.CreateChatCompletion(
ctx,

Check warning on line 30 in examples/llava-blind/main.go

View check run for this annotation

Codeac.io / Codeac Code Quality

CodeDuplication

This block of 28 lines is too similar to examples/moderation/main.go:3
groq.ChatCompletionRequest{
Model: groq.ModelLlavaV157B4096Preview,
Messages: []groq.ChatCompletionMessage{
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
Loading