coincap-hedera-agent-kit-plugin 0.4__tar.gz → 0.8__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.
Files changed (16) hide show
  1. {coincap_hedera_agent_kit_plugin-0.4/src/coincap_hedera_agent_kit_plugin.egg-info → coincap_hedera_agent_kit_plugin-0.8}/PKG-INFO +56 -11
  2. coincap_hedera_agent_kit_plugin-0.8/setup.py +19 -0
  3. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8/src/coincap_hedera_agent_kit_plugin.egg-info}/PKG-INFO +56 -11
  4. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_agent_kit_plugin.egg-info/SOURCES.txt +0 -1
  5. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_plugin/__init__.py +1 -1
  6. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_plugin/coincap_plugin/plugin.py +6 -2
  7. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_plugin/coincap_plugin/tool.py +10 -9
  8. coincap_hedera_agent_kit_plugin-0.4/README.md +0 -78
  9. coincap_hedera_agent_kit_plugin-0.4/setup.py +0 -20
  10. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/LICENSE +0 -0
  11. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/README.rst +0 -0
  12. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/setup.cfg +0 -0
  13. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_agent_kit_plugin.egg-info/dependency_links.txt +0 -0
  14. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_agent_kit_plugin.egg-info/requires.txt +0 -0
  15. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_agent_kit_plugin.egg-info/top_level.txt +0 -0
  16. {coincap_hedera_agent_kit_plugin-0.4 → coincap_hedera_agent_kit_plugin-0.8}/src/coincap_hedera_plugin/coincap_plugin/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coincap-hedera-agent-kit-plugin
3
- Version: 0.4
3
+ Version: 0.8
4
4
  Home-page: https://github.com/henrytongv/coincap-hedera-plugin-py
5
5
  Author: Henry Tong
6
6
  Author-email: taksantong@gmail.com
@@ -51,24 +51,42 @@ COINCAP_BEARER_TOKEN=******************************
51
51
  from coincap_hedera_plugin import conincap_h_plugin
52
52
  ```
53
53
 
54
- 4.- Add the plugin in the plugins secion of the agent
54
+ 4.- Import the core_account_query_plugin plugin code
55
55
 
56
+ This core plugin is already provided by the Hedera, it is needed to query the account (read its balance)
56
57
  ```py
57
- const hederaAgentToolkit = new HederaLangchainToolkit({
58
- client,
59
- configuration: {
60
- tools: [],
61
- plugins: [coreQueriesPlugin, coreAccountPlugin, CoinCapHederalugin], // <---- Add these
58
+ from hedera_agent_kit.plugins import core_account_query_plugin
62
59
  ```
63
60
 
64
- 5.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
61
+ 5.- Add the plugin in the plugins secion of the agent
62
+
63
+ ```py
64
+ async def main():
65
+ ...
66
+ configuration=Configuration(
67
+ tools=[],
68
+ plugins=[
69
+ core_account_query_plugin,
70
+ conincap_h_plugin # <---- add the plugin here
71
+ ```
72
+
73
+ 6.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
65
74
 
66
75
  ```py
67
76
  response = await agent.ainvoke(
68
77
  {"messages": [{"role": "user", "content": "Get my balance in HBAR and also convert it to USD please"}]},
69
78
  ```
70
79
 
71
- 6.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
80
+ > [!NOTE]
81
+ > The previous prompt results in a multi-step tool invocation:
82
+ >
83
+ > - Fetch the HBAR balance.
84
+ > - Fetch the current HBAR price.
85
+ > - Convert the balance to USD.
86
+ >
87
+ > It is important for developers to be aware of, as configurations that limit the agent to only one tool call per request will cause this prompt to fail or behave incorrectly.
88
+
89
+ 7.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
72
90
 
73
91
  ```bash
74
92
  python main.py
@@ -76,12 +94,39 @@ python main.py
76
94
 
77
95
  ## Tools
78
96
 
97
+ ### Get HBAR price in USD
98
+ Invoke the CoinCap API to get the current price in USD of one HBAR
99
+
100
+ #### Python Function
79
101
  ```py
80
- # Use the CoinCap API to get the current price in USD of one HBAR
81
102
  def get_hbar_price_from_coincap():
82
103
  ```
83
104
 
84
- ## (Optional, only needed when creating your own python package) How to publish a PyPi package
105
+ #### Input Parameters
106
+
107
+ None
108
+
109
+ #### Output Values
110
+
111
+ | Value | Type | Description |
112
+ |---------|----------|-------------|
113
+ | Result | `float` | Value in USD currency of 1 HBAR according to CoinCap |
114
+
115
+ #### Example Prompt
116
+
117
+ ```
118
+ Get my balance in HBAR and also convert it to USD please
119
+ ```
120
+
121
+ ## Optional - Code building, only needed when working on the source code
122
+
123
+ Use a code formatter, for example `black`
124
+ ```bash
125
+ pip install black
126
+ black .
127
+ ```
128
+
129
+ ## Optional - Distribution, only needed when creating your own python package) How to publish a PyPi package
85
130
  1.- Read the [instructions](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3/)
86
131
 
87
132
  1.- Create the distribution package
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="coincap-hedera-agent-kit-plugin",
5
+ version="0.8",
6
+ license="MIT",
7
+ author="Henry Tong",
8
+ author_email="taksantong@gmail.com",
9
+ long_description=open("README.md").read(),
10
+ long_description_content_type="text/markdown",
11
+ packages=find_packages("src"),
12
+ package_dir={"": "src"},
13
+ url="https://github.com/henrytongv/coincap-hedera-plugin-py",
14
+ keywords="hedera agent-kit coincap web3",
15
+ install_requires=[
16
+ "hedera-agent-kit",
17
+ "requests",
18
+ ],
19
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coincap-hedera-agent-kit-plugin
3
- Version: 0.4
3
+ Version: 0.8
4
4
  Home-page: https://github.com/henrytongv/coincap-hedera-plugin-py
5
5
  Author: Henry Tong
6
6
  Author-email: taksantong@gmail.com
@@ -51,24 +51,42 @@ COINCAP_BEARER_TOKEN=******************************
51
51
  from coincap_hedera_plugin import conincap_h_plugin
52
52
  ```
53
53
 
54
- 4.- Add the plugin in the plugins secion of the agent
54
+ 4.- Import the core_account_query_plugin plugin code
55
55
 
56
+ This core plugin is already provided by the Hedera, it is needed to query the account (read its balance)
56
57
  ```py
57
- const hederaAgentToolkit = new HederaLangchainToolkit({
58
- client,
59
- configuration: {
60
- tools: [],
61
- plugins: [coreQueriesPlugin, coreAccountPlugin, CoinCapHederalugin], // <---- Add these
58
+ from hedera_agent_kit.plugins import core_account_query_plugin
62
59
  ```
63
60
 
64
- 5.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
61
+ 5.- Add the plugin in the plugins secion of the agent
62
+
63
+ ```py
64
+ async def main():
65
+ ...
66
+ configuration=Configuration(
67
+ tools=[],
68
+ plugins=[
69
+ core_account_query_plugin,
70
+ conincap_h_plugin # <---- add the plugin here
71
+ ```
72
+
73
+ 6.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
65
74
 
66
75
  ```py
67
76
  response = await agent.ainvoke(
68
77
  {"messages": [{"role": "user", "content": "Get my balance in HBAR and also convert it to USD please"}]},
69
78
  ```
70
79
 
71
- 6.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
80
+ > [!NOTE]
81
+ > The previous prompt results in a multi-step tool invocation:
82
+ >
83
+ > - Fetch the HBAR balance.
84
+ > - Fetch the current HBAR price.
85
+ > - Convert the balance to USD.
86
+ >
87
+ > It is important for developers to be aware of, as configurations that limit the agent to only one tool call per request will cause this prompt to fail or behave incorrectly.
88
+
89
+ 7.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
72
90
 
73
91
  ```bash
74
92
  python main.py
@@ -76,12 +94,39 @@ python main.py
76
94
 
77
95
  ## Tools
78
96
 
97
+ ### Get HBAR price in USD
98
+ Invoke the CoinCap API to get the current price in USD of one HBAR
99
+
100
+ #### Python Function
79
101
  ```py
80
- # Use the CoinCap API to get the current price in USD of one HBAR
81
102
  def get_hbar_price_from_coincap():
82
103
  ```
83
104
 
84
- ## (Optional, only needed when creating your own python package) How to publish a PyPi package
105
+ #### Input Parameters
106
+
107
+ None
108
+
109
+ #### Output Values
110
+
111
+ | Value | Type | Description |
112
+ |---------|----------|-------------|
113
+ | Result | `float` | Value in USD currency of 1 HBAR according to CoinCap |
114
+
115
+ #### Example Prompt
116
+
117
+ ```
118
+ Get my balance in HBAR and also convert it to USD please
119
+ ```
120
+
121
+ ## Optional - Code building, only needed when working on the source code
122
+
123
+ Use a code formatter, for example `black`
124
+ ```bash
125
+ pip install black
126
+ black .
127
+ ```
128
+
129
+ ## Optional - Distribution, only needed when creating your own python package) How to publish a PyPi package
85
130
  1.- Read the [instructions](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3/)
86
131
 
87
132
  1.- Create the distribution package
@@ -6,4 +6,4 @@ __all__ = [
6
6
  from coincap_hedera_plugin.coincap_plugin import (
7
7
  conincap_h_plugin,
8
8
  conincap_h_plugin_tool_names,
9
- )
9
+ )
@@ -13,6 +13,7 @@ from hedera_agent_kit.shared.utils.prompt_generator import PromptGenerator
13
13
 
14
14
  from coincap_hedera_plugin.coincap_plugin.tool import get_hbar_price_from_coincap
15
15
 
16
+
16
17
  def get_hbar_price_in_usd_prompt(context: Context = {}) -> str:
17
18
  """Generate a human-readable description of the get hbar price in usd query tool.
18
19
 
@@ -35,10 +36,11 @@ Parameters:
35
36
  {usage_instructions}
36
37
  """
37
38
 
39
+
38
40
  async def get_hbar_price_in_usd_query(
39
41
  client: Client,
40
42
  context: Context,
41
- params: AccountQueryParameters,
43
+ params: None,
42
44
  ) -> ToolResponse:
43
45
  """Execute a get hbar price in usd request to coincap API.
44
46
 
@@ -55,7 +57,9 @@ async def get_hbar_price_in_usd_query(
55
57
  """
56
58
  try:
57
59
  current_price_of_hbar_in_usd = get_hbar_price_from_coincap()
58
- print(f"coincap said that the price in USD of one HBAR is {current_price_of_hbar_in_usd}")
60
+ print(
61
+ f"coincap said that the price in USD of one HBAR is {current_price_of_hbar_in_usd}"
62
+ )
59
63
  return ToolResponse(
60
64
  human_message=str(current_price_of_hbar_in_usd),
61
65
  )
@@ -1,24 +1,25 @@
1
1
  import requests
2
2
  import os
3
3
 
4
+
4
5
  # Use the CoinCap API to get the current price in USD of one HBAR
5
6
  def get_hbar_price_from_coincap():
6
- headers = {
7
- "Authorization": f"Bearer {os.getenv("BEARER_TOKEN")}"
8
- }
7
+ headers = {"Authorization": f"Bearer {os.getenv("COINCAP_BEARER_TOKEN")}"}
9
8
 
10
9
  # Send GET request
11
- response = requests.get("https://rest.coincap.io/v3/price/bysymbol/hbar", headers=headers)
12
-
10
+ response = requests.get(
11
+ "https://rest.coincap.io/v3/price/bysymbol/hbar", headers=headers
12
+ )
13
+
13
14
  # Raise an error if the request failed (4xx / 5xx)
14
15
  response.raise_for_status()
15
-
16
+
16
17
  # Parse JSON response
17
18
  json_data = response.json()
18
-
19
+
19
20
  # Get the first element from the "data" array and convert it to float
20
21
  first_value = float(json_data["data"][0])
21
22
 
22
23
  print(f"* got this value from coincap api {first_value}")
23
-
24
- return first_value
24
+
25
+ return first_value
@@ -1,78 +0,0 @@
1
- # Hedera Agent Kit - CoinCap Plugin Python version
2
-
3
- A plugin for [Hedera Agent Kit PY](https://github.com/hashgraph/hedera-agent-kit-py) that provides integration with the CoinCap API
4
-
5
- In this plugin we use CoinCap to get the current price in USD of one HBAR and combine it with the power of the Hedera Agent Kit to get your current balance of HBA in USD currency.
6
-
7
- ## Overview
8
-
9
- This plugin enables `AI agents` to interact with the CoinCap API
10
-
11
- ## Installation in the example index.js agent
12
-
13
- 1.- Install the plugin
14
-
15
- ```bash
16
- pip install coincap-hedera-agent-kit-plugin
17
- ```
18
-
19
- 2.- Add your CoinCap API Bearer token in the .env file ( You get it in the CoinCap website )
20
-
21
- ```
22
- # Coincap API needed by coincap-hedera-plugin
23
- COINCAP_BEARER_TOKEN=******************************
24
- ```
25
-
26
- 3.- Import the plugin code in your index.js (Hedera Agent)
27
-
28
- ```py
29
- from coincap_hedera_plugin import conincap_h_plugin
30
- ```
31
-
32
- 4.- Add the plugin in the plugins secion of the agent
33
-
34
- ```py
35
- const hederaAgentToolkit = new HederaLangchainToolkit({
36
- client,
37
- configuration: {
38
- tools: [],
39
- plugins: [coreQueriesPlugin, coreAccountPlugin, CoinCapHederalugin], // <---- Add these
40
- ```
41
-
42
- 5.- Use a prompt to ask for you current balance and tell the agent to want it in USD currency, for example like this:
43
-
44
- ```py
45
- response = await agent.ainvoke(
46
- {"messages": [{"role": "user", "content": "Get my balance in HBAR and also convert it to USD please"}]},
47
- ```
48
-
49
- 6.- Now you can run the example agent and you should get your current HBAR balance converted to USD currency
50
-
51
- ```bash
52
- python main.py
53
- ```
54
-
55
- ## Tools
56
-
57
- ```py
58
- # Use the CoinCap API to get the current price in USD of one HBAR
59
- def get_hbar_price_from_coincap():
60
- ```
61
-
62
- ## (Optional, only needed when creating your own python package) How to publish a PyPi package
63
- 1.- Read the [instructions](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3/)
64
-
65
- 1.- Create the distribution package
66
- ```bash
67
- python setup.py sdist
68
- ```
69
-
70
- 2.- Install twine
71
- ```bash
72
- pip install twine
73
- ```
74
-
75
- 3.- Upload package
76
- ```bash
77
- twine upload dist/*
78
- ```
@@ -1,20 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- setup(
4
- name='coincap-hedera-agent-kit-plugin',
5
- version='0.4',
6
- license='MIT',
7
- author="Henry Tong",
8
- author_email='taksantong@gmail.com',
9
- long_description=open('README.md').read(),
10
- long_description_content_type='text/markdown',
11
- packages=find_packages('src'),
12
- package_dir={'': 'src'},
13
- url='https://github.com/henrytongv/coincap-hedera-plugin-py',
14
- keywords='hedera agent-kit coincap web3',
15
- install_requires=[
16
- 'hedera-agent-kit',
17
- 'requests',
18
- ],
19
-
20
- )