Skip to main content

LLM plugin for interacting with Jina AI APIs

Project description

llm-jina

PyPI Changelog License

LLM plugin for interacting with Jina AI APIs

Table of Contents

Installation

Install this plugin in the same environment as LLM.

llm install llm-jina

Configuration

You need to set the JINA_API_KEY environment variable with your Jina AI API key. You can get a free API key from https://jina.ai/?sui=apikey.

export JINA_API_KEY=your_api_key_here

Usage

This plugin adds several commands to interact with Jina AI APIs:

Embedding

Generate embeddings for given texts:

llm jina embed "The quick brown fox jumps over the lazy dog."

You can specify a different model using the --model option:

llm jina embed "To be, or not to be, that is the question." --model jina-embeddings-v2-base-en

Reranking

Rerank documents based on a query:

llm jina rerank "Best sci-fi movies" "Star Wars: A New Hope" "The Matrix" "Blade Runner" "Interstellar" "2001: A Space Odyssey"

You can specify a different model using the --model option:

llm jina rerank "Healthy eating tips" "Eat more fruits and vegetables" "Limit processed foods" "Stay hydrated" --model jina-reranker-v2-base-en 

URL Reading

Read and parse content from a URL:

llm jina read https://en.wikipedia.org/wiki/Artificial_intelligence

You can include link and image summaries:

llm jina read https://www.nasa.gov/topics/moon-to-mars --with-links --with-images

Web Search

Search the web for information:

llm jina search "History of the internet"

You can limit the search to a specific domain:

llm jina search "Python programming tutorials" --site docs.python.org 

Example with multiple options:

llm jina search "Climate change impacts" --site nasa.gov --with-links --with-images

Fact Checking

Verify the factual accuracy of a statement:

llm jina ground "The Mona Lisa was painted by Leonardo da Vinci."

You can provide specific sites for grounding:

llm jina ground "Jina AI offers state-of-the-art AI models." --sites https://jina.ai,https://docs.jina.ai

Text Segmentation

Segment text into tokens or chunks:

llm jina segment --content "Space: the final frontier. These are the voyages of the starship Enterprise. Its five-year mission: to explore strange new worlds. To seek out new life and new civilizations. To boldly go where no man has gone before
In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep." --tokenizer cl100k_base --return-chunks

Example response:

{
  "chunks": [
    "Space: the final frontier. These are the voyages of the starship Enterprise. Its five-year mission: to explore strange new worlds. To seek out new life and new civilizations. To boldly go where no man has gone before\n",
    "In the beginning God created the heaven and the earth. And the earth was without form, and void; and darkness was upon the face of the deep."
  ]
}

Classification

Classify inputs into given labels:

llm jina classify "The movie was amazing! I loved every minute of it." "The acting was terrible and the plot made no sense." --labels positive negative neutral 

For image classification:

llm jina classify path/to/cat.jpg path/to/dog.jpg path/to/bird.jpg --labels feline canine avian --image

Code Generation

Generate Jina API code based on a prompt:

llm jina generate-code "Create a function that searches Wikipedia for information about famous scientists and reranks the results based on relevance to the query."
llm jina generate-code "Create a function that searches for information about AI and reranks the results based on relevance"

Metaprompt

Display the Jina metaprompt used for generating code:

llm jina metaprompt

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-jina
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Contributing

Contributions to this plugin are welcome! Please refer to the LLM plugin development documentation for more information on how to get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_jina-0.1a0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

llm_jina-0.1a0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file llm_jina-0.1a0.tar.gz.

File metadata

  • Download URL: llm_jina-0.1a0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for llm_jina-0.1a0.tar.gz
Algorithm Hash digest
SHA256 7092c7d908ef9181f089ffb1a03daf33d541537796da2067faf391a316ce9721
MD5 87e86cbff84420df835a7f44c00f4fa7
BLAKE2b-256 557c0eba5c0ce95ade69e2a0b157cba444f61d278b434b29efa313ae06bc5079

See more details on using hashes here.

File details

Details for the file llm_jina-0.1a0-py3-none-any.whl.

File metadata

  • Download URL: llm_jina-0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for llm_jina-0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 581e14a79a9e7b78d9699162fb4ceb38fec68b159d8c010f544fc13c9d9a1810
MD5 d7427ebb312914843ab1365e99e9b878
BLAKE2b-256 e8d9888e78e09514c52f268f2e87873383688bc1f17c5c14409eab1381f6ffc3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page