Skip to main content

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 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

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

lingxinai_psychology-1.0.4.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lingxinai_psychology-1.0.4-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

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

Hashes for lingxinai_psychology-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b0b55e19c18c3cc0a6e21dc66276567fbf1227ec52d018e9c6d65209e03ac72d
MD5 e1d882f03d43a9deeab714055e1d04e1
BLAKE2b-256 503f1adae94d10956973a38f2f737c1f448dfc902a45eab285c2b983c0f53f9d

See more details on using hashes here.

File details

Details for the file lingxinai_psychology-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for lingxinai_psychology-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 32a0b7c00c6a6d1b1c365e224cbaa5833241db5d26f3445fb321ca979e860e60
MD5 5a510f3a12f28011697ef743da1277cc
BLAKE2b-256 74942eef7189f3cb2cd86f4dc1486440679009c73ebfb449b44de042a319e287

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page