qtype 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qtype/interpreter/executors/document_embedder_executor.py +17 -1
- qtype/interpreter/executors/invoke_embedding_executor.py +33 -23
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/METADATA +1 -1
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/RECORD +8 -8
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/WHEEL +0 -0
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/entry_points.txt +0 -0
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/licenses/LICENSE +0 -0
- {qtype-0.1.4.dist-info → qtype-0.1.6.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import logging
|
|
1
3
|
from typing import AsyncIterator
|
|
2
4
|
|
|
3
5
|
from botocore.exceptions import ClientError
|
|
@@ -58,7 +60,17 @@ class DocumentEmbedderExecutor(StepExecutor):
|
|
|
58
60
|
Returns:
|
|
59
61
|
The embedding vector as a list of floats.
|
|
60
62
|
"""
|
|
61
|
-
|
|
63
|
+
|
|
64
|
+
# TODO: switch back to async once aws auth supports it.
|
|
65
|
+
# https://github.com/bazaarvoice/qtype/issues/108
|
|
66
|
+
def _call():
|
|
67
|
+
return self.embedding_model.get_text_embedding(text=text)
|
|
68
|
+
|
|
69
|
+
loop = asyncio.get_running_loop()
|
|
70
|
+
response = await loop.run_in_executor(self.context.thread_pool, _call)
|
|
71
|
+
|
|
72
|
+
return response
|
|
73
|
+
# return await self.embedding_model.aget_text_embedding(text=text)
|
|
62
74
|
|
|
63
75
|
async def process_message(
|
|
64
76
|
self,
|
|
@@ -103,5 +115,9 @@ class DocumentEmbedderExecutor(StepExecutor):
|
|
|
103
115
|
except Exception as e:
|
|
104
116
|
# Emit error event to stream so frontend can display it
|
|
105
117
|
await self.stream_emitter.error(str(e))
|
|
118
|
+
logging.error(
|
|
119
|
+
f"Error processing DocumentEmbedder step {self.step.id}",
|
|
120
|
+
exc_info=e,
|
|
121
|
+
)
|
|
106
122
|
message.set_error(self.step.id, e)
|
|
107
123
|
yield message
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
from typing import AsyncIterator
|
|
2
3
|
|
|
3
4
|
from openinference.semconv.trace import OpenInferenceSpanKindValues
|
|
@@ -56,32 +57,41 @@ class InvokeEmbeddingExecutor(StepExecutor):
|
|
|
56
57
|
if input_value is None:
|
|
57
58
|
raise ValueError(f"Input variable '{input_id}' is missing")
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
content = input_value
|
|
73
|
-
else:
|
|
74
|
-
raise ValueError(
|
|
75
|
-
(
|
|
76
|
-
f"Unsupported input type for embedding: "
|
|
77
|
-
f"{input_type}. Must be 'text' or 'image'."
|
|
60
|
+
def _call(input_value=input_value):
|
|
61
|
+
# Generate embedding based on input type
|
|
62
|
+
if input_type == PrimitiveTypeEnum.text:
|
|
63
|
+
if not isinstance(input_value, str):
|
|
64
|
+
input_value = str(input_value)
|
|
65
|
+
vector = self.embedding_model.get_text_embedding(
|
|
66
|
+
text=input_value
|
|
67
|
+
)
|
|
68
|
+
content = input_value
|
|
69
|
+
elif input_type == PrimitiveTypeEnum.image:
|
|
70
|
+
# For image embeddings
|
|
71
|
+
vector = self.embedding_model.get_image_embedding(
|
|
72
|
+
image_path=input_value
|
|
78
73
|
)
|
|
74
|
+
content = input_value
|
|
75
|
+
else:
|
|
76
|
+
raise ValueError(
|
|
77
|
+
(
|
|
78
|
+
f"Unsupported input type for embedding: "
|
|
79
|
+
f"{input_type}. Must be 'text' or 'image'."
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Create the Embedding object
|
|
84
|
+
embedding = Embedding(
|
|
85
|
+
vector=vector,
|
|
86
|
+
content=content,
|
|
79
87
|
)
|
|
88
|
+
return embedding
|
|
80
89
|
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
# TODO: switch back to async once aws auth supports it.
|
|
91
|
+
# https://github.com/bazaarvoice/qtype/issues/108
|
|
92
|
+
loop = asyncio.get_running_loop()
|
|
93
|
+
embedding = await loop.run_in_executor(
|
|
94
|
+
self.context.thread_pool, _call
|
|
85
95
|
)
|
|
86
96
|
|
|
87
97
|
# Yield the result
|
|
@@ -59,7 +59,7 @@ qtype/interpreter/executors/aggregate_executor.py,sha256=Z3NJekpeo7aqqvOcXQqb6d6
|
|
|
59
59
|
qtype/interpreter/executors/bedrock_reranker_executor.py,sha256=p25BMmM1paAlK2vfpwJ9T5st_2B-bmZoDnVFp9ynZIY,7154
|
|
60
60
|
qtype/interpreter/executors/decoder_executor.py,sha256=KqLhnhiclMIcUNf3bu7H4vDAOXCQeVO0rc2hIXm1qZ4,5610
|
|
61
61
|
qtype/interpreter/executors/doc_to_text_executor.py,sha256=ZkTtKUL0BfNIiuj-OcYybn1f0By6ujRmd1U4VEAtJt4,3804
|
|
62
|
-
qtype/interpreter/executors/document_embedder_executor.py,sha256=
|
|
62
|
+
qtype/interpreter/executors/document_embedder_executor.py,sha256=dBx1yfjzGPAOAfCx0zr1uOkfs7JUWgHoKYanqnCFAQk,4089
|
|
63
63
|
qtype/interpreter/executors/document_search_executor.py,sha256=ZmKAt__jC5cxZY0gSm9AgpC6n7MFavTHE01tQED3zFk,4051
|
|
64
64
|
qtype/interpreter/executors/document_source_executor.py,sha256=ZpBrBaE16YeRk750TxvE08NnCIUzArjESZImESomaIo,4247
|
|
65
65
|
qtype/interpreter/executors/document_splitter_executor.py,sha256=00x32yo1wGUvW88_lUahfGU94prUPGaOTk5GBUJbBJA,3882
|
|
@@ -68,7 +68,7 @@ qtype/interpreter/executors/field_extractor_executor.py,sha256=geDmT6GyvbDDJvPX1
|
|
|
68
68
|
qtype/interpreter/executors/file_source_executor.py,sha256=OUT_zJrYN3iFMUgLECde93C4rv8PthcQsuJ--CJvEsI,3605
|
|
69
69
|
qtype/interpreter/executors/file_writer_executor.py,sha256=x4BpgdXM7Xhz1tJJ5MmBIjFO4y80VC1V1ow3tox_Xrw,4099
|
|
70
70
|
qtype/interpreter/executors/index_upsert_executor.py,sha256=5MxG3GX2bbjX6jhCpCdEZ0YFJOshn649cfaOT50PLCA,8518
|
|
71
|
-
qtype/interpreter/executors/invoke_embedding_executor.py,sha256=
|
|
71
|
+
qtype/interpreter/executors/invoke_embedding_executor.py,sha256=5iXh2elP51gdnuUvRDH_RuWugsm3KCJb8S15Oy4p8zg,3834
|
|
72
72
|
qtype/interpreter/executors/invoke_flow_executor.py,sha256=U30cYM3F_zy1_2CD1Dde59xyZD0rDa5W46lST1hxF6s,1682
|
|
73
73
|
qtype/interpreter/executors/invoke_tool_executor.py,sha256=hhbE8YTr0x5-kz_xsvdWGGzkLkVdvDoAVAF-3ZUK5as,12786
|
|
74
74
|
qtype/interpreter/executors/llm_inference_executor.py,sha256=A6b_Ns_734TCn_DMhdNSqWc5qX970FryhpsX_jtEu_4,9593
|
|
@@ -129,9 +129,9 @@ qtype/semantic/loader.py,sha256=QRhTc_AJfsWSMn8ThaW60GmIGjFMN-3bBUy4pktFjz4,3041
|
|
|
129
129
|
qtype/semantic/model.py,sha256=7yZ-Ufuo-gNJbhFXALuKZxILdhNB5zbL3a3oQQARI8g,28602
|
|
130
130
|
qtype/semantic/resolver.py,sha256=bWPCSB8KJpVqN_n41U_r-qzUiT8vAMBOD3pOGmxL6TY,4618
|
|
131
131
|
qtype/semantic/visualize.py,sha256=thjrZcfQuZJWrZ9EMAPhAa2kNikR5rLIJrfcD3hJ8XY,17426
|
|
132
|
-
qtype-0.1.
|
|
133
|
-
qtype-0.1.
|
|
134
|
-
qtype-0.1.
|
|
135
|
-
qtype-0.1.
|
|
136
|
-
qtype-0.1.
|
|
137
|
-
qtype-0.1.
|
|
132
|
+
qtype-0.1.6.dist-info/licenses/LICENSE,sha256=1KA5EgYBSR0O6nCH2HEvk6Di53YKJ9r_VCR7G8G8qAY,11341
|
|
133
|
+
qtype-0.1.6.dist-info/METADATA,sha256=kzhXY2Ol_Ih1R-HZMSTrf_lLpQhjUY0t-JAj-IdYBrU,5657
|
|
134
|
+
qtype-0.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
135
|
+
qtype-0.1.6.dist-info/entry_points.txt,sha256=5y4vj8RLvgl2tXSj-Hm7v5-Tn3kP4-UonjNoN-mfaQE,41
|
|
136
|
+
qtype-0.1.6.dist-info/top_level.txt,sha256=ONroH5B0mZ51jr7NSWCK0weFwwCO7wBLmyVS1YqNU14,6
|
|
137
|
+
qtype-0.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|