Metadata-Version: 2.5
Name: locaith
Version: 1.0.0
Summary: Python SDK cho Locaith-4-flash: tìm web, suy luận, ngữ cảnh 64K và Bio-Memory.
Project-URL: Homepage, https://locaith.com
Author: Locaith
License: MIT
License-File: LICENSE
Keywords: ai,llm,locaith,openai-compatible,sdk,vietnamese
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Vietnamese
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: httpx<1,>=0.24
Description-Content-Type: text/markdown

# locaith

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

```bash
pip install locaith
export LOCAITH_API_KEY="LocAI..."
```

```python
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:

```python
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:

```python
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:

```python
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:

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