Skip to main content

Yet another LLM access to DeepSeek's API

Project description

llm-deepseek-ya

PyPI GitHub release (latest by date including pre-releases) License

LLM access to DeepSeek's API

Installation

Install this plugin in the same environment as LLM.

llm install llm-deepseek-ya

Usage

First, set an API key for DeepSeek:

llm keys set deepseek
# Paste key here

Run llm models to list the models, and llm models --options to include a list of their options.

Running Prompts

Run prompts like this:

llm -m deepseek-chat "Describe a futuristic city on Mars"
llm -m deepseek-chat-completion "The AI began to dream, and in its dreams," -o echo true
llm -m deepseek-reasoner "Write a Python function to sort a list of numbers"

Note: The DeepSeek Reasoner model only supports the chat endpoint, not the completion endpoint.

DeepSeek Reasoner Model

The DeepSeek Reasoner model uses a Chain of Thought (CoT) approach to solve complex problems, showing its reasoning process before providing the final answer.

The plugin shows the model's chain of thought reasoning by default in non-streaming mode. The reasoning feature is currently only supported in non-streaming mode.

# Normal usage - will show reasoning by default
llm -m deepseek-reasoner "What is 537 * 943?"

# Hide reasoning when you only want the final answer
llm -m deepseek-reasoner "What is 537 * 943?" -o show_reasoning false

Features

Prefill

The prefill option allows you to provide initial text for the model's response. This is useful for guiding the model's output.

Example:

llm -m deepseek-chat "What are some wild and crazy activities for a holiday party?" -o prefill "Here are some off-the-wall ideas to make your holiday party unforgettable [warning: these may not be suitable for work holiday parties]:"

You can also load prefill text from a file:

# Create a file with your prefill text
echo "Here are some unique holiday party ideas:" > prefill.txt

# Use the file path as the prefill value
llm -m deepseek-chat "What are some fun activities for a holiday party?" -o prefill prefill.txt

This is especially useful for longer prefill text that would be unwieldy on the command line.

JSON Response Format

The response_format option allows you to specify that the model should output its response in JSON format. To ensure the model outputs valid JSON, include the word "json" in the system or user prompt. Optionally, you can provide an example of the desired JSON format to guide the model.

Example:

llm -m deepseek-chat "What are some fun activities for a holiday party?" -o response_format json_object --system "json"

To guide the model further, you can provide an example JSON structure:

llm -m deepseek-chat "What are some way to tell if a holiday party is fun?" -o response_format json_object --system 'EXAMPLE JSON OUTPUT: {"event": "holiday_party_fun", "success_metric": ["..."]}'

JSON Schema Support

DeepSeek Chat models support JSON schema output (via LLM's --schema option). When you provide a schema, the plugin automatically enables JSON mode and includes the schema in the system message to guide the model's output.

Important Note: DeepSeek's API does not validate the output against the schema - it only uses JSON mode. The schema is provided to the model as guidance, so the model will attempt to follow it, but strict validation is not enforced.

Example:

llm -m deepseek-chat "Generate a user profile" --schema '{"type": "object", "properties": {"name": {"type": "string"}, "age": {"type": "number"}, "email": {"type": "string"}}, "required": ["name", "age"]}'

You can also use LLM's schema file support:

# Create a schema file
cat > user_schema.json << 'EOF'
{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "number"},
    "email": {"type": "string"},
    "interests": {"type": "array", "items": {"type": "string"}}
  },
  "required": ["name", "age"]
}
EOF

# Use the schema file
llm -m deepseek-chat "Generate a user profile for a software developer" --schema user_schema.json

Development

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

cd llm-deepseek-ya
python3 -m venv venv
source venv/bin/activate

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_deepseek_ya-1.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_deepseek_ya-1.0.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file llm_deepseek_ya-1.0.0.tar.gz.

File metadata

  • Download URL: llm_deepseek_ya-1.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for llm_deepseek_ya-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dd2094807936e8aba47bb42dfca319c641876cbcfc3b2c0714b8639ccd1b2665
MD5 5619e2c7a8064ad0066d1c398e9feebf
BLAKE2b-256 3b74faae50a5ec1825fe77b63edf5d00006e88f1a7f2b62cea420b03c9c99a01

See more details on using hashes here.

File details

Details for the file llm_deepseek_ya-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_deepseek_ya-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b792eca8ba81953e3f9fdb2414d12f9a1d275707bd05bf6af1c2cfda63aeeb7
MD5 4717dfa70f2df2f6cde4fa9859f3dc77
BLAKE2b-256 300054a946512a748a13e32ee46396eb8c28bdc4bbb2e17580df67ad613b6bb8

See more details on using hashes here.

Supported by

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