-
Notifications
You must be signed in to change notification settings - Fork 20
feat(protocol): add user agent #71
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,12 @@ def call( | |
| to_merge_incremental_output = True | ||
| parameters['incremental_output'] = True | ||
|
|
||
| # Pass incremental_to_full flag via headers user-agent | ||
| if 'headers' not in parameters: | ||
| parameters['headers'] = {} | ||
| flag = '1' if to_merge_incremental_output else '0' | ||
| parameters['headers']['user-agent'] = f'incremental_to_full/{flag}' | ||
|
|
||
| response = super().call(model=model, | ||
| task_group=task_group, | ||
| task=Generation.task, | ||
|
|
@@ -354,6 +360,12 @@ async def call( | |
| to_merge_incremental_output = True | ||
| parameters['incremental_output'] = True | ||
|
|
||
| # Pass incremental_to_full flag via headers user-agent | ||
| if 'headers' not in parameters: | ||
| parameters['headers'] = {} | ||
| flag = '1' if to_merge_incremental_output else '0' | ||
| parameters['headers']['user-agent'] = f'incremental_to_full/{flag}' | ||
|
Comment on lines
+366
to
+367
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the synchronous flag = '1' if to_merge_incremental_output else '0'
new_ua_part = f'incremental_to_full/{flag}'
existing_ua = parameters['headers'].get('user-agent', '')
parameters['headers']['user-agent'] = f'{existing_ua}; {new_ua_part}' if existing_ua else new_ua_part |
||
|
|
||
| response = await super().call(model=model, | ||
| task_group=task_group, | ||
| task=Generation.task, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,12 @@ def call( | |
| to_merge_incremental_output = True | ||
| kwargs['incremental_output'] = True | ||
|
|
||
| # Pass incremental_to_full flag via headers user-agent | ||
| if 'headers' not in kwargs: | ||
| kwargs['headers'] = {} | ||
| flag = '1' if to_merge_incremental_output else '0' | ||
| kwargs['headers']['user-agent'] = f'incremental_to_full/{flag}' | ||
|
Comment on lines
+126
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flag = '1' if to_merge_incremental_output else '0'
new_ua_part = f'incremental_to_full/{flag}'
existing_ua = kwargs['headers'].get('user-agent', '')
kwargs['headers']['user-agent'] = f'{existing_ua}; {new_ua_part}' if existing_ua else new_ua_part |
||
|
|
||
| response = super().call(model=model, | ||
| task_group=task_group, | ||
| task=MultiModalConversation.task, | ||
|
|
@@ -287,6 +293,15 @@ async def call( | |
| to_merge_incremental_output = True | ||
| kwargs['incremental_output'] = True | ||
|
|
||
| # Pass incremental_to_full flag via headers user-agent | ||
| if 'headers' not in kwargs: | ||
| kwargs['headers'] = {} | ||
| flag = '1' if to_merge_incremental_output else '0' | ||
| kwargs['headers']['user-agent'] = ( | ||
| kwargs['headers'].get('user-agent', '') + | ||
| f'; incremental_to_full/{flag}' | ||
| ) | ||
|
Comment on lines
+300
to
+303
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current logic for appending to the new_ua_part = f'incremental_to_full/{flag}'
existing_ua = kwargs['headers'].get('user-agent', '')
kwargs['headers']['user-agent'] = f'{existing_ua}; {new_ua_part}' if existing_ua else new_ua_part |
||
|
|
||
| response = await super().call(model=model, | ||
| task_group=task_group, | ||
| task=AioMultiModalConversation.task, | ||
|
|
||
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.
The current implementation overwrites the
user-agentheader. This could lead to loss of information if auser-agentwas already present. It's better to append to the existing user-agent. The suggested change ensures the new user-agent part is appended correctly, handling cases where the user-agent does not exist.