Skip to main content

Chinf

API calls to Cheap Inference without dependencies.

  pip install chinf

Then:

# Python
from yaml import safe_load as yl
from chinf.chat import chat_complete as cc

kwargs = """  # this is a string in YAML format
  max_tokens:   32000
  stop_sequences:
    - STOP
    - "\nTitle"
  temperature:  1.0
  top_k:        10
  top_p:        0.5
  reasoning_effort: high
"""

instruction = 'You are a helpful assistant. Do not use markdown or lists in your responses.'

weather_tool = """ # YAML definition of a function (old format)
  type: function
  function:
    name: get_weather
    description: Determine weather in a location
    parameters:
      type: object
      properties:
        location:
          type: string
          description: The city and state, e.g. San Francisco, CA
      additionalProperties: false
      required:
        - location
"""

tools = [yl(weather_tool)]

msgs = [{'role': 'user', 'content': 'What is the weather in Chicago, IL and Paris, France?'}]

thoughts, text = cc(
    messages=msgs,
    instructions=instruction,
    tools=tools,
    **yl(kwargs)
)

or

from yaml import safe_load as yl
from chinf.messages import message


kwargs = """  # this is a string in YAML format
  max_tokens:   32000
  stop_sequences:
    - STOP
    - "\nTitle"
  temperature:  1.0
  top_k:        10
  top_p:        0.5
  thinking:     
    type: enabled
    budget_tokens: 24576
    display: summarized
  tool_choice:
    type: auto
    disable_parallel_tool_use: false
"""

instruction = 'You are a helpful assistant. Do not use markdown or lists in your responses.'

get_weather_tool_str = """ # YAML definition of a function
    name: get_weather
    description: Determine weather in a location
    input_schema:
      type: object
      properties:
        location:
          type: string
          description: The city and state, e.g. San Francisco, CA
      additionalProperties: true
      required:
        - location
    """

tools = [yl(get_weather_tool_str)]

msg = [{'role': 'user', 'content': 'What is the weather in Chicago, IL and Paris, France?'}]

thoughts, text = message(
    messages=msg,
    instructions=instruction,
    tools=tools,
    **yl(kwargs)
)

or

from yaml import safe_load as yl
from chinf.responses import respond


kwargs = """  # this is a string in YAML format
  max_tokens:   64000
  temperature:  1.0
"""

msgs = [{'role': 'user', 'content': 'What is the weather in Chicago, IL and Paris, France?'}]

weather_tool = """ # YAML definition of a function (new format)
  type: function
  name: get_weather
  description: Determine weather in a location
  parameters:
    type: object
    properties:
      location:
        type: string
        description: The city and state, e.g. San Francisco, CA
    additionalProperties: false
    required:
      - location
"""

tools = [yl(weather_tool)]

instructions = """
You are a helpful assistant.
Rubric: respond in plain text without any markdown, emphasis or lists;
all paragraphs except the first one should begin with a newline and a tab.
"""

thougts, text = respond(
    messages=msgs,
    instructions=instructions,
    tools=tools,
    **yl(kwargs)
)

Download files

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

Source Distribution

chinf-0.0.4.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

chinf-0.0.4-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file chinf-0.0.4.tar.gz.

File metadata

  • Download URL: chinf-0.0.4.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chinf-0.0.4.tar.gz
Algorithm Hash digest
SHA256 758035dcca79130d7d08350b2d4a848dc51b161c8b94edb0f6a46e671ce69b70
MD5 2d6c5f7cd578cb34eda19e7b8ec94a51
BLAKE2b-256 a2ac7994a7a920968ca3b330c85c22975ea6659a0b137700854a4ef626c3d36f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chinf-0.0.4.tar.gz:

Publisher: python-publish.yml on alxfed/chinf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chinf-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: chinf-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for chinf-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 eca0ed8353c85f60e1c740e95b7b78eab8ca6c4233d561afd0591d64f036a737
MD5 6d20f3b609d2cd5707c564b730b27ed3
BLAKE2b-256 0f05c6c6f9196471c6510b23b5ec5598d870f0bb2ce8fe371715b467687d905c

See more details on using hashes here.

Provenance

The following attestation bundles were made for chinf-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on alxfed/chinf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page