Skip to main content

unofficial_ffm_openai_client

An unofficial Formosa Foundation Model client implementation based on OpenAI and LangChain

Introduction

This is an unofficial Python client implementation for the Formosa Foundation Model public endpoint, compatible with the OpenAI Python client and LangChain. Currently, it only implements the Conversation API and supports the public endpoint. Note that the synchronous API is not yet implemented.

Changelog

  • 0.2.1 - [fix] Remove unnecessary import from chat_completion.py
  • 0.2.0
    • Add a callback for counting token consumption in streaming and non-streaming mode.
    • Add json error handling for sync streaming mode.
    • Add token consumption info in the result of streaming and non-streaming mode.
  • 0.1.3 - Support function calls.
  • 0.1.2 - Support embeddings.

Usage

Install using pypi:

pip install unofficial-ffm-openai

You can use it similarly to the original OpenAIChat, with a few different parameters:

from ffm.langchain.language_models.ffm import FfmChatOpenAI

chat_ffm = FfmChatOpenAI(
    ffm_endpoint="https://api-ams.twcc.ai/api",
    max_tokens=1000,
    temperature=0.5,
    top_k=50,
    top_p=1.0,
    frequency_penalty=1.0,
    ffm_api_key="your key",
    ffm_deployment="ffm-mistral-7b-32k-instruct",  # or other model name
    streaming=True,
    callbacks=callbacks
)
from ffm.embeddings import FFMEmbeddings

embedding = FFMEmbeddings(
    base_url="",
    api_key="your key")

Callbacks

You cen use the ffm callbacks as using other callbacks such as openai callback, here is the example:

from ffm.langchain.callbacks import get_ffm_callback

with get_ffm_callback() as cb:
    ...do something using llm...
    
    total_tokens = cb.total_tokens
    prompt_tokens = cb.prompt_tokens
    completion_tokens = cb.completion_tokens
    successful_requests = cb.successful_requests
  • Note: Cost calculation has not been done yet but is in progress.

Limitation

Currently, it has only been tested with the following dependencies:

langchain                         0.1.20
langchain-community               0.0.38
langchain-core                    0.1.52
langchain-openai                  0.1.7
langchain-text-splitters          0.0.2
langchainhub                      0.1.15

and the OpenAI client:

openai                            1.30.1

TODO

  • Full implementation for the synchronous API.

Metadata

Release files for unofficial-ffm-openai 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unofficial-ffm-openai 0.2.1
File Size Uploaded Provenance
unofficial_ffm_openai-0.2.1.tar.gz 16.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for unofficial-ffm-openai 0.2.1
File Interpreter ABI Platform
unofficial_ffm_openai-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 37.9 kB

Release files / unofficial_ffm_openai-0.2.1.tar.gz

Download URL unofficial_ffm_openai-0.2.1.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a58d28460a3711ed583f945610444bd466458cd8ecf65ed5e5f937ddaec4d9fc
BLAKE2b-256 checksum
How to use checksums
73b6f2de27603a80187f0f0ea358b129b66b13ced5a11a9967442d712bc65634
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.11

Release files / unofficial_ffm_openai-0.2.1-py3-none-any.whl

Download URL unofficial_ffm_openai-0.2.1-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b35d126e17b2f8ce3e496308d8313bd396a2f985edb8f934adfe20ba2424bea
BLAKE2b-256 checksum
How to use checksums
717e34847b4504deb0e0e244a8d1f02f59855d5978dcba1cb0b74e0790ec03c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.11

Security for unofficial-ffm-openai 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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