redis-intent-router 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redis_intent_router-0.1.0a1/PKG-INFO +559 -0
- redis_intent_router-0.1.0a1/README-PYPI.md +537 -0
- redis_intent_router-0.1.0a1/py.typed +1 -0
- redis_intent_router-0.1.0a1/pyproject.toml +60 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/__init__.py +21 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/_hooks/__init__.py +6 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/_hooks/registration.py +13 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/_hooks/sdkhooks.py +77 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/_hooks/types.py +125 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/_version.py +18 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/basesdk.py +393 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/__init__.py +17 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/_hooks/__init__.py +5 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/_hooks/registration.py +13 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/_hooks/sdkhooks.py +76 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/_hooks/types.py +124 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/_version.py +17 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/basesdk.py +392 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/__init__.py +101 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/apierror.py +40 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/authenticationerrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/badrequesterrorresponsecontent.py +48 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/conflicterrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/faileddependencyerrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/intentrouterserviceerror.py +30 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/no_response_error.py +17 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/notfounderrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/preconditionfailederrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/responsevalidationerror.py +27 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/timeouterrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/errors/unexpectederrorresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/httpclient.py +125 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/__init__.py +184 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/authenticationerrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/badrequesterrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/conflicterrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/createrouterop.py +53 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/createrouterrequestcontent.py +83 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/createrouterresponsecontent.py +128 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/deleterouterop.py +21 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/deleterouterresponsecontent.py +128 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/embeddingmodel.py +35 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/faileddependencyerrortype.py +12 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/fielderror.py +29 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/getrouterop.py +21 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/getrouterresponsecontent.py +128 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/listmodelsop.py +64 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/listmodelsresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/listroutersop.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/listroutersresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/modelauthorization.py +12 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/modelitem.py +83 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/modelpurpose.py +13 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/mutablerouterstate.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/notfounderrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/preconditionfailederrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/router.py +128 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/routerstate.py +13 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/routertemplate.py +14 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/security.py +42 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/timeouterrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/unexpectederrortype.py +10 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/updaterouterop.py +63 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/updaterouterrequestcontent.py +98 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/models/updaterouterresponsecontent.py +128 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/py.typed +1 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/sdk.py +1673 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/sdkconfiguration.py +36 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/types/__init__.py +24 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/types/base64fileinput.py +43 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/types/basemodel.py +77 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/__init__.py +183 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/annotations.py +79 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/datetimes.py +41 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/dynamic_imports.py +54 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/enums.py +134 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/eventstreaming.py +326 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/forms.py +239 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/headers.py +136 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/logger.py +27 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/metadata.py +119 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/queryparams.py +217 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/requestbodies.py +67 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/retries.py +372 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/security.py +215 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/serializers.py +326 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/unmarshal_json_response.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/url.py +154 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/controlplane/utils/values.py +142 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/__init__.py +115 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/apierror.py +41 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/authenticationerrorresponsecontent.py +46 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/badrequesterrorresponsecontent.py +49 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/conflicterrorresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/faileddependencyerrorresponsecontent.py +46 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/intentroutererror.py +31 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/no_response_error.py +18 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/notfounderrorresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/preconditionfailederrorresponsecontent.py +46 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/resourcesuspendederrorresponsecontent.py +46 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/responsevalidationerror.py +28 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/serviceunavailableerrorresponsecontent.py +43 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/timeouterrorresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/errors/unexpectederrorresponsecontent.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/httpclient.py +126 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/__init__.py +392 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addexamplesop.py +62 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addexamplesrequestcontent.py +15 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addexamplesresponsecontent.py +16 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addintentsop.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addintentsrequestcontent.py +16 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/addintentsresponsecontent.py +16 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/authenticationerrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/badrequesterrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/clearrouterop.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/clearrouterrequestcontent.py +17 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/clearscope.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/conflicterrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/deleteexampleop.py +61 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/deleteintentop.py +52 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/example.py +35 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/faileddependencyerrortype.py +13 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/fielderror.py +30 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getexampleop.py +61 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getexampleresponsecontent.py +35 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getintentop.py +52 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getintentresponsecontent.py +85 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getrouterhealthop.py +46 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/getrouterhealthresponsecontent.py +19 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/healthcheck.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/intent.py +85 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/intentdefinition.py +77 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/internal/__init__.py +26 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/internal/globals.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/listexamplesop.py +88 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/listexamplesresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/listintentsop.py +79 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/listintentsresponsecontent.py +45 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/matchintentsop.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/matchintentsrequestcontent.py +51 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/matchintentsresponsecontent.py +16 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/matchitem.py +59 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/notfounderrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/preconditionfailederrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/resourcesuspendederrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/security.py +43 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/serviceunavailableerrortype.py +9 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/target.py +48 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/timeouterrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/unexpectederrortype.py +11 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/updateintentop.py +92 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/updateintentrequestcontent.py +122 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/updateintentresponsecontent.py +85 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/upsertintentop.py +92 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/upsertintentrequestcontent.py +78 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/models/upsertintentresponsecontent.py +85 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/py.typed +1 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/sdk.py +3835 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/sdkconfiguration.py +38 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/types/__init__.py +25 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/types/base64fileinput.py +44 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/types/basemodel.py +78 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/__init__.py +184 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/annotations.py +80 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/datetimes.py +42 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/dynamic_imports.py +55 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/enums.py +135 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/eventstreaming.py +327 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/forms.py +240 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/headers.py +137 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/logger.py +28 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/metadata.py +120 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/queryparams.py +218 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/requestbodies.py +68 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/retries.py +373 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/security.py +216 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/serializers.py +327 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/unmarshal_json_response.py +39 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/url.py +155 -0
- redis_intent_router-0.1.0a1/src/redis_intent_router/utils/values.py +143 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: redis-intent-router
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Python Client SDK for Redis Intent Router
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Redis AI Services Team
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: httpcore (>=1.0.9)
|
|
16
|
+
Requires-Dist: httpx (>=0.28.1)
|
|
17
|
+
Requires-Dist: pydantic (>=2.11.2)
|
|
18
|
+
Project-URL: Documentation, https://pypi.org/project/redis-intent-router/
|
|
19
|
+
Project-URL: Homepage, https://redis.io/docs/latest/develop/ai/
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# redis-intent-router
|
|
23
|
+
|
|
24
|
+
Developer-friendly & type-safe Python SDK specifically catered to leverage *redis-intent-router* API.
|
|
25
|
+
|
|
26
|
+
[](https://www.speakeasy.com/?utm_source=redis-intent-router&utm_campaign=python)
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<br /><br />
|
|
31
|
+
> [!IMPORTANT]
|
|
32
|
+
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/redis/ai-services). Delete this section before > publishing to a package manager.
|
|
33
|
+
|
|
34
|
+
<!-- Start Summary [summary] -->
|
|
35
|
+
## Summary
|
|
36
|
+
|
|
37
|
+
Redis Intent Router: Intent authoring and matching API for one Router. An intent is a named classification with example phrasings and an optional dispatch target; matching returns the intents closest to a query. Intents and examples are ordered lists: they are returned in the order they were created.
|
|
38
|
+
|
|
39
|
+
For more information about the API: [Redis AI documentation](https://redis.io/docs/latest/develop/ai/)
|
|
40
|
+
<!-- End Summary [summary] -->
|
|
41
|
+
|
|
42
|
+
<!-- Start Table of Contents [toc] -->
|
|
43
|
+
## Table of Contents
|
|
44
|
+
<!-- $toc-max-depth=2 -->
|
|
45
|
+
* [redis-intent-router](#redis-intent-router)
|
|
46
|
+
* [SDK Installation](#sdk-installation)
|
|
47
|
+
* [IDE Support](#ide-support)
|
|
48
|
+
* [SDK Example Usage](#sdk-example-usage)
|
|
49
|
+
* [Authentication](#authentication)
|
|
50
|
+
* [Available Resources and Operations](#available-resources-and-operations)
|
|
51
|
+
* [Global Parameters](#global-parameters)
|
|
52
|
+
* [Retries](#retries)
|
|
53
|
+
* [Error Handling](#error-handling)
|
|
54
|
+
* [Custom HTTP Client](#custom-http-client)
|
|
55
|
+
* [Resource Management](#resource-management)
|
|
56
|
+
* [Debugging](#debugging)
|
|
57
|
+
* [Development](#development)
|
|
58
|
+
* [Maturity](#maturity)
|
|
59
|
+
* [Contributions](#contributions)
|
|
60
|
+
|
|
61
|
+
<!-- End Table of Contents [toc] -->
|
|
62
|
+
|
|
63
|
+
<!-- Start SDK Installation [installation] -->
|
|
64
|
+
## SDK Installation
|
|
65
|
+
|
|
66
|
+
> [!NOTE]
|
|
67
|
+
> **Python version upgrade policy**
|
|
68
|
+
>
|
|
69
|
+
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
|
|
70
|
+
|
|
71
|
+
The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
|
|
72
|
+
|
|
73
|
+
### uv
|
|
74
|
+
|
|
75
|
+
*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uv add redis-intent-router
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### PIP
|
|
82
|
+
|
|
83
|
+
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install redis-intent-router
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Poetry
|
|
90
|
+
|
|
91
|
+
*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
poetry add redis-intent-router
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Shell and script usage with `uv`
|
|
98
|
+
|
|
99
|
+
You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
uvx --from redis-intent-router python
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
It's also possible to write a standalone Python script without needing to set up a whole project like so:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
#!/usr/bin/env -S uv run --script
|
|
109
|
+
# /// script
|
|
110
|
+
# requires-python = ">=3.10"
|
|
111
|
+
# dependencies = [
|
|
112
|
+
# "redis-intent-router",
|
|
113
|
+
# ]
|
|
114
|
+
# ///
|
|
115
|
+
|
|
116
|
+
from redis_intent_router import IntentRouter
|
|
117
|
+
|
|
118
|
+
sdk = IntentRouter(
|
|
119
|
+
# SDK arguments
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Rest of script here...
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Once that is saved to a file, you can run it with `uv run script.py` where
|
|
126
|
+
`script.py` can be replaced with the actual file name.
|
|
127
|
+
<!-- End SDK Installation [installation] -->
|
|
128
|
+
|
|
129
|
+
<!-- Start IDE Support [idesupport] -->
|
|
130
|
+
## IDE Support
|
|
131
|
+
|
|
132
|
+
### PyCharm
|
|
133
|
+
|
|
134
|
+
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
|
|
135
|
+
|
|
136
|
+
- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
|
|
137
|
+
<!-- End IDE Support [idesupport] -->
|
|
138
|
+
|
|
139
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
140
|
+
## SDK Example Usage
|
|
141
|
+
|
|
142
|
+
### Example
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
# Synchronous Example
|
|
146
|
+
from redis_intent_router import IntentRouter, models
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
with IntentRouter(
|
|
150
|
+
"https://api.example.com",
|
|
151
|
+
router_id="<id>",
|
|
152
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
153
|
+
) as intent_router:
|
|
154
|
+
|
|
155
|
+
intent_router.clear(scope=models.ClearScope.INTENTS)
|
|
156
|
+
|
|
157
|
+
# Use the SDK ...
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
</br>
|
|
161
|
+
|
|
162
|
+
The same SDK client can also be used to make asynchronous requests by importing asyncio.
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
# Asynchronous Example
|
|
166
|
+
import asyncio
|
|
167
|
+
from redis_intent_router import IntentRouter, models
|
|
168
|
+
|
|
169
|
+
async def main():
|
|
170
|
+
|
|
171
|
+
async with IntentRouter(
|
|
172
|
+
"https://api.example.com",
|
|
173
|
+
router_id="<id>",
|
|
174
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
175
|
+
) as intent_router:
|
|
176
|
+
|
|
177
|
+
await intent_router.clear_async(scope=models.ClearScope.INTENTS)
|
|
178
|
+
|
|
179
|
+
# Use the SDK ...
|
|
180
|
+
|
|
181
|
+
asyncio.run(main())
|
|
182
|
+
```
|
|
183
|
+
<!-- End SDK Example Usage [usage] -->
|
|
184
|
+
|
|
185
|
+
<!-- Start Authentication [security] -->
|
|
186
|
+
## Authentication
|
|
187
|
+
|
|
188
|
+
### Per-Client Security Schemes
|
|
189
|
+
|
|
190
|
+
This SDK supports the following security scheme globally:
|
|
191
|
+
|
|
192
|
+
| Name | Type | Scheme | Environment Variable |
|
|
193
|
+
| --------- | ---- | ----------- | ----------------------- |
|
|
194
|
+
| `api_key` | http | HTTP Bearer | `INTENT_ROUTER_API_KEY` |
|
|
195
|
+
|
|
196
|
+
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
|
197
|
+
```python
|
|
198
|
+
from redis_intent_router import IntentRouter, models
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
with IntentRouter(
|
|
202
|
+
"https://api.example.com",
|
|
203
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
204
|
+
router_id="<id>",
|
|
205
|
+
) as intent_router:
|
|
206
|
+
|
|
207
|
+
intent_router.clear(scope=models.ClearScope.INTENTS)
|
|
208
|
+
|
|
209
|
+
# Use the SDK ...
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
<!-- End Authentication [security] -->
|
|
213
|
+
|
|
214
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
215
|
+
## Available Resources and Operations
|
|
216
|
+
|
|
217
|
+
<details open>
|
|
218
|
+
<summary>Available methods</summary>
|
|
219
|
+
|
|
220
|
+
### IntentRouter SDK
|
|
221
|
+
|
|
222
|
+
* clear - Removes everything the scope names. With INTENTS every intent and example of the Router is deleted and the Router itself stays. The scope is required: there is no default.
|
|
223
|
+
* get_router_health - Reports why a Router can or cannot serve: its state, the generation the data plane has applied and the stores it depends on.
|
|
224
|
+
* list_intents - Lists intents with their configuration and example counts, in the order they were created.
|
|
225
|
+
* add_intents - Adds several intents in the order given, after the ones the Router already has. An intent whose name already exists is replaced in its place; every other intent is left alone. Nothing is written if any intent is invalid.
|
|
226
|
+
* delete_intent - Deletes one intent and its examples. Deleting a missing intent succeeds.
|
|
227
|
+
* get_intent - Returns one intent. Its examples are listed from the examples sub-resource.
|
|
228
|
+
* update_intent - Changes an intent's description, target, minScore or metadata as a merge patch, without touching or re-embedding its examples. An omitted member is unchanged and a null member is cleared; a given metadata map replaces the whole map.
|
|
229
|
+
* upsert_intent - Creates or replaces one intent. Idempotent: the same request twice yields the same state. 201 when the intent is new, 200 when it replaced one, which keeps its place in the list. Existing phrasings absent from the request are removed after the new ones are written, so a concurrent match never sees an empty intent.
|
|
230
|
+
* list_examples - Lists an intent's examples in the order they were written.
|
|
231
|
+
* add_examples - Adds example phrasings to an existing intent, after the ones it already has. Repeating a phrasing is harmless: it keeps its place and is not embedded again.
|
|
232
|
+
* delete_example - Deletes one example. Deleting a missing example succeeds.
|
|
233
|
+
* get_example - Returns one example. An identifier from another intent is not found.
|
|
234
|
+
* match - Returns the intents closest to the query, best first. No match is a 200 with an empty list.
|
|
235
|
+
|
|
236
|
+
</details>
|
|
237
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
238
|
+
|
|
239
|
+
<!-- Start Global Parameters [global-parameters] -->
|
|
240
|
+
## Global Parameters
|
|
241
|
+
|
|
242
|
+
A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
|
|
243
|
+
|
|
244
|
+
For example, you can set `routerId` to `"<id>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `clear`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
### Available Globals
|
|
248
|
+
|
|
249
|
+
The following global parameter is available.
|
|
250
|
+
Global parameters can also be set via environment variable.
|
|
251
|
+
|
|
252
|
+
| Name | Type | Description | Environment |
|
|
253
|
+
| --------- | ---- | ------------------------ | ----------------------- |
|
|
254
|
+
| router_id | str | The router_id parameter. | INTENT_ROUTER_ROUTER_ID |
|
|
255
|
+
|
|
256
|
+
### Example
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from redis_intent_router import IntentRouter, models
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
with IntentRouter(
|
|
263
|
+
"https://api.example.com",
|
|
264
|
+
router_id="<id>",
|
|
265
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
266
|
+
) as intent_router:
|
|
267
|
+
|
|
268
|
+
intent_router.clear(scope=models.ClearScope.INTENTS)
|
|
269
|
+
|
|
270
|
+
# Use the SDK ...
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
<!-- End Global Parameters [global-parameters] -->
|
|
274
|
+
|
|
275
|
+
<!-- Start Retries [retries] -->
|
|
276
|
+
## Retries
|
|
277
|
+
|
|
278
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
279
|
+
|
|
280
|
+
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
|
281
|
+
```python
|
|
282
|
+
from redis_intent_router import IntentRouter, models
|
|
283
|
+
from redis_intent_router.utils import BackoffStrategy, RetryConfig
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
with IntentRouter(
|
|
287
|
+
"https://api.example.com",
|
|
288
|
+
router_id="<id>",
|
|
289
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
290
|
+
) as intent_router:
|
|
291
|
+
|
|
292
|
+
intent_router.clear(scope=models.ClearScope.INTENTS,
|
|
293
|
+
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
294
|
+
|
|
295
|
+
# Use the SDK ...
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
|
300
|
+
```python
|
|
301
|
+
from redis_intent_router import IntentRouter, models
|
|
302
|
+
from redis_intent_router.utils import BackoffStrategy, RetryConfig
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
with IntentRouter(
|
|
306
|
+
"https://api.example.com",
|
|
307
|
+
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
|
308
|
+
router_id="<id>",
|
|
309
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
310
|
+
) as intent_router:
|
|
311
|
+
|
|
312
|
+
intent_router.clear(scope=models.ClearScope.INTENTS)
|
|
313
|
+
|
|
314
|
+
# Use the SDK ...
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
<!-- End Retries [retries] -->
|
|
318
|
+
|
|
319
|
+
<!-- Start Error Handling [errors] -->
|
|
320
|
+
## Error Handling
|
|
321
|
+
|
|
322
|
+
`IntentRouterError` is the base class for all HTTP error responses. It has the following properties:
|
|
323
|
+
|
|
324
|
+
| Property | Type | Description |
|
|
325
|
+
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
|
|
326
|
+
| `err.message` | `str` | Error message |
|
|
327
|
+
| `err.status_code` | `int` | HTTP response status code eg `404` |
|
|
328
|
+
| `err.headers` | `httpx.Headers` | HTTP response headers |
|
|
329
|
+
| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
|
|
330
|
+
| `err.raw_response` | `httpx.Response` | Raw HTTP response |
|
|
331
|
+
| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
|
|
332
|
+
|
|
333
|
+
### Example
|
|
334
|
+
```python
|
|
335
|
+
from redis_intent_router import IntentRouter, errors, models
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
with IntentRouter(
|
|
339
|
+
"https://api.example.com",
|
|
340
|
+
router_id="<id>",
|
|
341
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
342
|
+
) as intent_router:
|
|
343
|
+
|
|
344
|
+
try:
|
|
345
|
+
|
|
346
|
+
intent_router.clear(scope=models.ClearScope.INTENTS)
|
|
347
|
+
|
|
348
|
+
# Use the SDK ...
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
except errors.IntentRouterError as e:
|
|
352
|
+
# The base class for HTTP error responses
|
|
353
|
+
print(e.message)
|
|
354
|
+
print(e.status_code)
|
|
355
|
+
print(e.body)
|
|
356
|
+
print(e.headers)
|
|
357
|
+
print(e.raw_response)
|
|
358
|
+
|
|
359
|
+
# Depending on the method different errors may be thrown
|
|
360
|
+
if isinstance(e, errors.BadRequestErrorResponseContent):
|
|
361
|
+
print(e.data.title) # str
|
|
362
|
+
print(e.data.status) # Optional[int]
|
|
363
|
+
print(e.data.detail) # Optional[str]
|
|
364
|
+
print(e.data.instance) # Optional[str]
|
|
365
|
+
print(e.data.type) # models.BadRequestErrorType
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Error Classes
|
|
369
|
+
**Primary errors:**
|
|
370
|
+
* `IntentRouterError`: The base class for HTTP error responses.
|
|
371
|
+
* `BadRequestErrorResponseContent`: Request validation or input decoding failed. Status code `400`.
|
|
372
|
+
* `AuthenticationErrorResponseContent`: Authentication credentials are missing, malformed, or invalid. Status code `401`.
|
|
373
|
+
* `NotFoundErrorResponseContent`: The requested resource does not exist. Status code `404`.
|
|
374
|
+
* `TimeoutErrorResponseContent`: The request timed out before the service could complete it. Status code `408`.
|
|
375
|
+
* `ConflictErrorResponseContent`: The request conflicts with the current state of the resource. Status code `409`.
|
|
376
|
+
* `ResourceSuspendedErrorResponseContent`: The requested resource exists but is suspended by an administrator. Status code `423`.
|
|
377
|
+
* `FailedDependencyErrorResponseContent`: A dependent resource required to process the request is unavailable or unhealthy. Status code `424`.
|
|
378
|
+
* `UnexpectedErrorResponseContent`: The service failed with an unexpected internal error. Status code `500`.
|
|
379
|
+
* `ServiceUnavailableErrorResponseContent`: ServiceUnavailableError 503 response. Status code `503`.
|
|
380
|
+
|
|
381
|
+
<details><summary>Less common errors (6)</summary>
|
|
382
|
+
|
|
383
|
+
<br />
|
|
384
|
+
|
|
385
|
+
**Network errors:**
|
|
386
|
+
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
|
|
387
|
+
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
|
|
388
|
+
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
**Inherit from `IntentRouterError`**:
|
|
392
|
+
* `PreconditionFailedErrorResponseContent`: The write named an expected revision (expectedRevision or If-Match) that is no longer current. Read the resource again and retry. Status code `412`. Applicable to 2 of 13 methods.*
|
|
393
|
+
* `ResponseValidationError`: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
|
|
394
|
+
|
|
395
|
+
</details>
|
|
396
|
+
|
|
397
|
+
\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
|
|
398
|
+
<!-- End Error Handling [errors] -->
|
|
399
|
+
|
|
400
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
401
|
+
## Custom HTTP Client
|
|
402
|
+
|
|
403
|
+
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
|
|
404
|
+
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
|
|
405
|
+
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
|
|
406
|
+
|
|
407
|
+
For example, you could specify a header for every request that this sdk makes as follows:
|
|
408
|
+
```python
|
|
409
|
+
from redis_intent_router import IntentRouter
|
|
410
|
+
import httpx
|
|
411
|
+
|
|
412
|
+
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
|
413
|
+
s = IntentRouter(client=http_client)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
or you could wrap the client with your own custom logic:
|
|
417
|
+
```python
|
|
418
|
+
from redis_intent_router import IntentRouter
|
|
419
|
+
from redis_intent_router.httpclient import AsyncHttpClient
|
|
420
|
+
import httpx
|
|
421
|
+
|
|
422
|
+
class CustomClient(AsyncHttpClient):
|
|
423
|
+
client: AsyncHttpClient
|
|
424
|
+
|
|
425
|
+
def __init__(self, client: AsyncHttpClient):
|
|
426
|
+
self.client = client
|
|
427
|
+
|
|
428
|
+
async def send(
|
|
429
|
+
self,
|
|
430
|
+
request: httpx.Request,
|
|
431
|
+
*,
|
|
432
|
+
stream: bool = False,
|
|
433
|
+
auth: Union[
|
|
434
|
+
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
|
435
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
436
|
+
follow_redirects: Union[
|
|
437
|
+
bool, httpx._client.UseClientDefault
|
|
438
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
439
|
+
) -> httpx.Response:
|
|
440
|
+
request.headers["Client-Level-Header"] = "added by client"
|
|
441
|
+
|
|
442
|
+
return await self.client.send(
|
|
443
|
+
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
def build_request(
|
|
447
|
+
self,
|
|
448
|
+
method: str,
|
|
449
|
+
url: httpx._types.URLTypes,
|
|
450
|
+
*,
|
|
451
|
+
content: Optional[httpx._types.RequestContent] = None,
|
|
452
|
+
data: Optional[httpx._types.RequestData] = None,
|
|
453
|
+
files: Optional[httpx._types.RequestFiles] = None,
|
|
454
|
+
json: Optional[Any] = None,
|
|
455
|
+
params: Optional[httpx._types.QueryParamTypes] = None,
|
|
456
|
+
headers: Optional[httpx._types.HeaderTypes] = None,
|
|
457
|
+
cookies: Optional[httpx._types.CookieTypes] = None,
|
|
458
|
+
timeout: Union[
|
|
459
|
+
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
|
460
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
461
|
+
extensions: Optional[httpx._types.RequestExtensions] = None,
|
|
462
|
+
) -> httpx.Request:
|
|
463
|
+
return self.client.build_request(
|
|
464
|
+
method,
|
|
465
|
+
url,
|
|
466
|
+
content=content,
|
|
467
|
+
data=data,
|
|
468
|
+
files=files,
|
|
469
|
+
json=json,
|
|
470
|
+
params=params,
|
|
471
|
+
headers=headers,
|
|
472
|
+
cookies=cookies,
|
|
473
|
+
timeout=timeout,
|
|
474
|
+
extensions=extensions,
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
s = IntentRouter(async_client=CustomClient(httpx.AsyncClient()))
|
|
478
|
+
```
|
|
479
|
+
### httpx2 (Pydantic's httpx fork)
|
|
480
|
+
|
|
481
|
+
[httpx2](https://httpx2.pydantic.dev/) is Pydantic's maintained fork of `httpx`. To run this SDK on httpx2, call `alias_httpx()` at your program's entry point, before importing the SDK, so every `import httpx` — including the ones inside the SDK — resolves to `httpx2`:
|
|
482
|
+
```python
|
|
483
|
+
import httpx2
|
|
484
|
+
|
|
485
|
+
httpx2.alias_httpx()
|
|
486
|
+
|
|
487
|
+
from redis_intent_router import IntentRouter
|
|
488
|
+
|
|
489
|
+
s = IntentRouter()
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
An SDK can also be generated against httpx2 directly, so it depends on the fork instead of `httpx`, by setting `python.httpClientLibrary: httpx2` in `gen.yaml`.
|
|
493
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
494
|
+
|
|
495
|
+
<!-- Start Resource Management [resource-management] -->
|
|
496
|
+
## Resource Management
|
|
497
|
+
|
|
498
|
+
The `IntentRouter` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
|
|
499
|
+
|
|
500
|
+
[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
|
|
501
|
+
|
|
502
|
+
```python
|
|
503
|
+
from redis_intent_router import IntentRouter
|
|
504
|
+
def main():
|
|
505
|
+
|
|
506
|
+
with IntentRouter(
|
|
507
|
+
"https://api.example.com",
|
|
508
|
+
router_id="<id>",
|
|
509
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
510
|
+
) as intent_router:
|
|
511
|
+
# Rest of application here...
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
# Or when using async:
|
|
515
|
+
async def amain():
|
|
516
|
+
|
|
517
|
+
async with IntentRouter(
|
|
518
|
+
"https://api.example.com",
|
|
519
|
+
router_id="<id>",
|
|
520
|
+
api_key="<INTENT_ROUTER_API_KEY>",
|
|
521
|
+
) as intent_router:
|
|
522
|
+
# Rest of application here...
|
|
523
|
+
```
|
|
524
|
+
<!-- End Resource Management [resource-management] -->
|
|
525
|
+
|
|
526
|
+
<!-- Start Debugging [debug] -->
|
|
527
|
+
## Debugging
|
|
528
|
+
|
|
529
|
+
You can setup your SDK to emit debug logs for SDK requests and responses.
|
|
530
|
+
|
|
531
|
+
You can pass your own logger class directly into your SDK.
|
|
532
|
+
```python
|
|
533
|
+
from redis_intent_router import IntentRouter
|
|
534
|
+
import logging
|
|
535
|
+
|
|
536
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
537
|
+
s = IntentRouter(server_url="https://example.com", debug_logger=logging.getLogger("redis_intent_router"))
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
You can also enable a default debug logger by setting an environment variable `INTENT_ROUTER_DEBUG` to true.
|
|
541
|
+
<!-- End Debugging [debug] -->
|
|
542
|
+
|
|
543
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
544
|
+
|
|
545
|
+
# Development
|
|
546
|
+
|
|
547
|
+
## Maturity
|
|
548
|
+
|
|
549
|
+
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
|
550
|
+
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
|
551
|
+
looking for the latest version.
|
|
552
|
+
|
|
553
|
+
## Contributions
|
|
554
|
+
|
|
555
|
+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
|
556
|
+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
|
557
|
+
|
|
558
|
+
### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=redis-intent-router&utm_campaign=python)
|
|
559
|
+
|