edubruell / tidyllm

An tidy interface to large language model APIs for R
https://edubruell.github.io/tidyllm/
Other
36 stars 2 forks source link

Unit tests for embedding api functions #23

Closed edubruell closed 1 month ago

edubruell commented 1 month ago

Description

The embedding API functions (ollama_embedding(), openai_embedding(), mistral_embedding(), etc.) currently do not have full test coverage. While the chat model side has comprehensive tests, the embedding functions need tests to ensure their correctness, particularly for handling edge cases, error handling, and integration with various models and APIs.

Possible Actions

  1. Write Unit Tests for Embedding Functions:

    • Write tests to ensure that embedding functions (ollama_embedding(), openai_embedding(), mistral_embedding()) behave as expected across different scenarios, including:
      • Valid inputs (both LLMMessage objects and character vectors).
      • Return a valid request via .dry_run
  2. Mocking of API Requests with httptest2:

    • Implement mock API responses similar to the chat model functions
    • Ensure that the functions return the correct results based on the simulated API responses.
  3. Test Input Validation:

    • Validate that all input validation logic works as expected:
      • Ensuring correct data types for .llm, .model, .truncate, .timeout, etc.