Provides a unified interface for interacting with Large Language Models (LLMs) through various providers including OpenAI https://platform.openai.com/docs/api-reference, Ollama https://ollama.com/, and other OpenAI-compatible APIs. Features include automatic connection testing, max_tokens limit auto-adjustment, structured JSON responses with schema validation, interactive JSON schema generation, prompt templating, and comprehensive diagnostics.
The llmhelper package provides a unified and user-friendly interface for interacting with Large Language Models (LLMs) through various providers including OpenAI, Ollama, and other OpenAI-compatible APIs.
llm_providerCreate an OpenAI-compatible LLM provider
llm_ollamaCreate an Ollama LLM provider
get_llm_responseGet text or JSON responses from LLM
build_promptBuild prompts from templates
set_promptCreate prompt objects
generate_json_schemaInteractively generate JSON schemas
diagnose_llm_connectionDebug connection issues
ollama_list_modelsList available Ollama models
ollama_download_modelDownload Ollama models
ollama_delete_modelDelete Ollama models
The package uses the following environment variables:
Default API key for LLM providers
OpenAI API key
DeepSeek API key
Maintainer: Zaoqu Liu liuzaoqu@163.com (ORCID)
Zaoqu Liu liuzaoqu@163.com
Useful links:
Useful links: