Skip to content

feat(dictation): add the documented llm request to DictationConfig - #320

Open
mayankbohradev wants to merge 1 commit into
AssemblyAI:masterfrom
mayankbohradev:feat/dictation-llm-request
Open

mayankbohradev wants to merge 1 commit into
AssemblyAI:masterfrom
mayankbohradev:feat/dictation-llm-request

Conversation

@mayankbohradev

Copy link
Copy Markdown
Contributor

What

Adds DictationConfig.llm, so the SDK can send the documented "Sending your own LLM request" rewrite: your own messages/prompt with {{turn}}, or a saved prompt by aai_prompt.

Why

Closes #299. DictationConfig rejects unknown fields, and it had no llm field. So DictationConfig(llm=...) raised, and the saved-prompt flow that the "Authenticate your app" page recommends for on-device apps could not be sent from the SDK.

How

  • DictationLLMRequest: a new model with the 13 fields the docs list (model, messages, prompt, temperature, top_p, top_k, max_tokens, max_completion_tokens, response_format, reasoning_effort, aai_prompt, prompt_replacements, zero_data_retention). Unknown fields are rejected, as on DictationConfig. A plain dict works too.
  • The documented 400s are checked before anything is sent:
    • llm together with llm_instruction
    • max_tokens or max_completion_tokens above 8192
    • any field other than prompt_replacements alongside aai_prompt
    • rewrite_mode with a saved prompt
    • text or transcript in prompt_replacements
    • prompt_replacements without aai_prompt
  • Model names are not checked. That list changes, so the server decides.
  • Unset fields are not sent, and {{turn}} goes out unchanged.
  • README has a new "Send your own LLM request" section. CLAUDE.md is updated. Version is 1.10.17.

Testing

  • 22 new test cases in test_dictation.py and test_dictation_async.py. They read the config part that is actually sent. Each rule has a test, and each test failed before the change.
  • tox -e py312-latest,py311-pydantic1.10: all pass, except test_tts.py::test_a_forked_child_does_not_share_the_parents_tts_connections, which fails the same way on master on my machine.
  • ruff format --check and ruff check are clean.
  • mypy --follow-imports=silent --ignore-missing-imports on the changed files: no new errors. It reports the two read() override errors that are already on master.
  • scripts/build_api_docs.sh + docs/check_api_docs.py: OK, and DictationLLMRequest is documented.

Notes for reviewers

DictationConfig rejects unknown fields and had no llm field, so the
documented custom LLM request and the saved-prompt (aai_prompt) flow
could not be sent from the SDK.

Add DictationLLMRequest with the 13 fields the docs list, and
DictationConfig.llm. The config is rejected before sending for the
documented 400s: llm with llm_instruction, max_tokens or
max_completion_tokens above 8192, other fields or rewrite_mode with
aai_prompt, text or transcript in prompt_replacements, and
prompt_replacements without aai_prompt. Model names are left to the
server.

Closes AssemblyAI#299

This branch has not been deployed

No deployments
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.

DictationConfig has no llm field: documented custom LLM request / aai_prompt unreachable

1 participant