Skip to content

Commit

Permalink
Chore Add groq support (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
henomis authored Feb 28, 2024
1 parent 86f7986 commit 02d056b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 38 deletions.
31 changes: 31 additions & 0 deletions examples/llm/groq/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"context"
"fmt"

"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/thread"
goopenai "github.com/sashabaranov/go-openai"
)

func main() {
customConfig := goopenai.DefaultConfig("YOUR_API_KEY")
customConfig.BaseURL = "https://api.groq.com/openai/v1"
customClient := goopenai.NewClientWithConfig(customConfig)

openaillm := openai.New().WithClient(customClient).WithModel("mixtral-8x7b-32768")

t := thread.New().AddMessage(
thread.NewUserMessage().AddContent(
thread.NewTextContent("What's the NATO purpose?"),
),
)

err := openaillm.Generate(context.Background(), t)
if err != nil {
panic(err)
}

fmt.Println(t)
}
31 changes: 31 additions & 0 deletions examples/llm/localai/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"context"
"fmt"

"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/thread"
goopenai "github.com/sashabaranov/go-openai"
)

func main() {
customConfig := goopenai.DefaultConfig("YOUR_API_KEY")
customConfig.BaseURL = "http://localhost:8080"
customClient := goopenai.NewClientWithConfig(customConfig)

openaillm := openai.New().WithClient(customClient).WithModel("ggml-gpt4all-j")

t := thread.New().AddMessage(
thread.NewUserMessage().AddContent(
thread.NewTextContent("What's the NATO purpose?"),
),
)

err := openaillm.Generate(context.Background(), t)
if err != nil {
panic(err)
}

fmt.Println(t)
}
38 changes: 0 additions & 38 deletions examples/llm/openai/localai/main.go

This file was deleted.

0 comments on commit 02d056b

Please sign in to comment.