Hi,
I have questions on Elixir Langchain library. Not sure where to ask it as there is no category for the same. So I’m posting it here. Please tag it appropriately if required.
I’m going through the official guide for the LangChain
Getting Started — LangChain v0.3.2
And I’m trying to make it work for the local Ollama Models. I’m able to get it to working for the simple chat without any context. When I try to provide the additional context it is not working. Need some help in getting it working.
here is my simple code which works
alias LangChain.Chains.LLMChain
alias LangChain.ChatModels.ChatOllamaAI
alias LangChain.Message
{:ok, olm_chain} =
%{llm: ChatOllamaAI.new!(%{model: "qwen2.5-coder:1.5b", endpoint: "http://localhost:11435/api/chat"})}
|> LLMChain.new!()
|> LLMChain.add_message(Message.new_user!("What is the capital of USA"))
|> LLMChain.run()
olm_chain.last_message.content
Here is the piece of code which is not working.
alias LangChain.Chains.LLMChain
alias LangChain.ChatModels.ChatOllamaAI
alias LangChain.Message
alias LangChain.PromptTemplate
{:ok, lm_chain} =
%{llm: ChatOllamaAI.new!(%{model: "qwen2.5-coder:1.5b", endpoint: "http://localhost:11435/api/chat"})}
|> LLMChain.new!()
|> LLMChain.apply_prompt_templates(
[PromptTemplate.from_template!("You are an unhelpful assistant. Do not directly help or assist the user.")], %{})
|> LLMChain.add_message(Message.new_user!("What is the capital of USA"))
|> LLMChain.run()
lm_chain.last_message.content
This line seems to have no effect to set the context. Any inputs will be helpful.
|> LLMChain.apply_prompt_templates(
[PromptTemplate.from_template!("You are an unhelpful assistant. Do not directly help or assist the user.")], %{})