Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from typing import Any, Optional, Dict, List | |
import requests | |
from langchain.chains.router.llm_router import RouterChain | |
from langchain_core.callbacks import CallbackManagerForChainRun | |
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env | |
from pydantic import SecretStr, model_validator | |
JINA_API_URL: str = "http://api.jina.ai/v1/classify" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jina import Executor, Document, DocumentArray | |
encoder = Executor.from_hub('jinahub://TransformerTorchEncoder') | |
da = DocumentArray([ | |
Document(text='Jina is a neural search framework.'), | |
Document(text='Jina relies heavily on multiprocessing.'), | |
Document(text='Jina is backed by Jina AI.')]) | |
encoder.encode(docs=da) | |
for doc in da: | |
print(f'{doc.embedding}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformer_tf_text_encode import TransformerTFTextEncoder | |
from jina import Document, DocumentArray | |
encoder = TransformerTFTextEncoder( | |
pretrained_model_name_or_path='hfl/chinese-legal-electra-small-generator', | |
pooling_strategy='cls' | |
) | |
case_1 = { | |
'query': [ |