Repository: truera/trulens
Issue: [BUG] Langchain provider keeps throwing "unexpected keyword argument 'temperature'" error.
Root cause: Interface Contract Mismatch

**Bug Description**
Running feedback using Langchain provider will end with the "unexpected keyword argument 'temperature'" error.

**To Reproduce**
```
from langchain_ollama import ChatOllama
from trulens.providers.langchain import Langchain
from trulens.core import Feedback

llm = ChatOllama(
    model='deepseek-r1',
    temperature=0,
)

langchain_provider = Langchain(chain=llm)

relevance = Feedback(
    langchain_provider.relevance_with_cot_reasons
).on_input_output()

langchain_provider.relevance_with_cot_reasons(
    "What is a good name for a store that sells colorful socks?",
    "Great question! Naming a store that sells colorful socks can be a fun and creative process. Here are some suggestions to consider: SoleMates: This name plays on the idea of socks being your soul mate or partner in crime for the day. It is catchy and easy to remember, and it conveys the idea that the store offers a wide variety of sock styles and colors.",
)
```

**Expected Behavior**
I expect this to work like with other providers.

**Relevant Logs/Tracebacks**
```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[14], line 27
     22 # Define a relevance function using LiteLLM
     23 relevance = Feedback(
     24     langchain_provider.relevance_with_cot_reasons
     25 ).on_input_output()
---> 27 langchain_provider.relevance_with_cot_reasons(
     28     "What is a good name for a store that sells colorful socks?",
     29     "Great question! Naming a store that sells colorful socks can be a fun and creative process. Here are some suggestions to consider: SoleMates: This name plays on the idea of socks being your soul mate or partner in crime for the day. It is catchy and easy to remember, and it conveys the idea that the store offers a wide variety of sock styles and colors.",
     30 )

File ~/projects/voice-order/.venv/lib/python3.12/site-packages/trulens/feedback/llm_provider.py:626, in LLMProvider.relevance_with_cot_reasons(self, prompt, response, criteria, examples, min_score_val, max_score_val, temperature)
    618 user_prompt = str.format(
    619     feedback_prompts.ANSWER_RELEVANCE_USER,
    620     prompt=prompt,
    621     response=response,
    622 )
    623 user_prompt = user_prompt.replace(
    624     "RELEVANCE:", feedback_prompts.COT_REASONS_TEMPLATE
    625 )
--> 626 return self.generate_score_and_reasons(
    627     system_prompt=system_prompt,
    628     user_prompt=user_prompt,
    629     min_score_val=min_score_val,
    630     max_score_val=max_score_val,
    631     temperature=temperature,
    632 )

File ~/projects/voice-order/.venv/lib/python3.12/site-packages/trulens/feedback/llm_provider.py:249, in LLMProvider.generate_score_and_reasons(self, system_prompt, user_prompt, min_score_val, max_score_val, temperature)
    245     # Don't pass temperature to reasoning models as they don't support it
    246 else:
    247     extra_kwargs["temperature"] = temperature
--> 249 response = self.endpoint.run_in_pace(
    250     func=self._create_chat_completion,
    251     messages=llm_messages,
    252     response_format=response_format,
    253     **extra_kwargs,
    254 )
    256 criteria_field = "Criteria"
    257 supporting_evidence_field = "Supporting Evidence"

File ~/projects/voice-order/.venv/lib/python3.12/site-packages/trulens/core/feedback/endpoint.py:340, in Endpoint.run_in_pace(self, func, *args, **kwargs)
    337             sleep(retry_delay)
    338             retry_delay *= 2
--> 340 raise RuntimeError(
    341     f"Endpoint {self.name} request failed {attempts} time(s): \n\t"
    342     + ("\n\t".join(map(str, errors)))
    343 )

RuntimeError: Endpoint LangchainEndpoint request failed 4 time(s): 
	Client.chat() got an unexpected keyword argument 'temperature'
	Client.chat() got an unexpected keyword argument 'temperature'
	Client.chat() got an unexpected keyword argument 'temperature'
	Client.chat() got an unexpected keyword argument 'temperature'
```

**Environment:**

- OS: WSL
- Python Version: 3.12.3
- TruLens version: 2.1.4
- Versions of other relevant installed libraries: trulens libraries all at 2.1.4



<!-- Greeting -->
Hi @tfs-hendricks! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the trulens team.

<!-- Answer -->
This is a known compatibility issue: the Langchain provider in TruLens passes a temperature argument to the underlying model, but ChatOllama's client does not accept it, resulting in the "unexpected keyword argument 'temperature'" error. This has been reported and tracked in the repository, and currently there are no documented workarounds to prevent the provider from passing unsupported arguments in this context. You may want to try a different provider or monitor the issue for updates and fixes as they become available.  
[See the matching GitHub issue for details.](https://github.com/truera/trulens/issues/2166)


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bf85dc9c-4f82-4ab8-af50-258bc9e9865a?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e16d1378-a540-46b6-bd0e-816c493d2aee/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/truera/trulens/issues/2166)

@dosu ChatOllama does take in temperature as a kwarg. The matching GitHub issue you linked is this issue...

<!-- Answer -->
You're right—your traceback shows the error is coming from Client.chat(), not directly from ChatOllama. Even if ChatOllama's constructor accepts temperature, the error suggests that somewhere in the call stack, a lower-level method (likely the underlying client or API wrapper used by ChatOllama) does not accept temperature as a kwarg, which causes the failure when TruLens passes it through. This points to a mismatch between how TruLens expects to interact with Langchain models and how the langchain_ollama integration is implemented in your environment. 

To resolve this, you'll want to check the signature of the actual chat/completion method being called under the hood by ChatOllama in your installed langchain_ollama version. If that method doesn't accept temperature, that's where the incompatibility lies—even if the top-level class does. This is a subtle but common issue when wrappers or providers evolve at different rates. 

There are no other open or resolved issues in the repo about this specific error with ChatOllama and temperature, so this is the canonical thread for the problem at the moment.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/16b27159-043d-46df-89aa-e5e36396802e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e16d1378-a540-46b6-bd0e-816c493d2aee/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/truera/trulens/issues/2166)

Hey @tfs-hendricks - this issue is a result of deepseek (and other reasoning models) no longer using temperature as a parameter (we are sending temp=0, which causes this error). 

Working on a fix for the langchain provider to support these models (I've implemented a similar fix for openai provider here: https://github.com/truera/trulens/pull/2189)

Hey again - here's a PR that should fix your issue. @tfs-hendricks can you try installing from this branch and let me know?

https://github.com/truera/trulens/pull/2191