Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more resilient anthropic (model settings, mdown prompt structure, json correction) #34

Merged
merged 4 commits into from
May 26, 2024

Conversation

zoharbabin
Copy link
Contributor

making anthropic bedrock model more resilient: boto client config updates, model prompt structure using mdown and better instructions, and using fix_busted_json to resolve cases with llm responding with extra text rather than just json object (requires a dependency lib: fix_busted_json)

- Introduced a dictionary (LLM_MODEL_MAP) to map LLM types and model name prefixes to their respective classes.
- Updated the model prefix extraction logic to correctly handle the structure of model names (e.g., extracting 'anthropic' from 'anthropic.claude-3-sonnet-20240229-v1:0').
- Improved error handling to provide more specific error messages when LLM types or model prefixes are not implemented.
- Added type annotations and imports for better clarity and maintainability.
- Enhanced logging to provide clear information on the LLM provider and model being used.

These changes make the function more resilient, modular, and easier to extend with new LLM models.
…ibility

- Updated Prompter to allow dynamic configuration of model settings through the decorator.
  - Added `model_settings` parameter to the `@Prompter` decorator.
  - Modified `_Pr` class to pass `model_settings` to the LLM provider.

- Refactored BedRockAnthropic to support configurable model settings.
  - Introduced `model_settings` parameter in the constructor to allow dynamic configuration of settings like `max_tokens`, `temperature`, `top_p`, `top_k`, `stop_sequences`, and `anthropic_version`.
  - Ensured `stop_sequences` and `anthropic_version` are always included in the request body.
  - Improved error handling and logging for better traceability.

These changes enhance the flexibility and configurability of the prompter system, allowing for dynamic adjustment of LLM settings to suit different scenarios and requirements.
… updates, model prompt structure using mdown and better instructions, and using fix_busted_json to resolve cases with llm responding with extra text rather than just json object (requires a dependancy lib: fix_busted_json)
@helmanofer helmanofer merged commit 3cf8080 into helmanofer:main May 26, 2024
helmanofer added a commit that referenced this pull request May 26, 2024
…n correction) (#34)

* Refactored get_llm function for improved maintainability and flexibility

- Introduced a dictionary (LLM_MODEL_MAP) to map LLM types and model name prefixes to their respective classes.
- Updated the model prefix extraction logic to correctly handle the structure of model names (e.g., extracting 'anthropic' from 'anthropic.claude-3-sonnet-20240229-v1:0').
- Improved error handling to provide more specific error messages when LLM types or model prefixes are not implemented.
- Added type annotations and imports for better clarity and maintainability.
- Enhanced logging to provide clear information on the LLM provider and model being used.

These changes make the function more resilient, modular, and easier to extend with new LLM models.

* Refactored Prompter and BedRockAnthropic for configurability and flexibility

- Updated Prompter to allow dynamic configuration of model settings through the decorator.
  - Added `model_settings` parameter to the `@Prompter` decorator.
  - Modified `_Pr` class to pass `model_settings` to the LLM provider.

- Refactored BedRockAnthropic to support configurable model settings.
  - Introduced `model_settings` parameter in the constructor to allow dynamic configuration of settings like `max_tokens`, `temperature`, `top_p`, `top_k`, `stop_sequences`, and `anthropic_version`.
  - Ensured `stop_sequences` and `anthropic_version` are always included in the request body.
  - Improved error handling and logging for better traceability.

These changes enhance the flexibility and configurability of the prompter system, allowing for dynamic adjustment of LLM settings to suit different scenarios and requirements.

* Upgrading anthropic bedrock model more resillient: boto client config updates, model prompt structure using mdown and better instructions, and using fix_busted_json to resolve cases with llm responding with extra text rather than just json object (requires a dependancy lib: fix_busted_json)

---------

Co-authored-by: Ofer Helman <[email protected]>
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.

2 participants