MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / BundleInstance

Class BundleInstance

backend/app/models/tool/bundle_instance.py:10–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class BundleInstance(ModelEntity):
11 bundle_instance_id: str
12
13 encrypted_credentials: Dict
14 display_credentials: Dict
15 bundle_id: str # get bundle_id from plugin service
16 name: str
17
18 metadata: Dict
19 plugins: List[Plugin]
20 description: str
21 icon_url: str
22
23 created_timestamp: int
24 updated_timestamp: int
25
26 @staticmethod
27 def build(row):
28 from app.services.tool import list_plugins, get_bundle
29
30 try:
31 plugins = list_plugins(bundle_id=row["bundle_id"])
32 except Exception as e:
33 plugins = []
34
35 bundle = get_bundle(row["bundle_id"])
36
37 return BundleInstance(
38 bundle_instance_id=row["bundle_instance_id"],
39 encrypted_credentials=load_json_attr(row, "encrypted_credentials", {}),
40 display_credentials=load_json_attr(row, "display_credentials", {}),
41 bundle_id=row["bundle_id"],
42 name=row["name"],
43 metadata=load_json_attr(row, "metadata", {}),
44 plugins=plugins,
45 description=bundle.description,
46 icon_url=bundle.icon_url,
47 created_timestamp=row["created_timestamp"],
48 updated_timestamp=row["updated_timestamp"],
49 )
50
51 def to_response_dict(self, **kwargs) -> Dict:
52 from app.services.tool import i18n_text
53
54 # todo: currently we only support en
55 lang = kwargs.get("lang", "en")
56 return {
57 "object": "BundleInstance",
58 "bundle_instance_id": self.bundle_instance_id,
59 "display_credentials": self.display_credentials,
60 "bundle_id": self.bundle_id,
61 "name": self.name,
62 "metadata": self.metadata,
63 "plugins": [plugin.to_dict(lang=lang) for plugin in self.plugins],
64 "description": i18n_text(self.bundle_id, self.description, lang),
65 "icon_url": self.icon_url,
66 "created_timestamp": self.created_timestamp,
67 "updated_timestamp": self.updated_timestamp,

Callers 1

buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected