Skip to content

feat: Implement LLM features using litellm#189

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
feat/implement-llm-features
Draft

feat: Implement LLM features using litellm#189
google-labs-jules[bot] wants to merge 1 commit intomainfrom
feat/implement-llm-features

Conversation

@google-labs-jules
Copy link

This change implements the previously-defined placeholder methods for LLM features using the litellm library. This provides a provider-agnostic way to use different LLMs for summarization, NER, and sentiment analysis. The implementation is configurable via environment variables. Unit tests and documentation have been added.

This commit implements the LLM features that were previously added as placeholders. The implementation uses the `litellm` library to provide a provider-agnostic interface to various Large Language Models.

The `openodia.llm.LLM` class now provides the following methods:
- `summarize`: For abstractive text summarization.
- `named_entity_recognition`: For Named Entity Recognition.
- `sentiment_analysis`: For sentiment analysis.

The implementation is configurable via environment variables:
- `OPENODIA_LLM_MODEL`: To specify the LLM model to use (e.g., `gemini/gemini-pro`, `openai/gpt-4`). Defaults to `gemini/gemini-pro`.
- API keys for the respective services are read from standard environment variables (`GEMINI_API_KEY`, `OPENAI_API_KEY`, etc.).

The documentation has been updated to reflect these changes and provide usage examples.

Unit tests have been added for the new features, using `unittest.mock` to patch the `litellm.completion` function and avoid actual API calls.

The `litellm` library has been added as a dependency in `pyproject.toml`.
@codecov
Copy link

codecov bot commented Aug 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.55%. Comparing base (ac2db15) to head (c604478).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #189      +/-   ##
==========================================
+ Coverage   99.49%   99.55%   +0.06%     
==========================================
  Files           9       10       +1     
  Lines         199      227      +28     
==========================================
+ Hits          198      226      +28     
  Misses          1        1              
Flag Coverage Δ
pytest 99.55% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
openodia/__init__.py 100.00% <100.00%> (ø)
openodia/llm.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac2db15...c604478. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cloudflare-workers-and-pages
Copy link

Deploying openodia with  Cloudflare Pages  Cloudflare Pages

Latest commit: c604478
Status:🚫  Build failed.

View logs

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.

0 participants