api client py
1.4.8
API لتطوير عملاء Python للتفاعل مع CHESHIRE CAT.
تتيح الحزمة إنشاء إنشاء عميل WebSocket وتوفر واجهة برمجة التطبيقات للتفاعل مع جميع نقاط النهاية.
يتم إنشاء جزء من حزمة Python هذه تلقائيًا بواسطة مشروع OpenAPI Generator.
للحصول على وثائق أعمق حول نقاط النهاية المتاحة ، يرجى الرجوع إلى API Redoc. وثائق CHESHIRE CAT الرسمية متوفرة هنا.
بيثون 3.10
يمكنك تثبيت API مع pip :
pip install cheshire-cat-apiثم استيراد الحزمة:
import cheshire_cat_api as ccat يحتوي CatClient على السمات التالية للتفاعل بسهولة مع واجهات برمجة التطبيقات ذات الصلة:
import cheshire_cat_api as ccat
# A config is necessary to set up base parameters like
# URL, port, user_id, etc.
config = ccat . Config ( user_id = "my_user_42" )
# Connect to the API
cat_client = ccat . CatClient (
config = config
) # Now retrieve a list of the available plugins
plugins = cat_client . plugins . get_available_plugins () from cheshire_cat_api . models . body_upload_url import BodyUploadUrl
# Please note that interacting with the RabbitHole to upload
# a URL requires structuring the body like this
body_upload_url = BodyUploadUrl (
url = "https://cheshire-cat-ai.github.io/docs/conceptual/cheshire_cat/rabbit_hole/"
)
# then you can make the request as follows
response = cat_client . rabbit_hole . upload_url ( body_upload_url ) import time
import cheshire_cat_api as ccat
# A config is necessary to set up base parameters like
# URL, port, user_id, etc.
config = ccat . Config ( user_id = "my_user_42" )
cat_client = ccat . CatClient ( config = config )
# Connect to the WebSocket API
cat_client . connect_ws ()
while not cat_client . is_ws_connected :
# A better handling is strongly advised to avoid an infinite loop
time . sleep ( 1 )
# Send the message
cat_client . send ( message = "Hello Cat!" )
# Close connection
cat_client . close ()كلا الفئتين متاحان مع:
from cheshire_cat_api import Config| فصل | اسم | تقصير | وصف |
|---|---|---|---|
| تكوين | base_url | "المضيف المحلي" | عنوان URL الأساسي حيث يتم استضافة القط |
| تكوين | port | 1865 | منفذ الاتصال |
| تكوين | user_id | "مستخدم" | معرف العميل |
| تكوين | auth_key | "" " | مفتاح المصادقة لنقاط نهاية HTTP |
| تكوين | secure_connection | خطأ شنيع | إذا كان لاستخدام بروتوكول آمن |
للحصول على استخدام أكثر تقدماً ، يمكنك التفاعل مباشرة مع العميل الذي تم إنشاؤه تلقائيًا. للاطلاع على الوثائق انظر هنا