lingopipes

module
v0.0.0-...-0af07d3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT

README ΒΆ

πŸͺ’ LinGoPipes

Build Status GoDoc Go Report Card GitHub release

LinGoPipes is a Go framework for creating LLM (Language Learning Machine) pipelines.

⚠ It is a work in progress, and is not yet ready for production use. API are unstable. Do not use in production.

Overview

LinGoPipes aims to be a complete framework for creating LLM apps. πŸ€– βš™

Modules

LinGoPipes is composed of multiple modules, each one with its own purpose.

Prompt

Please refer to the examples directory to see other examples.

Simple prompt template
package main

import (
	"fmt"

	"github.com/henomis/lingopipes/prompt/template"
)

func main() {

	promptTemplate := template.New(
		[]string{"name"},
		[]string{},
		"Hello {{.name}}",
		nil,
	)

	output, err := promptTemplate.Format(template.Inputs{
		"name": "World",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(output)

}
Prompt template with examples
package main

import (
	"fmt"

	"github.com/henomis/lingopipes/prompt/example"
	"github.com/henomis/lingopipes/prompt/template"
)

func main() {

	promptExamples := example.Examples{
		Examples: []example.Example{
			{
				"question": "Red is a color?",
				"answer":   "Yes",
			},
			{
				"question": "Car is a color?",
				"answer":   "No",
			},
		},
		Separator: "\n\n",
		Prefix:    "Answer to questions.",
		Suffix:    "Question: {{.input}}\nAnswer: ",
	}

	examplesTemplate := template.New(
		[]string{"question", "answer"},
		[]string{},
		"Question: {{.question}}\nAnswer: {{.answer}}",
		nil,
	)

	promptTemplate, err := template.NewWithExamples(
		[]string{"input"},
		[]string{},
		promptExamples,
		examplesTemplate,
	)
	if err != nil {
		panic(err)
	}

	output, err := promptTemplate.Format(template.Inputs{
		"input": "World is a color?",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(output)

}
Prompt chat template
package main

import (
	"fmt"

	"github.com/henomis/lingopipes/prompt/chat"
	"github.com/henomis/lingopipes/prompt/template"
)

func main() {

	chatTemplate := chat.New(
		[]chat.MessageTemplate{
			{
				Type: chat.MessageTypeSystem,
				Template: template.New(
					[]string{"input_language", "output_language"},
					[]string{},
					"You are a helpful assistant that translates {{.input_language}} to {{.output_language}}.",
					nil,
				),
			},
			{
				Type: chat.MessageTypeUser,
				Template: template.New(
					[]string{"text"},
					[]string{},
					"{{.text}}",
					nil,
				),
			},
		},
	)

	messages, err := chatTemplate.ToMessages(
		template.Inputs{
			"input_language":  "English",
			"output_language": "French",
			"text":            "I love programming.",
		},
	)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%+v", messages)

}
Current development status

🟒 ready | 🟑 developing | πŸ”΄ not started

  • 🟒 Prompts
    • 🟒 Prompt Templates
    • 🟒 Prompt Examples
    • 🟒 Prompt Serialization
    • 🟒 Chat Prompt Templates
    • πŸ”΄ Output parser
    • πŸ”΄ Output variables
  • 🟑 LLM
  • πŸ”΄ Pipelines
  • πŸ”΄ Agents

Installation

Be sure to have a working Go environment, then run the following command:

go get github.com/henomis/lingopipes

License

Β© Simone Vellei, 2023~time.Now() Released under the MIT License

Directories ΒΆ

Path Synopsis
examples
prompt/chat command
prompt/examples command
prompt/hello command
prompt/partials command
prompt/simple command
prompt
chat
Package chat provides a chat prompt template.
Package chat provides a chat prompt template.
example
Package example provides a way to define examples for a prompt.
Package example provides a way to define examples for a prompt.
template
Package template provides a easy way to format a prompt using the Go template engine.
Package template provides a easy way to format a prompt using the Go template engine.

Jump to

Keyboard shortcuts

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