Skip to main content

locaith

Python SDK cho Locaith-4-flash: tìm web, suy luận, ngữ cảnh 64K, Bio-Memory.

pip install locaith
export LOCAITH_API_KEY="LocAI..."
from locaith import Locaith

client = Locaith()

r = client.chat.completions.create(
    messages=[{"role": "user", "content": "Giá vàng SJC hôm nay?"}],
)
print(r.choices[0].message.content)
print([s.url for s in r.sources])

Streaming:

stream = client.chat.completions.create(
    messages=[{"role": "user", "content": "Viết bài 500 chữ về AI tại Việt Nam"}],
    stream=True,
)
for text in stream.text():
    print(text, end="", flush=True)
print(stream.sources)

Bio-Memory:

client = Locaith(user="khach_123")

client.chat.completions.create(
    messages=[{"role": "user", "content": "Tôi là kế toán trưởng công ty ABC."}],
    memory=True,
)
client.chat.completions.create(
    messages=[{"role": "user", "content": "Bạn nhớ tôi làm nghề gì?"}],
    memory=True,
)

client.memory.list()
client.memory.add("Quy ước báo cáo", "Đơn vị triệu đồng.", type="feedback")
client.memory.export("ky-uc.zip")

Async:

import asyncio
from locaith import AsyncLocaith

async def main():
    async with AsyncLocaith() as client:
        r = await client.chat.completions.create(messages="Xin chào")
        print(r.text)

asyncio.run(main())

Lỗi:

import locaith

try:
    client.chat.completions.create(messages="Xin chào")
except locaith.AuthenticationError as e:
    print(e.status_code, e.message)
except locaith.APIConnectionError:
    ...

Tương thích OpenAI: có thể dùng thẳng SDK openai với base_url="https://memory-api.locaith.com/v1".

Metadata

Release files for locaith 1.0.0

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

Source distribution (sdist)

Source distribution for locaith 1.0.0
File Size Uploaded Provenance
locaith-1.0.0.tar.gz 8.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for locaith 1.0.0
File Interpreter ABI Platform
locaith-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / locaith-1.0.0.tar.gz

Download URL locaith-1.0.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
84311a0ba3a78b5e54eaf51f704f244ec8aa3e91e3cc5b41a6d4238d4ce375d8
BLAKE2b-256 checksum
How to use checksums
bb02f18f15eb74558d8c8dfc067b44b722e00ef70365248d17c8ff52b325f55c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / locaith-1.0.0-py3-none-any.whl

Download URL locaith-1.0.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf058b4e486c9b4653e0e3772dc68415dcb1592cedde500b92951e808c38cc80
BLAKE2b-256 checksum
How to use checksums
7fc0348a67963ca57dcf5f36dd520413d2671e4c2fb12efc683f5508b0625c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for locaith 1.0.0

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