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

Unbound prompt_params or messages from model_request objects for better reusing. #8

Open
unownone opened this issue Dec 14, 2023 · 0 comments

Comments

@unownone
Copy link
Contributor

unownone commented Dec 14, 2023

Summary

Currently we need to pass the prompt_params along with a given request object like we do in claude2_request.

...
messages = [
    {"role": "user", "content": "Write me a short poem"},
]
prompt_params = GenerationParams(messages=messages)
claude2_request = ModelGenerationRequest(
    model_name=ModelsEnum.CLAUDE_INSTANT_12,
    provider_name=ProvidersEnum.ANTHROPIC.value,
    order=1,
    prompt_params=prompt_params,
)
...

While we can possibly update the prompt_params later on by passing a new value by:

claude2_request.prompt_params = new_prompt_params

This makes it a dirty and implicit way of passing messages to the context.

Proposal

Update client.generate to accept prompt_params or messages separately ( assuming that prompt_params are model agnostic ).
Hence the following snippet would look like this:

prompt_params = GenerationParams(messages=messages)
claude2_request = ModelGenerationRequest(
    model_name=ModelsEnum.CLAUDE_INSTANT_12,
    provider_name=ProvidersEnum.ANTHROPIC.value,
    order=1,
)
...
response = client.generate(ordered_generation_requests=[claude2_request], messages=prompt_params)

The benefit of doing this would be:

  • Messages are decoupled from Model Request Objects and hence reusing them would be easier, ie one can generate multiple request objects and create a configuration of their request objects and reuse them with the same messages.
claude2_request_prio = ModelGenerationRequest(...)
claude_request_prio = ModelGenerationRequest(...)
openapi_request_non_prio = ModelGenerationRequest(...)
# Generation Request lists that can be reused as per requirement
main_generation_request_list = [
    claude2_request_prio,
    claude_request_prio,
    openapi_request_non_prio
]
...

# Generation request list is passed to `client.generate()` when a message is received
response = client.generate(ordered_generation_requests=main_generation_request_list, messages=prompt_params)
@unownone unownone changed the title Unboun Unbound prompt_params or messages from model_request objects for better reusing. Dec 14, 2023
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

No branches or pull requests

1 participant