feat(clients): add Together AI fine-tuning provider#9987
Conversation
Greptile SummaryThis PR adds Together AI as a fine-tuning provider. The main changes are:
Confidence Score: 4/5Mostly safe to merge after the model-name handling bug is fixed. The main fine-tuning flow is covered by tests, but prefix removal can submit the wrong base model for names containing
What T-Rex did
Important Files Changed
Reviews (5): Last reviewed commit: "fix(clients): strip together_ai/ prefix ..." | Re-trigger Greptile |
|
Thanks for the review! Addressed:
On the fresh Together client per poll tick — left as-is intentionally: it's created once per 60s poll and is cheap (mirrors the Databricks provider), so reusing one would add complexity for negligible benefit. |
Adds TogetherProvider, a fine-tuning Provider for Together AI (mirrors databricks.py). It saves training data to JSONL, uploads it, creates a fine-tune job, polls until completion, and returns the resulting together_ai/<name> model. Includes mocked unit tests that exercise the full finetune() flow without live API calls. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- validate training data against its declared format via validate_data_format - delete the local JSONL after upload (try/finally) - raise a clear error if a completed job returns no output model name Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Return None (matching the databricks provider) instead of calling the Together API with a None job id. Adds a test for the pre-job case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45d1a3a to
e52f32a
Compare
|
Hi @isaacbmiller — thanks for all the review-and-merge work on the repo lately! Checking in on this one when you have a moment. The Greptile feedback is addressed, and I've just rebased onto the latest For context: this provider mirrors the existing |
…PI call Together's fine-tuning API expects the bare model name, but finetune() was forwarding the full DSPy/LiteLLM-prefixed name (e.g. together_ai/meta-llama/ Llama-3-8b). Add _remove_provider_prefix() (mirrors OpenAIProvider) and strip the prefix before calling client.fine_tuning.create. Adds a test asserting the bare model name is passed to the API.
|
Quick update: pushed a fix for the model-prefix issue Greptile flagged. Added a |
| def _remove_provider_prefix(model: str) -> str: | ||
| # Together's API wants the bare model name, so strip DSPy's "together_ai/" routing prefix. | ||
| provider_prefix = "together_ai/" | ||
| return model.replace(provider_prefix, "") |
There was a problem hiding this comment.
Strip only the prefix
_remove_provider_prefix() removes every together_ai/ segment in the model string, not just the routing prefix. A valid bare Together model path that itself contains this substring, e.g. org/together_ai/model, is rewritten to org/model before fine_tuning.create, so the API receives the wrong base model.
| return model.replace(provider_prefix, "") | |
| return model[len(provider_prefix) :] if model.startswith(provider_prefix) else model |
Artifacts
Repro: focused pytest harness for TogetherProvider.finetune model argument
- Evidence file captured while the check ran.
Repro: verbose pytest output showing wrong create model argument and assertion failure
- The full command output behind this check.
What
Adds
TogetherProvider, a fine-tuning provider for Together AI, mirroringdspy/clients/databricks.py.Details
finetune()saves training data to JSONL, uploads it, creates a Together fine-tune job, polls until it completes (raises on error/cancelled), and returns the model astogether_ai/<name>.togetheris imported lazily (optional dependency).TrainingJobTogether.status()reports job status, andis_provider_model()recognizestogether_ai/model names.Tests
tests/clients/test_togetherai.py— a pure-logic test foris_provider_model, plus a mocked test that runs the fullfinetune()flow against a faketogetherclient (no live API calls; runs in CI).🤖 Generated with Claude Code