Skip to main content

Opehaina

Project description

Opehaina

Opehaina

  pip install opehaina

Then:

  # Python
from yaml import safe_load as yl
from opehaina.responses import respond


def get_weather(location):
    # print(f"Executing weather tool for location: {location}")
    return {"temperature": "72F", "condition": "Sunny"}

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

multilogue = "Compare the weather in Oakland, CA and weather in Paris, France. Use the tool for learning both."

get_weather_tool_str = """  # tool definition (new template)
  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(get_weather_tool_str)]

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.
"""

thoughts, text = respond(
    messages=multilogue,
    instructions=instructions,
    tools=tools,
    **yl(kwargs)
)

or

from yaml import safe_load as yl
from opehaina.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
  # thinking:     24576  # thinking tokens budget. 24576
  reasoning_effort: high
"""

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

get_weather_tool_str = """ # tool description (old)
  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(get_weather_tool_str)]

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

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

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

opehaina-0.0.7.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

opehaina-0.0.7-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file opehaina-0.0.7.tar.gz.

File metadata

  • Download URL: opehaina-0.0.7.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opehaina-0.0.7.tar.gz
Algorithm Hash digest
SHA256 fc95181553712e7f2ad457b2ebb698beae5256ebf7c42825200436246ceb0537
MD5 f5ea58419f6bec579e9bc75c4596caa4
BLAKE2b-256 08ef6612bf4737492c50d4f20491d98931f7dda6664695c517e73f2e136ee618

See more details on using hashes here.

Provenance

The following attestation bundles were made for opehaina-0.0.7.tar.gz:

Publisher: python-publish.yml on alxfed/opehaina

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

File details

Details for the file opehaina-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: opehaina-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opehaina-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e4a0b41832c1a493a53b4611d04ca91bfac3cf482298d06514d6f3dbb6e1a5cb
MD5 978561e8a01ec296b8f189a33a974aba
BLAKE2b-256 b72c11a102795bfbc2c5723f44b3cf7c00076d0431ac3d5a8efee48f4c4990f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for opehaina-0.0.7-py3-none-any.whl:

Publisher: python-publish.yml on alxfed/opehaina

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

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