-
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 #36 from conneroisu/devie
devie
- Loading branch information
Showing
64 changed files
with
6,632 additions
and
186 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,12 @@ | ||
# json-chat | ||
|
||
This is an example of using groq-go to create a chat application using the the ChatCompletionsJson Method. | ||
|
||
## Usage | ||
|
||
Make sure you have a groq key set in the environment variable `GROQ_KEY`. | ||
|
||
```bash | ||
export GROQ_KEY=your-groq-key | ||
go run . | ||
``` |
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,57 @@ | ||
// Package main demonstrates an example application of groq-go. | ||
// It shows how to use groq-go to create a chat completion of a json object | ||
// using the llama-3.1-70B-8192-tool-use-preview model. | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/conneroisu/groq-go" | ||
) | ||
|
||
func main() { | ||
if err := run(context.Background()); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
// Responses is a response from the models endpoint. | ||
type Responses []struct { | ||
Title string `json:"title" jsonschema:"title=Poem Title,description=Title of the poem, minLength=1, maxLength=20"` | ||
Text string `json:"text" jsonschema:"title=Poem Text,description=Text of the poem, minLength=10, maxLength=200"` | ||
} | ||
|
||
func run( | ||
ctx context.Context, | ||
) error { | ||
client, err := groq.NewClient(os.Getenv("GROQ_KEY")) | ||
if err != nil { | ||
return err | ||
} | ||
resp := &Responses{} | ||
err = client.CreateChatCompletionJSON(ctx, groq.ChatCompletionRequest{ | ||
Model: groq.Llama3Groq70B8192ToolUsePreview, | ||
Messages: []groq.ChatCompletionMessage{ | ||
{ | ||
Role: groq.ChatMessageRoleUser, | ||
Content: "Create 5 short poems in json format with title and text.", | ||
}, | ||
}, | ||
MaxTokens: 2000, | ||
}, resp) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
jsValue, err := json.MarshalIndent(resp, "", " ") | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(string(jsValue)) | ||
|
||
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,14 @@ | ||
# llava-blind | ||
|
||
This is an example of using groq-go to create a chat completion using the llava-v1.5-7b-4096-preview model. | ||
|
||
## Usage | ||
|
||
Make sure you have a groq key set in the environment variable `GROQ_KEY`. | ||
|
||
Also make sure that you are in the same directory as the `main.go` file. | ||
|
||
```bash | ||
export GROQ_KEY=your-groq-key | ||
go run . | ||
``` |
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,10 @@ | ||
# terminal-chat | ||
|
||
This is a simple terminal chat application using the groq-go library. | ||
|
||
## Usage | ||
|
||
```bash | ||
export GROQ_KEY=your-groq-key | ||
go run . | ||
``` |
Oops, something went wrong.