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.1.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file llm_jina-0.1.1.tar.gz.

File metadata

  • Download URL: llm_jina-0.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 4bfb05d3559f9d773b46c6b2e6f10ece10c626e1bbf55bb7cc4727540592d18a
MD5 5ea29763ee91e06c56d99223deac91ea
BLAKE2b-256 8de40b022997c1007aff6f470c461ecf9bb4018a84bef5aa1f2052730180fc6f

See more details on using hashes here.

File details

Details for the file llm_jina-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_jina-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0231a257fd35356a2453519031865d848bd4d69b755c5593b5df8ad856b8b17b
MD5 c2d0dff9015407d9e27b317b2a1229b9
BLAKE2b-256 c0c7d35b969e5570d9153094a62fa8bcc2e8b38e9e5a5c45912b4ebe8d70b34d

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