-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from conneroisu/feature/composio
feature/composio
- Loading branch information
Showing
55 changed files
with
1,823 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
//go:build !test | ||
// +build !test | ||
|
||
package groq | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.23.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.