You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add examples of using Fields and EnvAuthStrategy to developer documentation (#1056)
* Add example of using fields for configuration.
I have created this example based on some delving into the code and looking
at examples of some of the community providers.
I haven't included the IntegerField, as I couldn't get it to work properly,
suggesting that I don't understand it properly, whereas I have
successfully tested the TextField and MultilineTextField.
* Add example of using the EnvAuthStrategy to provide API Keys
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Combined sections for API Keys and for Fields into a single section.
As per review feedback, combined the two sections and examples for
brevity. Also added a couple of missing imports to the example.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The `auth_strategy` handles specifying API keys for providers and models.
166
+
The example shows the `EnvAuthStrategy` which takes the API key from the
167
+
environment variable with the name specified in `name` and be provided to the
168
+
model's `__init__` as a kwarg with the name specified in `keyword_param`.
169
+
This will also cause a field to be present in the configuration UI with the
170
+
`name` of the environment variable as the label.
171
+
172
+
Further configuration can be handled adding `fields` into the settings
173
+
dialogue for your custom model by specifying a list of fields as shown in
174
+
the example. These will be passed into the `__init__` as kwargs, with the
175
+
key specified by the key in the field object. The label specified in the field
176
+
object determines the text shown in the configuration section of the user
177
+
interface.
178
+
124
179
### Custom embeddings providers
125
180
126
181
To provide a custom embeddings model an embeddings providers should be defined implementing the API of `jupyter-ai`'s `BaseEmbeddingsProvider` and of `langchain`'s [`Embeddings`][Embeddings] abstract class.
0 commit comments