-
Notifications
You must be signed in to change notification settings - Fork 631
UN-3639 [FEAT] Add VLM/multimodal LLM support for per-prompt vision modes #2131
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
base: main
Are you sure you want to change the base?
Changes from all commits
f778064
24ba26b
e3404b0
8d92ac2
e449a0c
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import django.db.models.deletion | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("adapter_processor_v2", "0001_initial"), | ||
| ("prompt_profile_manager_v2", "0005_profilemanager_shared_to_org_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="profilemanager", | ||
| name="vector_store", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| db_comment="Field to store the chosen vector store.", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="profiles_vector_store", | ||
| to="adapter_processor_v2.adapterinstance", | ||
|
Check failure on line 21 in backend/prompt_studio/prompt_profile_manager_v2/migrations/0006_make_extraction_adapters_nullable.py
|
||
| ), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="profilemanager", | ||
| name="embedding_model", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| null=True, | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="profiles_embedding_model", | ||
| to="adapter_processor_v2.adapterinstance", | ||
| ), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="profilemanager", | ||
| name="x2text", | ||
| field=models.ForeignKey( | ||
| blank=True, | ||
| db_comment="Field to store the X2Text Adapter chosen by the user", | ||
| null=True, | ||
| on_delete=django.db.models.deletion.PROTECT, | ||
| related_name="profiles_x2text", | ||
| to="adapter_processor_v2.adapterinstance", | ||
| ), | ||
| ), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -411,6 +411,10 @@ def _build_prompt_output( | |||||||||
| if lookup_config := get_lookup_config(prompt): | ||||||||||
| output["lookup_config"] = lookup_config | ||||||||||
|
|
||||||||||
| # Vision mode fields | ||||||||||
| output[TSPKeys.EXTRACTION_INPUTS] = prompt.extraction_inputs | ||||||||||
| output[TSPKeys.SOURCE_OF_TRUTH] = prompt.source_of_truth | ||||||||||
|
|
||||||||||
| output[TSPKeys.EVAL_SETTINGS] = {} | ||||||||||
| output[TSPKeys.EVAL_SETTINGS][TSPKeys.EVAL_SETTINGS_EVALUATE] = prompt.evaluate | ||||||||||
| output[TSPKeys.EVAL_SETTINGS][TSPKeys.EVAL_SETTINGS_MONITOR_LLM] = [monitor_llm] | ||||||||||
|
|
@@ -825,6 +829,10 @@ def build_fetch_response_payload( | |||||||||
| if lookup_config := get_lookup_config(prompt): | ||||||||||
| output["lookup_config"] = lookup_config | ||||||||||
|
|
||||||||||
| # Vision mode fields | ||||||||||
| output[TSPKeys.EXTRACTION_INPUTS] = prompt.extraction_inputs | ||||||||||
| output[TSPKeys.SOURCE_OF_TRUTH] = prompt.source_of_truth | ||||||||||
|
|
||||||||||
| output[TSPKeys.EVAL_SETTINGS] = {} | ||||||||||
| output[TSPKeys.EVAL_SETTINGS][TSPKeys.EVAL_SETTINGS_EVALUATE] = prompt.evaluate | ||||||||||
| output[TSPKeys.EVAL_SETTINGS][TSPKeys.EVAL_SETTINGS_MONITOR_LLM] = [monitor_llm] | ||||||||||
|
|
@@ -874,6 +882,7 @@ def build_fetch_response_payload( | |||||||||
| TSPKeys.FILE_NAME: doc_name, | ||||||||||
| TSPKeys.FILE_HASH: file_hash, | ||||||||||
| TSPKeys.FILE_PATH: extract_path, | ||||||||||
| TSPKeys.SOURCE_FILE_PATH: file_path, | ||||||||||
| Common.LOG_EVENTS_ID: StateStore.get(Common.LOG_EVENTS_ID), | ||||||||||
| TSPKeys.EXECUTION_SOURCE: ExecutionSource.IDE.value, | ||||||||||
| TSPKeys.CUSTOM_DATA: tool.custom_data, | ||||||||||
|
|
@@ -1064,6 +1073,7 @@ def build_bulk_fetch_response_payload( | |||||||||
| TSPKeys.FILE_NAME: doc_name, | ||||||||||
| TSPKeys.FILE_HASH: file_hash, | ||||||||||
| TSPKeys.FILE_PATH: extract_path, | ||||||||||
| TSPKeys.SOURCE_FILE_PATH: file_path, | ||||||||||
| Common.LOG_EVENTS_ID: StateStore.get(Common.LOG_EVENTS_ID), | ||||||||||
| TSPKeys.EXECUTION_SOURCE: ExecutionSource.IDE.value, | ||||||||||
| TSPKeys.CUSTOM_DATA: tool.custom_data, | ||||||||||
|
|
@@ -1225,6 +1235,7 @@ def build_single_pass_payload( | |||||||||
| TSPKeys.FILE_HASH: file_hash, | ||||||||||
| TSPKeys.FILE_NAME: doc_name, | ||||||||||
| TSPKeys.FILE_PATH: file_path, | ||||||||||
| TSPKeys.SOURCE_FILE_PATH: doc_path, | ||||||||||
| Common.LOG_EVENTS_ID: StateStore.get(Common.LOG_EVENTS_ID), | ||||||||||
| TSPKeys.EXECUTION_SOURCE: ExecutionSource.IDE.value, | ||||||||||
| TSPKeys.CUSTOM_DATA: tool.custom_data, | ||||||||||
|
|
@@ -1950,6 +1961,9 @@ def _fetch_response( | |||||||||
| output[TSPKeys.POSTPROCESSING_WEBHOOK_URL] = webhook_url | ||||||||||
| if lookup_config := get_lookup_config(prompt): | ||||||||||
| output["lookup_config"] = lookup_config | ||||||||||
| # Vision mode fields | ||||||||||
| output[TSPKeys.EXTRACTION_INPUTS] = prompt.extraction_inputs | ||||||||||
| output[TSPKeys.SOURCE_OF_TRUTH] = prompt.source_of_truth | ||||||||||
| # Eval settings for the prompt | ||||||||||
| output[TSPKeys.EVAL_SETTINGS] = {} | ||||||||||
| output[TSPKeys.EVAL_SETTINGS][TSPKeys.EVAL_SETTINGS_EVALUATE] = prompt.evaluate | ||||||||||
|
|
@@ -2000,6 +2014,7 @@ def _fetch_response( | |||||||||
| TSPKeys.FILE_NAME: doc_name, | ||||||||||
| TSPKeys.FILE_HASH: file_hash, | ||||||||||
| TSPKeys.FILE_PATH: doc_path, | ||||||||||
| TSPKeys.SOURCE_FILE_PATH: doc_path, | ||||||||||
|
Comment on lines
2016
to
+2017
Contributor
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. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
In 🐛 Proposed fix TSPKeys.FILE_PATH: doc_path,
- TSPKeys.SOURCE_FILE_PATH: doc_path,
+ TSPKeys.SOURCE_FILE_PATH: file_path,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| Common.LOG_EVENTS_ID: StateStore.get(Common.LOG_EVENTS_ID), | ||||||||||
| TSPKeys.EXECUTION_SOURCE: ExecutionSource.IDE.value, | ||||||||||
| TSPKeys.CUSTOM_DATA: tool.custom_data, | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("prompt_studio_v2", "0014_alter_toolstudioprompt_enforce_type"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="toolstudioprompt", | ||
| name="extraction_inputs", | ||
| field=models.TextField( | ||
| choices=[ | ||
| ("text", "Text only (default)"), | ||
| ("image", "Page image only"), | ||
| ("both", "Text and page image"), | ||
| ], | ||
| db_comment="What inputs to send to the LLM: text, image, or both", | ||
| default="text", | ||
| ), | ||
| ), | ||
| migrations.AddField( | ||
| model_name="toolstudioprompt", | ||
| name="source_of_truth", | ||
| field=models.TextField( | ||
| choices=[ | ||
| ("text", "Text is source of truth"), | ||
| ("image", "Image is source of truth"), | ||
| ], | ||
| db_comment="Which input is source of truth " | ||
| "(only meaningful when extraction_inputs=both)", | ||
| default="text", | ||
| ), | ||
| ), | ||
| ] |
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.
{"vector_store": null}the checknot attrs.get(field)evaluates True (None is falsy), butnot getattr(instance, "vector_store_id", None)evaluates False (the old FK is still on the instance), so the field is never added tomissingand the null is saved silently — even when linked prompts still need text extraction. The guard needs to treat an inbound null as a removal, not as "not provided".Prompt To Fix With AI