golc

package module
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 6 Imported by: 0

README

🦜️🔗 GoLC

Build Status Go Reference goreportcard codecov

🚀 Building Go applications with LLMs through composability

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.

Features

GoLC offers a range of features to enhance the development of language processing applications:

  • 📃 LLMs and Prompts: GoLC simplifies the management and optimization of prompts and provides a generic interface for working with Large Language Models (LLMs). This simplifies the utilization of LLMs in your applications.
  • 🔗 Chains: GoLC enables the creation of sequences of calls to LLMs or other utilities. It provides a standardized interface for chains, allowing for seamless integration with various tools. Additionally, GoLC offers pre-built end-to-end chains designed for common application scenarios, saving development time and effort.
  • 📚 Retrieval Augmented Generation (RAG): GoLC supports specific types of chains that interact with data sources. This functionality enables tasks such as summarization of lengthy text and question-answering based on specific datasets. With GoLC, you can leverage RAG capabilities to enhance your language processing applications.
  • 🤖 Agents: GoLC empowers the creation of agents that leverage LLMs to make informed decisions, take actions, observe results, and iterate until completion. By incorporating agents into your applications, you can enhance their intelligence and adaptability.
  • 🧠 Memory: GoLC includes memory functionality that facilitates the persistence of state between chain or agent calls. This feature allows your applications to maintain context and retain important information throughout the processing pipeline. GoLC provides a standardized memory interface along with a selection of memory implementations for flexibility.
  • 🎓 Evaluation: GoLC simplifies the evaluation of generative models, which are traditionally challenging to assess using conventional metrics. By utilizing language models themselves for evaluation, GoLC provides a novel approach to assessing the performance of generative models.

Installation

Use Go modules to include golc in your project:

go get github.com/hupe1980/golc

Usage

package main

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

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

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.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request for any improvements or new features you would like to see.

References

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Overview

Package golc provides functions for executing chains.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Verbose controls the verbosity of the chain execution.
	Verbose = false
)

Functions

func BatchCall added in v0.0.14

func BatchCall(ctx context.Context, chain schema.Chain, inputs []schema.ChainValues, optFns ...func(*BatchCallOptions)) ([]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, optFns ...func(*CallOptions)) (schema.ChainValues, error)

Call executes a chain with multiple inputs. It returns the outputs of the chain or an error, if any.

func SimpleCall added in v0.0.14

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

SimpleCall executes a chain with a single input and a single output. It returns the output value as a string or an error, if any.

Types

type BatchCallOptions added in v0.0.22

type BatchCallOptions struct {
	Callbacks      []schema.Callback
	ParentRunID    string
	IncludeRunInfo bool
	Stop           []string
}

type CallOptions added in v0.0.22

type CallOptions struct {
	Callbacks      []schema.Callback
	ParentRunID    string
	IncludeRunInfo bool
	Stop           []string
}

type SimpleCallOptions added in v0.0.22

type SimpleCallOptions struct {
	Callbacks   []schema.Callback
	ParentRunID string
	Stop        []string
}

Directories

Path Synopsis
Package agent provides functionality for creating and managing agents that leverage Large Language Models (LLMs) to make informed decisions and take actions.
Package agent provides functionality for creating and managing agents that leverage Large Language Models (LLMs) to make informed decisions and take actions.
Package callback provides utilities for implementing callbacks in GoLC applications.
Package callback provides utilities for implementing callbacks in GoLC applications.
Package chain enables the creation and execution of chains, which are sequences of calls to LLMs or other utilities.
Package chain enables the creation and execution of chains, which are sequences of calls to LLMs or other utilities.
Package documentloader provides functionality for loading and processing documents in GoLC applications.
Package documentloader provides functionality for loading and processing documents in GoLC applications.
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
Package evaluation provides utilities for evaluating and assessing the performance of generative models in GoLC applications.
Package evaluation provides utilities for evaluating and assessing the performance of generative models in GoLC applications.
examples
Package integration provides utilities for integrating GoLC with external systems, services, and frameworks.
Package integration provides utilities for integrating GoLC with external systems, services, and frameworks.
zep
Package memory contains implementations for managing conversation data and facilitating the persistence of state between chain or agent calls.
Package memory contains implementations for managing conversation data and facilitating the persistence of state between chain or agent calls.
Package model provides functionalities for working with Large Language Models (LLMs).
Package model provides functionalities for working with Large Language Models (LLMs).
chatmodel
Package chatmodel provides functionalities for working with Large Language Models (LLMs).
Package chatmodel provides functionalities for working with Large Language Models (LLMs).
llm
Package llm provides functionalities for working with Large Language Models (LLMs).
Package llm provides functionalities for working with Large Language Models (LLMs).
Package outputparser provides utilities for parsing and processing the output generated by LLMs and other tools in GoLC applications.
Package outputparser provides utilities for parsing and processing the output generated by LLMs and other tools in GoLC applications.
Package prompt provides utilities for managing and optimizing prompts in GoLC applications.
Package prompt provides utilities for managing and optimizing prompts in GoLC applications.
Package rag provides functionality for Retrieval-Augmented Generation (RAG) in GoLC applications.
Package rag provides functionality for Retrieval-Augmented Generation (RAG) in GoLC applications.
Package retriever provides functionality for retrieving relevant documents using various services.
Package retriever provides functionality for retrieving relevant documents using various services.
Package schema defines the data structures and types used in GoLC applications.
Package schema defines the data structures and types used in GoLC applications.
Package textsplitter provides utilities for splitting and processing text in GoLC applications.
Package textsplitter provides utilities for splitting and processing text in GoLC applications.
Package tokenizer provides utilities for tokenizing text in GoLC applications.
Package tokenizer provides utilities for tokenizing text in GoLC applications.
Package tool provides tools that agents can use to perform various operations.
Package tool provides tools that agents can use to perform various operations.
Package util provides utility functions and helpers for use in GoLC applications.
Package util provides utility functions and helpers for use in GoLC applications.
Package vectorstore provides functionality for storing and managing vector embeddings in GoLC applications.
Package vectorstore provides functionality for storing and managing vector embeddings in GoLC applications.

Jump to

Keyboard shortcuts

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