Python SDK for LingxinAI Psychology Open APIs
Project description
LingxinAI Psychology Python SDK
Python SDK for LingxinAI Psychology Open APIs.
Install
pip install lingxinai-psychology
Quick Start
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.
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.
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 helpersorg()- organization APIsdept()- department/class APIsstudent()- student APIsorgUser()- organization staff APIsdevice()- device APIsbot()- bot APIschat()- chat APIscourse()- micro course APIsalgo()- HTTP ASR/TTS and realtime ASR/TTS WebSocket APIscrisis()- crisis warning APIsmeditation()- meditation APIsoverview()- dashboard/statistics APIsparent()- parent-side APIsquickInterview()- quick interview APIsactivity()- activity APIsscale()- scale/interview runtime APIs
Realtime ASR
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
python -m unittest discover -s test
python -m build --sdist --wheel
python -m twine check dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lingxinai_psychology-1.0.4.tar.gz.
File metadata
- Download URL: lingxinai_psychology-1.0.4.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b55e19c18c3cc0a6e21dc66276567fbf1227ec52d018e9c6d65209e03ac72d
|
|
| MD5 |
e1d882f03d43a9deeab714055e1d04e1
|
|
| BLAKE2b-256 |
503f1adae94d10956973a38f2f737c1f448dfc902a45eab285c2b983c0f53f9d
|
File details
Details for the file lingxinai_psychology-1.0.4-py3-none-any.whl.
File metadata
- Download URL: lingxinai_psychology-1.0.4-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32a0b7c00c6a6d1b1c365e224cbaa5833241db5d26f3445fb321ca979e860e60
|
|
| MD5 |
5a510f3a12f28011697ef743da1277cc
|
|
| BLAKE2b-256 |
74942eef7189f3cb2cd86f4dc1486440679009c73ebfb449b44de042a319e287
|