Metadata-Version: 2.4
Name: lingxinai-psychology
Version: 1.0.4
Summary: Python SDK for LingxinAI Psychology Open APIs
Project-URL: Homepage, https://lingxinai.com
Author: LingxinAI
License-Expression: Apache-2.0
Keywords: lingxinai,psychology,sdk
Requires-Python: >=3.9
Requires-Dist: requests>=2.31.0
Requires-Dist: websocket-client>=1.8.0
Description-Content-Type: text/markdown

# LingxinAI Psychology Python SDK

Python SDK for LingxinAI Psychology Open APIs.

## Install

```bash
pip install lingxinai-psychology
```

## Quick Start

```python
from lingxinai.psychology import PsychologyClient
from lingxinai.psychology.types import OpenStudentQueryRequest

client = PsychologyClient.builder() \
    .admin("your-api-key", "your-api-secret") \
    .build()

students = client.open_api().student().list(OpenStudentQueryRequest(
    orgCode="school001",
    pageNum=0,
    pageSize=20,
))

print(students.content)
```

## Streaming Chat

Use `completionsStream` when the reply must be displayed as it is generated.

```python
from lingxinai.psychology.types import ChatQueryRequest

for chunk in student_client.open_api().chat().completionsStream(ChatQueryRequest(
    botId=237,
    content="我最近压力很大，想聊一聊",
)):
    print(chunk, end="", flush=True)
print()
```

## Client Identity

Create one client per identity. Do not mix admin, user, student, or parent calls on the same client.

```python
admin_client = PsychologyClient.builder() \
    .admin("your-api-key", "your-api-secret") \
    .build()

user_client = PsychologyClient.builder() \
    .user("your-api-key", "your-api-secret", "external-user-001") \
    .build()

student_client = PsychologyClient.builder() \
    .student("your-api-key", "your-api-secret", 10001) \
    .build()

parent_client = PsychologyClient.builder() \
    .access_token(parent_login_response.token) \
    .build()
```

## API Groups

- `auth()` - login helpers
- `org()` - organization APIs
- `dept()` - department/class APIs
- `student()` - student APIs
- `orgUser()` - organization staff APIs
- `device()` - device APIs
- `bot()` - bot APIs
- `chat()` - chat APIs
- `course()` - micro course APIs
- `algo()` - HTTP ASR/TTS and realtime ASR/TTS WebSocket APIs
- `crisis()` - crisis warning APIs
- `meditation()` - meditation APIs
- `overview()` - dashboard/statistics APIs
- `parent()` - parent-side APIs
- `quickInterview()` - quick interview APIs
- `activity()` - activity APIs
- `scale()` - scale/interview runtime APIs

## Realtime ASR

```python
from lingxinai.psychology.types import RealtimeAsrOptions

ws = student_client.open_api().algo().realtimeAsr(RealtimeAsrOptions(
    voiceFormat=1,
    inputSampleRate=16000,
))

ws.send('{"type":"start"}')
ws.send(audio_chunk, opcode=0x2)
ws.send('{"type":"end"}')
print(ws.recv())
ws.close()
```

## Verification

```bash
python -m unittest discover -s test
python -m build --sdist --wheel
python -m twine check dist/*
```
