golc

package module
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 5 Imported by: 0

README

🦜️🔗 GoLC

⚡ Building applications with LLMs through composability ⚡

Build Status Go Reference

GoLC is an innovative project heavily inspired by the LangChain project, aimed at building applications with Large Language Models (LLMs) by leveraging the concept of composability. It provides a framework that enables developers to create and integrate LLM-based applications seamlessly. Through the principles of composability, GoLC allows for the modular construction of LLM-based components, offering flexibility and extensibility to develop powerful language processing applications. By leveraging the capabilities of LLMs and embracing composability, GoLC brings new opportunities to the Golang ecosystem for the development of natural language processing applications.

Installation

go get github.com/hupe1980/golc

How to use

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/hupe1980/golc"
	"github.com/hupe1980/golc/chain"
	"github.com/hupe1980/golc/model/llm"
	"github.com/hupe1980/golc/schema"
)

func main() {
	openai, err := llm.NewOpenAI(os.Getenv("OPENAI_API_KEY"))
	if err != nil {
		log.Fatal(err)
	}

	conversationChain, err := chain.NewConversation(openai)
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()

	result1, err := golc.SimpleCall(ctx, conversationChain, "What year was Einstein born?")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(result1)

	result2, err := golc.SimpleCall(ctx, conversationChain, "Multiply the year by 3.")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(result2)
}

Output:

Einstein was born in 1879.
1879 multiplied by 3 equals 5637.

For more example usage, see _examples.

References

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Verbose = false

	ErrMultipleInputs  = errors.New("no support for calling a chain with more than one expected input")
	ErrMultipleOutputs = errors.New("no support for calling a chain with more than one expected output")
	ErrWrongOutputType = errors.New("no support for calling a chain with non string return type")
)

Functions

func BatchCall added in v0.0.14

func BatchCall(ctx context.Context, chain schema.Chain, inputs []schema.ChainValues) ([]schema.ChainValues, error)

BatchCall executes multiple calls to the chain.Call function concurrently and collects the results in the same order as the inputs. It utilizes the errgroup package to manage the concurrent execution and handle any errors that may occur.

func Call added in v0.0.14

func Call(ctx context.Context, chain schema.Chain, inputs schema.ChainValues) (schema.ChainValues, error)

func SimpleCall added in v0.0.14

func SimpleCall(ctx context.Context, chain schema.Chain, input any) (string, error)

Types

This section is empty.

Directories

Path Synopsis
_examples
Package embedding contains the implementation to create vector embeddings from text using different APIs
Package embedding contains the implementation to create vector embeddings from text using different APIs
zep
Packet memory contains implementations for managing conversation data
Packet memory contains implementations for managing conversation data
llm

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL