Skip to content

Commit

Permalink
fix: fix helloworld multimodal (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Jan 20, 2022
1 parent dde78e3 commit 4db2069
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
3 changes: 2 additions & 1 deletion jina/helloworld/multimodal/my_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def segment(self, docs: DocumentArray, **kwargs):
uri = f'{os.environ["HW_WORKDIR"]}/people-img/{doc.tags["image"]}'
chunk_text = Document(text=text, mime_type='text/plain')
chunk_uri = Document(uri=uri, mime_type='image/jpeg')
doc.chunks = [chunk_text, chunk_uri]
doc.chunks = DocumentArray([chunk_text, chunk_uri])
doc.uri = uri
doc.convert_uri_to_datauri()

Expand Down Expand Up @@ -191,6 +191,7 @@ def query(self, docs: DocumentArray, **kwargs):
new_matches = DocumentArray()
for match in doc.matches:
extracted_doc = self._docs[match.parent_id]
extracted_doc.scores = match.scores
new_matches.append(extracted_doc)
doc.matches = new_matches

Expand Down
44 changes: 23 additions & 21 deletions jina/helloworld/multimodal/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,27 +139,29 @@
t_id = uuidv4()
i_id = uuidv4()
return {
data: [{
id: p_id,
chunks: [
{
id: t_id,
weight: this.textWeight,
mimeType: "text/plain",
text: this.query.text,
granularity: 1,
parentId: p_id
},
{
id: i_id,
weight: this.imageWeight,
mimeType: "image/jpeg",
uri: this.query.uri,
granularity: 1,
parentId: p_id
}
]
}],
data: {
docs: [{
id: p_id,
chunks: [
{
id: t_id,
weight: this.textWeight,
mimeType: "text/plain",
text: this.query.text,
granularity: 1,
parentId: p_id
},
{
id: i_id,
weight: this.imageWeight,
mimeType: "image/jpeg",
uri: this.query.uri,
granularity: 1,
parentId: p_id
}
]
}]
},
exec_endpoint: '/search',
parameters: {top_k: 20}
}
Expand Down
3 changes: 2 additions & 1 deletion jina/serve/runtimes/gateway/http/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ async def foo(body: JinaRequestModel):
req_generator_input['data'] = req_generator_input['data']['docs']
req_generator_input['data_type'] = DataInputType.DICT

return await _get_singleton_result(request_generator(**req_generator_input))
res = await _get_singleton_result(request_generator(**req_generator_input))
return res

if not args.no_crud_endpoints:
openapi_tags.append(
Expand Down

0 comments on commit 4db2069

Please sign in to comment.