Skip to content

Commit

Permalink
chore: add localai example (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
henomis committed Aug 22, 2023
1 parent bfb5d2a commit af78665
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/llm/openai/localai/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"context"
"fmt"

goopenai "github.com/sashabaranov/go-openai"

"github.com/henomis/lingoose/chat"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
)

func main() {

chat := chat.New(
chat.PromptMessage{
Type: chat.MessageTypeUser,
Prompt: prompt.New("How are you?"),
},
)

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

llm := openai.NewChat().WithClient(customClient).WithModel("ggml-gpt4all-j")

err := llm.ChatStream(context.Background(), func(output string) {
fmt.Printf("%s", output)
}, chat)
if err != nil {
panic(err)
}

fmt.Println()

}

0 comments on commit af78665

Please sign in to comment.