-
Notifications
You must be signed in to change notification settings - Fork 112
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
Refactor streaming and g-sampling FSM logics #239
Conversation
gen_state["func_name"] = func_name | ||
gen_state["func_index"] += 1 | ||
gen_state["call_id"] = prompt_utils.get_random_tool_call_id() | ||
gen_state["first_time_func"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh why this is always True?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is True, it means we need to stream an empty chunk before streaming the chunks containing the function name and arguments. Thereafter, we will set this to False.
empty_response = prompt_utils.get_text_delta_response( | ||
"", True, finish_reason | ||
# Form the options for the following stages | ||
options = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can create a function for getting options, this is kind of duplicate in function: stream_delta_text and grammar_sample
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will do
…mbine-streaming-gsampling-fsm
prompt_template.initialize_fsm_gen_state
initializes prompt template's FSM gen state. Both streaming and gsampling will call this method at the start.prompt_template.stream_delta_text
method that streams specific delta texts and updates the gen state at every iterationasync_llm_engine
will callprompt_template.grammar_sample
method that grammar samples the tokens and updates the gen state at every iterationprompt_template.update_fsm_gen_state
updates the gen_state.