Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithStreamingFunc not working in latest version #642

Closed
pnthang01 opened this issue Mar 2, 2024 · 5 comments
Closed

WithStreamingFunc not working in latest version #642

pnthang01 opened this issue Mar 2, 2024 · 5 comments

Comments

@pnthang01
Copy link

Notice that my code didn't send data via WithStreamingFunc to client.
I checked code https://github.com/tmc/langchaingo/blob/e8498f5c2f097cd31c917d2e63b4f6f41c651bf2/chains/options.go in v0.1.5, it's no longer build options from ChainCallOption to CallOption.
Have to downgrade version to v0.1.4.
Or I'm missing something ?

@Abirdcfly
Copy link
Contributor

maybe fixed by #639

@devalexandre
Copy link
Contributor

@pnthang01 I try it, in version v0.1.5 don't work only v0.1.4 @Abirdcfly it isn't fixed in #699

code for test.

package main

import (
	"context"
	"log"

	"github.com/tmc/langchaingo/chains"
	"github.com/tmc/langchaingo/llms/ollama"
	"github.com/tmc/langchaingo/prompts"
)

func main() {
	llm, err := ollama.New(ollama.WithModel("llama2"))
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	prompt := prompts.NewPromptTemplate(
		"Translate the following text from {{.inputLanguage}} to {{.outputLanguage}}. {{.text}}",
		[]string{"inputLanguage", "outputLanguage", "text"},
	)
	llmChain := chains.NewLLMChain(llm, prompt)

	chainOptions := []chains.ChainCallOption{
		chains.WithStreamingFunc(func(ctx context.Context, chuck []byte) error {
			log.Println(string(chuck))
			return nil
		}),
	}
	_, err = chains.Call(ctx, llmChain, map[string]any{
		"inputLanguage":  "English",
		"outputLanguage": "French",
		"text":           "I love programming.",
	}, chainOptions...)

	if err != nil {
		log.Fatal(err)
	}

}

@Abirdcfly
Copy link
Contributor

in version v0.1.5 don't work

you can try main branch, v0.1.5 do not contains #639 ..

@tmc
Copy link
Owner

tmc commented Mar 8, 2024

Yes please try the current unreleased version (you can use @main to target to a pre-release version), I will be tagging and releasing v0.1.6 soon, and in the mean time I have created a pre-release tag called "v0.1.6-alpha.0" that you can point to.

@tmc
Copy link
Owner

tmc commented Mar 8, 2024

@pnthang01 I'm going to presume these instructions address your issue, please reopen if that is not the case and we'll get v0.1.6 tagged and released within a few days.

@tmc tmc closed this as completed Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants