Skip to content

Conversation

@brainlid
Copy link
Owner

This change includes the Mimic testing library for mocking out live calls and forcing a specific return value.

Originally, was using LangChain.Utils.ApiOverride which provided process-level result overrides. However, it had the negative requirement of requiring testing-aware to be in the production code, specifically in the ChatXYZ.call functions.

Using Mimic removes that requirement, keeping the production level code cleaner.

The selection of Mimic started in PR #154. I tried out Mimic and liked it well enough.

brainlid added 2 commits July 16, 2024 21:52
- updated LLMChain tests
- removed special test handling code from ChatOpenAI
- setup test helper
- removed production test code from ChatBumblebee
- removed from ChatMistral
- removed from ChatAnthropic
- removed from OpenAIImage
- removed LangChain.Utils.ApiOverride
- migrated more tests to use mimic
  - TextToTitleChain tests
  - RoutingChain tests
  - ChatBumblebee tests
@brainlid brainlid merged commit 0d2dc6a into main Jul 17, 2024
@brainlid brainlid deleted the me-convert-to-mimic branch July 17, 2024 13:44
xhr15 added a commit to bitcrowd/chatbot_ex that referenced this pull request Mar 10, 2025
…chatbot.ex

Langchain.ex has progressed to 0.3.1. We should update to that. However,
it introduces a breaking change:

    Compiling 10 files (.ex)
        error: module LangChain.Utils.ApiOverride is not loaded and could not be found
        │
     12 │   import LangChain.Utils.ApiOverride
        │   ^
        │
        └─ lib/chatbot/llm_mock.ex:12:3: Chatbot.LLMMock (module)

The background is
[this PR](brainlid/langchain#155):

> This change includes the Mimic testing library for mocking out live
> calls and forcing a specific return value.
>
> Originally, was using `LangChain.Utils.ApiOverride` which provided
> process-level result overrides. However, it had the negative
> requirement of requiring testing-aware to be in the production code,
> specifically in the ChatXYZ.call functions.
>
> Using Mimic removes that requirement, keeping the production level
> code cleaner.

The reasoning is sound, however, it crashes with what we do in
`Chatbot.LLMMock`. As LLM Mock is not used in tests (and `LLMMock` does
not have tests itself), I would take it out for now. 

https://bitcrowd.atlassian.net/browse/INTERNAL-501
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

Successfully merging this pull request may close these issues.

2 participants