Skip to content

Instantly share code, notes, and snippets.

View alexcg1's full-sized avatar

Alex Cureton-Griffiths alexcg1

View GitHub Profile
@alexcg1
alexcg1 / app.py
Created May 30, 2022 14:28
JCloud - faceted search
from jina import Client
from docarray import Document
client = Client("https://8bae9ebaf9.wolf.jina.ai")
query = Document(text="Can I catch COVID from my pet armadillo?")
search_filter = {"source": {"$eq": "biomedical"}}
results = client.search(query, parameters={"filter": search_filter})
@alexcg1
alexcg1 / app.py
Created May 30, 2022 14:03
DocumentArray - from CSV
docs = DocumentArray.from_csv(
"data/community.csv",
field_resolver={"question": "text"}
)
@alexcg1
alexcg1 / indexer.py
Created May 30, 2022 13:59
Jina Client - indexing
client = Client(host=<Flow URL>)
client.index(docs)
@alexcg1
alexcg1 / flow.yml
Last active May 30, 2022 14:06
Knowledge base: Flow YAML (3)
jtype: Flow
with:
protocol: http # remove the port
executors:
- name: encoder
uses: jinahub+docker://SpacyTextEncoder/v0.4 # run everything in docker
uses_with:
model_name: 'en_core_web_md'
replicas: 2 # 2 replicas for faster encoding
resources:
@alexcg1
alexcg1 / searcher.py
Created May 30, 2022 13:46
Jina client - faceted search
from jina import Client
from docarray import Document
client = Client(host='localhost', port=23456)
query = Document(text="Can I catch COVID from my pet armadillo?")
search_filter = {"source": {"$eq": "biomedical"}}
results = client.search(query, parameters={"filter": search_filter})
@alexcg1
alexcg1 / searcher.py
Created May 30, 2022 13:42
Jina Client - simple search
from jina import Client
from docarray import Document
client = Client(host='localhost', port=23456)
query = Document(text="Can I catch COVID from my pet armadillo?")
results = client.search(query)
for result in results:
@alexcg1
alexcg1 / app.py
Created May 30, 2022 13:34
Flow from YAML - load Flow
flow = Flow.load_config("flow.yml")
@alexcg1
alexcg1 / flow.yml
Last active May 30, 2022 14:06
Knowledge base: Flow YAML (2)
jtype: Flow
with:
protocol: http
port: 23456
executors:
- name: encoder
uses: jinahub+docker://SpacyTextEncoder/v0.4
uses_with:
model_name: 'en_core_web_md'
install_requirements: true
@alexcg1
alexcg1 / flow.yml
Last active May 30, 2022 14:05
Knowledge base: Flow YAML (1)
jtype: Flow
with:
protocol: http
port: 23456
executors:
- name: encoder
uses: jinahub+://SpacyTextEncoder/v0.4
uses_with:
model_name: 'en_core_web_md'
install_requirements: true
@alexcg1
alexcg1 / flow.yml
Created May 19, 2022 11:14
JCloud migration - final Flow
jtype: Flow
with:
protocol: http
executors:
- name: encoder
uses: jinahub+docker://CLIPEncoder
resources:
memory: 8G
- name: tensor_deleter
uses: jinahub+docker://TensorDeleter