Skip to main content

LLM Tools

This package wraps the OpenAI API and other LLM models that share the completion endpoint feature. It provides a simple interface to generate text from a prompt.

Installation

pip install llm-space

Usage

from llm_space.openai import prompt
from pathlib import Path


# Create a prompt object that will be logged to the `my-task` directory under the
# current working directory.
# The PromptZeros class will use arguments that will maximize the determinism of the outputs.
pz = prompt.PromptZeros(Path("./"), "my-task")

# Send a prompt to the API and return the response.
w = pz.send_prompt("What is the WDI code for GDP?", return_data=True)

# Print the response.
print(w)

# Output:

# {'message': [{'role': 'system', 'content': ''}, {'role': 'user', 'content': 'What is the WDI code for GDP?'}], 'response': {'id': 'chatcmpl-8V0IN0VbeYTrsBAohs309DHJQLJL8', 'choices': [{'finish_reason': 'stop', 'index': 0, 'message': {'content': 'The WDI code for GDP (Gross Domestic Product) is "NY.GDP.MKTP.CD".', 'role': 'assistant', 'function_call': None, 'tool_calls': None}}], 'created': 1702399995, 'model': 'gpt-3.5-turbo-0613', 'object': 'chat.completion', 'system_fingerprint': None, 'usage': {'completion_tokens': 23, 'prompt_tokens': 20, 'total_tokens': 43}}, 'content': 'The WDI code for GDP (Gross Domestic Product) is "NY.GDP.MKTP.CD".', 'api_kwargs': {'temperature': 0, 'top_p': 0, 'n': 1, 'stream': False, 'frequency_penalty': 0, 'presence_penalty': 0, 'model': 'gpt-3.5-turbo', 'max_tokens': 4029}, 'metadata': {}, 'message_hash': '1a5816095c232f29428d4cec70498391'}

NOTE: The output is also logged to the my-task directory under the current working directory.

Download files

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

Source Distribution

llm_space-0.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

llm_space-0.0.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file llm_space-0.0.3.tar.gz.

File metadata

  • Download URL: llm_space-0.0.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Darwin/23.1.0

File hashes

Hashes for llm_space-0.0.3.tar.gz
Algorithm Hash digest
SHA256 e6055f2538f1b01ea345cc229f6debfee2e2e18658079bea756d6c95718f7935
MD5 269fe1408561d889d85f90192d1c4970
BLAKE2b-256 d9b31075c093002c13f30744f5bed28c62b7d9d4375ba962249cf0235ebd4679

See more details on using hashes here.

File details

Details for the file llm_space-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: llm_space-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.6 Darwin/23.1.0

File hashes

Hashes for llm_space-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4082a0468da8c11eb36f69bc0c0bd035a3a012ceba53a2e30f3e4e78de239e53
MD5 7ec36bfe3b937daa5f943f71bbe654d4
BLAKE2b-256 be1cc5717dc92569b6af974bb55d5d6de2247f55802731d6978fa314dc2c3cd8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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