Code Monkey home page Code Monkey logo

golc's Introduction

πŸ¦œοΈπŸ”— GoLC

Build Status Go Reference goreportcard codecov License: MIT

πŸš€ 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.
  • πŸš“ Moderation: GoLC incorporates essential moderation functionalities to enhance the security and appropriateness of language processing applications. This includes prompt injection detection, detection and redaction of Personally Identifiable Information (PII), identification of toxic content, and more.
  • πŸ“„ Document Processing: GoLC provides comprehensive document processing capabilities, including loading, transforming, and compressing. It offers a versatile set of tools to streamline document-related tasks, making it an ideal solution for document-centric language processing applications.

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/chatmodel"
)

func main() {
	openai, err := chatmodel.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.

golc's People

Contributors

bstncartwright avatar hupe1980 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

golc's Issues

`chatmodel` Bedrock supports only Meta and Amazon models

Thanks for building this awesome library! I look forward to contributing :)

In the models/chatmodel module, the Amazon Bedrock supports only the Meta (LLama) and Amazon (Titan) models. We would love for it to support the other models on Amazon Bedrock like Cohere's, Mistral's and Anthropic's.

Error when running the example in README.md

First of all, thank you for open sourcing your project! When running the example code from README.md, I got the following error:

2023/12/22 20:44:46 All attempts fail:
#1: error, status code: 400, message: Invalid value for 'tool_choice': 'tool_choice' is only allowed when 'tools' are specified.
exit status 1

Not sure if I missed something obvious though...

Update Anthropic Client

Anthropic changed their python sdk - making this code line outdated.

client *anthropic.Client

Would love to know if this might help - https://github.com/BerriAI/litellm

~100 lines of code, that standardizes all the llm api calls to the OpenAI call

from litellm import completion

## set ENV variables
# ENV variables can be set in .env file, too. Example in .env.example
os.environ["OPENAI_API_KEY"] = "openai key"
os.environ["ANTHROPIC_API_KEY"] = "anthropic key"

messages = [{ "content": "Hello, how are you?","role": "user"}]

# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)

# anthropic call
response = completion("claude-v-2", messages)

template: template:5:19: executing "template" at <.query>: map has no entry for key "query"

Thanks for the project, I'm running across this issue in the conversational_retrieval_qa_rag example.

template: template:5:19: executing "template" at <.query>: map has no entry for key "query"

It only happens on the second call though. I'm stumped.

result2, err := golc.Call(context.Background(), conversationalRetrievalQAChain, schema.ChainValues{
		"question": question2,
	})

Thanks again, happy to contribute if you can point me in a direction.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.