tmc / langchaingo

LangChain for Go, the easiest way to write LLM-based programs in Go
https://tmc.github.io/langchaingo/
MIT License
4.66k stars 627 forks source link

openai: use ollama in test #994

Open codefromthecrypt opened 3 months ago

codefromthecrypt commented 3 months ago

Ollama has some support for openai emulation and could be a nice way to support more tests without requiring an API key or a public endpoint. This might be a nice way to extend coverage of the openai, which could also run relevant versions of the tests also in the ollama llm package. What do you think?

e.g. Some test configuration could work when OPENAI_API_KEY is not set, but OLLAMA_TEST_MODEL is.

    llm, err := openai.New(
        openai.WithBaseURL("http://localhost:11434/v1"),
        openai.WithModel(ollamaModel),
        openai.WithToken("unused"),
        // openai.WithHTTPClient(httputil.DebugHTTPClient),
    )
devalexandre commented 2 months ago

for test, I think that use testcontainer with ollama, but I need try it.

codefromthecrypt commented 2 months ago

yep you can use testcontainers or use a system managed one. If you are using small models the perf hit of running via containers may not be a big deal.

mdelapenya commented 2 weeks ago

@devalexandre there is an Ollama module for Go: https://golang.testcontainers.org/modules/ollama/ 😉