Skip to content

Commit

Permalink
Chore Refactor legacy and docs (#182)
Browse files Browse the repository at this point in the history
* update doc

* chore: delete prompt dependency from thread

* fix: linting

* chore: move prompt to legacy

* fix
  • Loading branch information
henomis committed Mar 15, 2024
1 parent 525cbb0 commit 88bd28b
Show file tree
Hide file tree
Showing 37 changed files with 136 additions and 33 deletions.
9 changes: 8 additions & 1 deletion docs/content/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ You need to set the `COHERE_API_KEY` environment variable to your Cohere API key
You need to set the `HUGGING_FACE_HUB_TOKEN` environment variable to your Hugging Face API key. To get your API key refer to the [Hugging Face website](https://huggingface.co/).

## Nomic
You need to set the `NOMIC_API_KEY` environment variable to your Nomic API key. To get your API key refer to the [Nomic website](https://nomic.ai/).
You need to set the `NOMIC_API_KEY` environment variable to your Nomic API key. To get your API key refer to the [Nomic website](https://nomic.ai/).


## Anthropic
You need to set the `ANTHROPIC_API_KEY` environment variable to your Anthropic API key. To get your API key refer to the [Anthropic website](https://anthropic.com/).

## Voyage AI
You need to set the `VOYAGE_API_KEY` environment variable to your Voyage AI API key. To get your API key refer to the [Voyage AI website](https://www.voyageai.com/).
1 change: 1 addition & 0 deletions docs/content/reference/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LinGoose provides an interface for working with embeddings, allowing developers
- [Ollama](https://ollama.ai)
- [LocalAI](https://localai.io/) (_via OpenAI API compatibility_)
- [Atlas Nomic](https://atlas.nomic.ai)
- [Voyage AI](https://www.voyageai.com/)

## Using Embeddings

Expand Down
1 change: 1 addition & 0 deletions docs/content/reference/llm.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LinGoose supports the following LLM providers API:
- [Ollama](https://ollama.ai)
- [LocalAI](https://localai.io/) (_via OpenAI API compatibility_)
- [Groq](https://groq.com/)
- [Anthropic](https://anthropic.com/)

## Using LLMs

Expand Down
2 changes: 1 addition & 1 deletion examples/chat/functions/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"os"

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

Expand Down
2 changes: 1 addition & 1 deletion examples/chat/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

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

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/jsondb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
"github.com/henomis/lingoose/index/vectordb/jsondb"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/knowledge_base/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/henomis/lingoose/legacy/chat"

"github.com/henomis/lingoose/index/vectordb/jsondb"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
"github.com/henomis/lingoose/types"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/milvus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
milvusdb "github.com/henomis/lingoose/index/vectordb/milvus"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/nomic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
"github.com/henomis/lingoose/index/vectordb/jsondb"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/pinecone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
pineconedb "github.com/henomis/lingoose/index/vectordb/pinecone"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/postgres/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
"github.com/henomis/lingoose/index/vectordb/postgres"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
// uncomment to use postgres
// _ "github.com/lib/pq"
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/qdrant/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
qdrantdb "github.com/henomis/lingoose/index/vectordb/qdrant"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/embeddings/redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/henomis/lingoose/index"
indexoption "github.com/henomis/lingoose/index/option"
"github.com/henomis/lingoose/index/vectordb/redis"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/loader"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/textsplitter"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/llm/mock/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"context"

"github.com/henomis/lingoose/legacy/prompt"
llmmock "github.com/henomis/lingoose/llm/mock"
"github.com/henomis/lingoose/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/llm/openai/stream/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

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

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/callbacks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"

"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/henomis/lingoose/legacy/decoder"
"github.com/henomis/lingoose/legacy/memory/ram"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/henomis/lingoose/history"
"github.com/henomis/lingoose/legacy/chat"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/memory/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/henomis/lingoose/legacy/decoder"
"github.com/henomis/lingoose/legacy/memory/ram"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
llmmock "github.com/henomis/lingoose/llm/mock"
"github.com/henomis/lingoose/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/openai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/henomis/lingoose/legacy/memory/ram"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/henomis/lingoose/legacy/decoder"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
llmmock "github.com/henomis/lingoose/llm/mock"
"github.com/henomis/lingoose/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/splitter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/henomis/lingoose/legacy/memory/ram"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/llm/openai"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/prompt/chat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/henomis/lingoose/legacy/chat"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/prompt/hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/prompt/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/prompt/whisper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion legacy/chat/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion legacy/pipeline/qa/qa.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
indexoption "github.com/henomis/lingoose/index/option"
"github.com/henomis/lingoose/legacy/chat"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion legacy/pipeline/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/henomis/lingoose/legacy/decoder"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
2 changes: 1 addition & 1 deletion legacy/pipeline/summarize/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/henomis/lingoose/document"
"github.com/henomis/lingoose/legacy/pipeline"
"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/legacy/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 12 additions & 4 deletions thread/thread.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package thread

import (
"bytes"
"strings"
"text/template"

"github.com/henomis/lingoose/prompt"
"github.com/henomis/lingoose/types"
)

Expand Down Expand Up @@ -205,12 +206,19 @@ func (c *Content) Format(input types.M) *Content {
return c
}

prompt := prompt.NewPromptTemplate(c.Data.(string))
err := prompt.Format(input)
templateEngine, err := template.New("prompt").
Option("missingkey=zero").Parse(c.Data.(string))
if err != nil {
return c
}
c.Data = prompt.String()

var buffer bytes.Buffer
err = templateEngine.Execute(&buffer, input)
if err != nil {
return c
}

c.Data = buffer.String()

return c
}
Expand Down

0 comments on commit 88bd28b

Please sign in to comment.