Skip to main content

LLM helpers for SRX services: ChatOpenAI wrapper, tool base and Tavily tool

Project description

srx-lib-llm

LLM helpers for SRX services built on LangChain.

What it includes:

  • responses_chat(prompt, cache=False): simple text chat via OpenAI Responses API
  • Tool strategy base and registry
  • Tavily search tool strategy
  • Structured output helpers: build Pydantic model from JSON Schema and generate structured outputs via LLM
  • Request models, e.g. DynamicStructuredOutputRequest

Designed to work with official OpenAI only.

Install

PyPI (public):

  • pip install srx-lib-llm

uv (pyproject):

[project]
dependencies = ["srx-lib-llm>=0.1.0"]

Usage

from srx_lib_llm import responses_chat
text = await responses_chat("Hello there", cache=True)

Structured output from JSON Schema:

from srx_lib_llm import StructuredOutputGenerator, build_model_from_schema, preprocess_json_schema

json_schema = {
  "type": "object",
  "properties": {
    "title": {"type": "string"},
    "score": {"type": "number"}
  },
  "required": ["title"]
}

gen = StructuredOutputGenerator()
model = build_model_from_schema("MyOutput", preprocess_json_schema(json_schema))
result = await gen.generate_from_model("Give me a title and score", model)
print(result.model_dump())

All-in-one extraction:

from srx_lib_llm import extract_structured

result = await extract_structured(
    text="Analyze this text...", json_schema=my_schema, schema_name="MyOutput"
)
print(result.model_dump())

Back-compat helpers and request models:

from srx_lib_llm import create_dynamic_schema, DynamicStructuredOutputRequest

schema_model = create_dynamic_schema("MyOutput", json_schema)
payload = DynamicStructuredOutputRequest(text="...", json_schema=json_schema)

Tools:

from srx_lib_llm.tools import ToolStrategyBase, register_strategy, get_strategies
from srx_lib_llm.tools.tavily import TavilyToolStrategy

register_strategy(TavilyToolStrategy())
strategies = get_strategies()

Environment Variables

  • OPENAI_API_KEY (required)
  • OPENAI_MODEL (optional, default: gpt-4.1-nano)
  • TAVILY_API_KEY (optional, for the Tavily tool)

Release

Tag vX.Y.Z to publish to GitHub Packages via Actions.

License

Proprietary © SRX

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

srx_lib_llm-0.1.8.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

srx_lib_llm-0.1.8-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file srx_lib_llm-0.1.8.tar.gz.

File metadata

  • Download URL: srx_lib_llm-0.1.8.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for srx_lib_llm-0.1.8.tar.gz
Algorithm Hash digest
SHA256 689b19226cedbf6ed6d798c2fc33372c2193cd3806849f911c20b3c8d3eabb9d
MD5 6530cc58624a228531c99054dc0c8c4e
BLAKE2b-256 7243ca27c137fb98fb8750a491ef04fb5c8bb1a9758de3a927f7c62fee476dda

See more details on using hashes here.

File details

Details for the file srx_lib_llm-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: srx_lib_llm-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for srx_lib_llm-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 eacc545f6be5ee5de4e79a83eb0cc7984a3858039de75ef5ae902966fd1f1c8b
MD5 de092fc2616a1f36fd7e04a160405854
BLAKE2b-256 d90fe0746f8f63712f4d80b2f21e75d19cdfba82d0e636e7831d8475349ad90b

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