ZIm/crates/assistant/src
邻二氮杂菲 f1778dd9de
Add max_output_tokens to OpenAI models and integrate into requests (#16381)
### Pull Request Title
Introduce `max_output_tokens` Field for OpenAI Models


https://platform.deepseek.com/api-docs/news/news0725/#4-8k-max_tokens-betarelease-longer-possibilities

### Description
This commit introduces a new field `max_output_tokens` to the OpenAI
models, which allows specifying the maximum number of tokens that can be
generated in the output. This field is now integrated into the request
handling across multiple crates, ensuring that the output token limit is
respected during language model completions.

Changes include:
- Adding `max_output_tokens` to the `Custom` variant of the
`open_ai::Model` enum.
- Updating the `into_open_ai` method in `LanguageModelRequest` to accept
and use `max_output_tokens`.
- Modifying the `OpenAiLanguageModel` and `CloudLanguageModel`
implementations to pass `max_output_tokens` when converting requests.
- Ensuring that the `max_output_tokens` field is correctly serialized
and deserialized in relevant structures.

This enhancement provides more control over the output length of OpenAI
model responses, improving the flexibility and accuracy of language
model interactions.

### Changes
- Added `max_output_tokens` to the `Custom` variant of the
`open_ai::Model` enum.
- Updated the `into_open_ai` method in `LanguageModelRequest` to accept
and use `max_output_tokens`.
- Modified the `OpenAiLanguageModel` and `CloudLanguageModel`
implementations to pass `max_output_tokens` when converting requests.
- Ensured that the `max_output_tokens` field is correctly serialized and
deserialized in relevant structures.

### Related Issue
https://github.com/zed-industries/zed/pull/16358

### Screenshots / Media
N/A

### Checklist
- [x] Code compiles correctly.
- [x] All tests pass.
- [ ] Documentation has been updated accordingly.
- [ ] Additional tests have been added to cover new functionality.
- [ ] Relevant documentation has been updated or added.

### Release Notes

- Added `max_output_tokens` field to OpenAI models for controlling
output token length.
2024-08-21 00:39:10 -04:00
..
context Simplify logic & add UI affordances to show model cache status (#16395) 2024-08-19 12:06:14 -07:00
slash_command context_servers: Fix argument handling (#16402) 2024-08-17 20:04:34 -07:00
workflow workflow: Add button to open the step view (#16387) 2024-08-17 13:06:34 -03:00
assistant.rs assistant: Fix toggling slash command menu from toolbar menu (#16459) 2024-08-19 14:47:05 +02:00
assistant_panel.rs Avoid double message header in new contexts, don't expand default prompt (#16490) 2024-08-19 12:54:03 -07:00
assistant_settings.rs Add max_output_tokens to OpenAI models and integrate into requests (#16381) 2024-08-21 00:39:10 -04:00
context.rs Simplify logic & add UI affordances to show model cache status (#16395) 2024-08-19 12:06:14 -07:00
context_store.rs Allow /workflow and step resolution prompts to be overridden (#15892) 2024-08-06 21:47:42 -06:00
inline_assistant.rs assistant: Add imports in a single area when using workflows (#16355) 2024-08-19 19:01:45 +02:00
model_selector.rs Make providers more clear in model selector (#16480) 2024-08-19 13:38:19 -04:00
prompt_library.rs Make unnecessary code fade configurable (#14442) 2024-08-20 13:13:27 -04:00
prompts.rs Improve dev experience for built-in prompts (#16413) 2024-08-17 12:28:53 -06:00
slash_command.rs Display default prompts more elaborately (#16471) 2024-08-19 18:44:52 +03:00
slash_command_picker.rs assistant: Add the "create your command" item (#16467) 2024-08-19 12:29:16 -03:00
slash_command_settings.rs assistant: Put /docs and /project behind a setting (#16186) 2024-08-13 17:32:24 -04:00
streaming_diff.rs Improve streaming git diffs to be less jumpy during inline assistant generation (#15853) 2024-08-06 16:13:29 +03:00
terminal_inline_assistant.rs Implement Anthropic prompt caching (#16274) 2024-08-15 22:21:06 -05:00
workflow.rs assistant: Add imports in a single area when using workflows (#16355) 2024-08-19 19:01:45 +02:00