Skip to content

[DOCS]: Persistent Storage documentation is a bit unclear what self is in the code example #501

@Escapingbug

Description

@Escapingbug

Type of Documentation Change

Other

Documentation Page URL or Path

https://docs.dify.ai/plugin-dev-en/0411-persistent-storage-kv

Current Content

Current code example gives entry point and usage such as:

Entry point:

    self.session.storage

Interface:

    def set(self, key: str, val: bytes) -> None:
        pass

Suggested Changes

The code example should include a bit more context such as what the self is mean to be.
It is better to describe what the selfs are about, and better write down code examples to help user understand how it can be used.

Reason for Change

Considering the context of plugin development, there are at least provider context and tool context. Although it is possible that both provider and tool contexts support the storage accessing, it is unclear in the example.
Also, the interface set references self as well, which confuses reader even more. It is possible to be used directly on tool context for example self.set(xxx) or self.session.storage.set(xxx).
It is better to describe this directly. If it is possible to provide code examples, which would be better.

Code of Conduct

  • I agree to follow Dify's documentation contribution guidelines
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions