Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10: Crash if cluster commands list is init to empty map #11

Closed
wants to merge 2 commits into from

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Jul 16, 2023

AutoPR Failure

Fixes #10

Status

This pull request was being autonomously generated by AutoPR, but it encountered an error.

Error:

Traceback (most recent call last):
  File "/app/autopr/services/agent_service.py", line 78, in run_agent
    agent.handle_event(event)
  File "/app/autopr/agents/plan_and_code.py", line 216, in handle_event
    self.create_pull_request(event)
  File "/app/autopr/agents/plan_and_code.py", line 176, in create_pull_request
    context = self.action_service.run_actions_iteratively(
  File "/app/autopr/services/action_service.py", line 215, in run_actions_iteratively
    context = self.run_action(action_id, context)
  File "/app/autopr/services/action_service.py", line 186, in run_action
    results = action.run(arguments, context)
  File "/app/autopr/actions/look_at_files.py", line 379, in run
    notes = self.write_notes_about_files(files, context, filepaths)
  File "/app/autopr/actions/look_at_files.py", line 355, in write_notes_about_files
    response = self.rail_service.run_prompt_rail(rail)
  File "/app/autopr/services/rail_service.py", line 355, in run_prompt_rail
    prompt = self.completions_repo.complete(
  File "/app/autopr/repos/completions_repo.py", line 74, in complete
    raise e
  File "/app/autopr/repos/completions_repo.py", line 65, in complete
    result = self._complete(
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "/app/autopr/repos/completions_repo.py", line 142, in _complete
    openai_response = openai.ChatCompletion.create(
  File "/venv/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/venv/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 230, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 624, in _interpret_response
    self._interpret_response_line(
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: This model's maximum context length is 4097 tokens. However, you requested 5558 tokens (3558 in the messages, 2000 in the completion). Please reduce the length of the messages or completion.

Please open an issue to report this.

⚠️⚠️⚠️ Warning: Using gpt-3.5-turbo completion model. AutoPR is currently not optimized for this model. See irgolic/AutoPR#65 for more details. In the mean time, if you have access to the gpt-4 API, please use that instead. Please note that ChatGPT Plus does not give you access to the gpt-4 API; you need to sign up on the GPT-4 API waitlist.

📖 Looking at files
💬 Asked for InitialFileSelect
Prompt
Hey, somebody just opened an issue in my repo, could you help me write a pull request?

Given context variables enclosed by +-+:

Issue:
+-+
#10 Crash if cluster commands list is init to empty map

zakaria1193: may affect cluster with empty aattribute list too,

Stop using pointers in the cluster, use refs or smart pointers instead.



+-+

The list of files in the repo is:
```.clang-format (170 tokens)
.clang-tidy (148 tokens)
.gitignore (225 tokens)
.gitmodules (45 tokens)
.travis.yml (1315 tokens)
CMakeLists.txt (2468 tokens)
Makefile (340 tokens)
README.md (231 tokens)
first_setup.sh (93 tokens)
.idea/.gitignore (6 tokens)
.idea/cmake-project-template.iml (37 tokens)
.idea/workspace.xml.example (1444 tokens)
src/main.cpp (573 tokens)
src/nwk_mgt_commands.cpp (296 tokens)
.github/workflows/build.yml (388 tokens)
.github/workflows/gpt-auto-pr.yml (543 tokens)
.idea/dictionaries/kig.xml (60 tokens)
.idea/inspectionProfiles/Project_Default.xml (177 tokens)
.idea/markdown-navigator/profiles_settings.xml (27 tokens)
include/device/device.hpp (1975 tokens)
include/device_pool/pool.hpp (566 tokens)
include/nwk/nwk_mgt_commands.hpp (667 tokens)
include/nwk/pan.hpp (211 tokens)
src/clusters/global_commands.cpp (943 tokens)
src/clusters/on_off.cpp (490 tokens)
include/zcl/clusters/global_commands.hpp (1120 tokens)
include/zcl/clusters/on_off_cluster.hpp (2038 tokens)
include/zcl/common/attributes.hpp (862 tokens)
include/zcl/common/cluster.hpp (1742 tokens)
include/zcl/common/commands.hpp (836 tokens)
include/zcl/common/reporting_configuration.hpp (294 tokens)
include/zcl/common/zcl_status.hpp (128 tokens)```

Should we take a look at any files? If so, pick only a few files (max 5000 tokens). 
Respond with a very short rationale, and a list of files.
If looking at files would be a waste of time with regard to the issue, respond with an empty list.
Response
Yes, we should take a look at the following files:

- src/nwk_mgt_commands.cpp (296 tokens): This file is mentioned in the issue description and is related to the crash with an empty attribute list.

The rationale for selecting this file is that it is the most relevant file mentioned in the issue and is likely to contain the code that needs to be modified to fix the crash.

Let's start by examining the contents of this file.
🛤 Ran InitialFileSelectResponse on rail
Prompt
Given the following document surrounded by `+++++`, answer the following questions. 
If the answer doesn't exist in the document, enter `null`.

+++++
Yes, we should take a look at the following files:

- src/nwk_mgt_commands.cpp (296 tokens): This file is mentioned in the issue description and is related to the crash with an empty attribute list.

The rationale for selecting this file is that it is the most relevant file mentioned in the issue and is likely to contain the code that needs to be modified to fix the crash.

Let's start by examining the contents of this file.
+++++

Extract information from this document and return a JSON that follows the correct schema.
If looking at files would be a waste of time, please submit an empty list.


Given below is XML that describes the information to extract from this document and the tags to extract it into.


<output>
    <list name="filepaths">
        <string description="Files in this repository that we should look at."/>
    </list>
</output>

Raw output
{
  "filepaths": [
    "src/nwk_mgt_commands.cpp"
  ]
}
Parsed output
{
  "filepaths": [
    "src/nwk_mgt_commands.cpp"
  ]
}
Validated output
{
  "filepaths": [
    "src/nwk_mgt_commands.cpp"
  ]
}
💬 Asked for LookAtFiles
Prompt
Hey, somebody just submitted an issue, could you own it, and write a pull request?

Given context variables enclosed by +-+:

Issue:
+-+
#10 Crash if cluster commands list is init to empty map

zakaria1193: may affect cluster with empty aattribute list too,

Stop using pointers in the cluster, use refs or smart pointers instead.



+-+

We've decided to look at these files:
```>>> Path: src/nwk_mgt_commands.cpp:

0 #include <nwk/nwk_mgt_commands.hpp>
1 
2 namespace nwk
3 {
4 
5 zcl::ZclStatus requestNwkAddressExecuter(
6     device::Pool& pool, const device::MacAddress& input_mac_address,
7     device::short_address_t& output_nwk_address)
8 {
9   auto device = pool.get_device_by_mac(input_mac_address);
10 
11   output_nwk_address = device.get_short_address();
12 
13   return zcl::ZclStatus::success;
14 }
15 
16 zcl::ZclStatus requestMacAddressExecuter(
17     device::Pool& pool, const device::short_address_t& input_nwk_address,
18     device::MacAddress& output_mac_address)
19 {
20   auto device = pool.get_device_by_short(input_nwk_address);
21 
22   output_mac_address = device.get_mac_address();
23 
24   return zcl::ZclStatus::success;
25 }
26 
27 zcl::ZclStatus leaveExecuter(device::Device& device)
28 {
29   device.leave_pan();
30 
31   return zcl::ZclStatus::success;
32 }
33 
34 }  // namespace nwk```

The list of files in the repo that we haven't taken a look at yet:
```.clang-format (170 tokens)
.clang-tidy (148 tokens)
.gitignore (225 tokens)
.gitmodules (45 tokens)
.travis.yml (1315 tokens)
CMakeLists.txt (2468 tokens)
Makefile (340 tokens)
README.md (231 tokens)
first_setup.sh (93 tokens)
.idea/.gitignore (6 tokens)
.idea/cmake-project-template.iml (37 tokens)
.idea/workspace.xml.example (1444 tokens)
src/main.cpp (573 tokens)
.github/workflows/build.yml (388 tokens)
.github/workflows/gpt-auto-pr.yml (543 tokens)
.idea/dictionaries/kig.xml (60 tokens)
.idea/inspectionProfiles/Project_Default.xml (177 tokens)
.idea/markdown-navigator/profiles_settings.xml (27 tokens)
include/device/device.hpp (1975 tokens)
include/device_pool/pool.hpp (566 tokens)
include/nwk/nwk_mgt_commands.hpp (667 tokens)
include/nwk/pan.hpp (211 tokens)
src/clusters/global_commands.cpp (943 tokens)
src/clusters/on_off.cpp (490 tokens)
include/zcl/clusters/global_commands.hpp (1120 tokens)
include/zcl/clusters/on_off_cluster.hpp (2038 tokens)
include/zcl/common/attributes.hpp (862 tokens)
include/zcl/common/cluster.hpp (1742 tokens)
include/zcl/common/commands.hpp (836 tokens)
include/zcl/common/reporting_configuration.hpp (294 tokens)
include/zcl/common/zcl_status.hpp (128 tokens)```

Take some notes that will help us plan our code commits, in an effort to close the issue. 
Also, should we take a look at any other files? If so, pick only a few files (max 5000 tokens).
Respond with some very brief notes, and a list of files to continue looking at. 
If looking at files would be a waste of time with regard to the issue, respond with an empty list.
Response
Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.

To address this issue, we should make the following changes:

1. Replace the usage of pointers in the cluster with references or smart pointers.
2. Ensure that the cluster commands list is properly initialized, even if it's empty.

The files we have already looked at are:
- src/nwk_mgt_commands.cpp

The files we should continue looking at are:
- include/nwk/nwk_mgt_commands.hpp (667 tokens)
- include/device/device.hpp (1975 tokens)
- include/device_pool/pool.hpp (566 tokens)
- include/zcl/clusters/global_commands.hpp (1120 tokens)
🛤 Ran LookAtFilesResponse on rail
Prompt
Given the following document surrounded by `+++++`, answer the following questions. 
If the answer doesn't exist in the document, enter `null`.

+++++
Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.

To address this issue, we should make the following changes:

1. Replace the usage of pointers in the cluster with references or smart pointers.
2. Ensure that the cluster commands list is properly initialized, even if it's empty.

The files we have already looked at are:
- src/nwk_mgt_commands.cpp

The files we should continue looking at are:
- include/nwk/nwk_mgt_commands.hpp (667 tokens)
- include/device/device.hpp (1975 tokens)
- include/device_pool/pool.hpp (566 tokens)
- include/zcl/clusters/global_commands.hpp (1120 tokens)
+++++

Extract information from this document and return a JSON that follows the correct schema.
If looking at files would be a waste of time, please submit an empty list.


Given below is XML that describes the information to extract from this document and the tags to extract it into.


<output>
    <string name="notes" description="Notes relevant to solving the issue, that we will use to plan our code commits." length="1 1000" on-fail="noop"/>
    <list name="filepaths_we_should_look_at">
        <string description="The paths to files we should look at next in the repo. Drop any files that are a waste of time with regard to the issue."/>
    </list>
</output>

Raw output
{
  "notes": "Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.\n\nTo address this issue, we should make the following changes:\n\n1. Replace the usage of pointers in the cluster with references or smart pointers.\n2. Ensure that the cluster commands list is properly initialized, even if it's empty.",
  "filepaths_we_should_look_at": [
    "include/nwk/nwk_mgt_commands.hpp",
    "include/device/device.hpp",
    "include/device_pool/pool.hpp",
    "include/zcl/clusters/global_commands.hpp"
  ]
}
Parsed output
{
  "notes": "Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.\n\nTo address this issue, we should make the following changes:\n\n1. Replace the usage of pointers in the cluster with references or smart pointers.\n2. Ensure that the cluster commands list is properly initialized, even if it's empty.",
  "filepaths_we_should_look_at": [
    "include/nwk/nwk_mgt_commands.hpp",
    "include/device/device.hpp",
    "include/device_pool/pool.hpp",
    "include/zcl/clusters/global_commands.hpp"
  ]
}
Validated output
{
  "filepaths_we_should_look_at": [
    "include/nwk/nwk_mgt_commands.hpp",
    "include/device/device.hpp",
    "include/device_pool/pool.hpp",
    "include/zcl/clusters/global_commands.hpp"
  ],
  "notes": "Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.\n\nTo address this issue, we should make the following changes:\n\n1. Replace the usage of pointers in the cluster with references or smart pointers.\n2. Ensure that the cluster commands list is properly initialized, even if it's empty."
}
❌ Failed look_at_files
Prompt
Hey, somebody just submitted an issue, could you own it, and write a pull request?

Given context variables enclosed by +-+:

Issue:
+-+
#10 Crash if cluster commands list is init to empty map

zakaria1193: may affect cluster with empty aattribute list too,

Stop using pointers in the cluster, use refs or smart pointers instead.



+-+

Some notes we've taken while looking at files so far:
```Based on the issue description and the provided code snippet, it seems that the crash occurs when cluster commands list is initialized to an empty map. The suggestion is to stop using pointers in the cluster and instead use refs or smart pointers.

To address this issue, we should make the following changes:

1. Replace the usage of pointers in the cluster with references or smart pointers.
2. Ensure that the cluster commands list is properly initialized, even if it's empty.```

We've decided to look at these files:
```>>> Path: include/device/device.hpp:

0 #ifndef ZCL_DEVICE_HPP
1 #define ZCL_DEVICE_HPP
2 
3 #include <cstdint>
4 #include <iomanip>
5 #include <utility>
6 #include <vector>
7 #include <memory>
8 
9 #include <zcl/clusters/on_off_cluster.hpp>
10 
11 #include "zcl/common/cluster.hpp"
12 #include "zcl/common/commands.hpp"
13 
14 #include "nwk/pan.hpp"
15 
16 namespace device
17 {
18 
19 using endpoint_id_t  = uint8_t;
20 using cluster_list_t = std::vector<zcl::Cluster>;
21 
22 class Endpoint
23 {
24   endpoint_id_t  ep_id;
25   cluster_list_t clusters;
26 
27  public:
28   Endpoint(endpoint_id_t ep_id, cluster_list_t clusters)
29       : ep_id(ep_id), clusters(std::move(clusters))
30   {
31   }
32 
33   [[nodiscard]] endpoint_id_t get_endpoint_id() const { return ep_id; }
34 
35   zcl::Cluster& get_cluster(const zcl::cluster_id_t cluster_id)
36   {
37     for (auto& cluster : clusters)
38     {
39       if (cluster.get_descriptor().id == cluster_id)
40       {
41         return cluster;
42       }
43     }
44     throw std::runtime_error("Cluster not found");
45   }
46 };
47 
48 using endpoint_list_t = std::vector<Endpoint>;
49 using short_address_t = uint16_t;
50 
51 class MacAddress
52 {
53   using mac_address_value_t = std::array<uint8_t, 8>;
54   mac_address_value_t address{};
55   size_t              size{};
56 
57  public:
58   MacAddress() = delete;
59 
60   // Constructer from byte arg list using initializer list
61   template <typename... Args>
62   explicit MacAddress(Args... args) : size(sizeof...(args))
63   {
64     size_t index = 0;
65 
66     if (size > address.size())
67     {
68       throw std::runtime_error("MacAddress constructor received too many bytes");
69     }
70 
71     for (auto arg : {args...})
72     {
73       address[index++] = arg;
74     }
75 
76     std::cout << "MacAddress created with " << size << " bytes" << std::endl;
77 
78   }
79 
80   [[nodiscard]] std::string get_string() const
81   {
82     std::stringstream ss;
83     // Format 00:AA:BB:CC:DD:EE:FF:00
84     for (size_t i = 0; i < size; i++)
85     {
86       bool is_last = i == size - 1;
87       ss << std::setfill('0') << std::setw(2) << std::hex
88          << static_cast<int>(address[i]) << (is_last ? "" : ":");
89     }
90 
91     return ss.str();
92   }
93 
94   // Comparison operators
95   bool operator==(const MacAddress& rhs) const
96   {
97     return address == rhs.address;
98   }
99 
100   bool operator!=(const MacAddress& rhs) const
101   {
102     return !(rhs == *this);
103   }
104 };
105 
106 class Device
107 {
108   MacAddress mac_address;
109   endpoint_list_t endpoints;
110 
111   // Attributes depending on the network
112   std::weak_ptr<nwk::Pan> pan{};
113   short_address_t  short_address{};
114   bool            reacheable{true};
115 
116  public:
117   Device() = delete;
118   Device(MacAddress mac_address, endpoint_list_t endpoints)
119       : mac_address(mac_address),
120         endpoints(std::move(endpoints))
121   {
122       std::cout << "Device created with MAC: " << mac_address.get_string()
123         << " and " << endpoints.size() << " endpoints"
124         << std::endl;
125   }
126 
127   [[nodiscard]]  MacAddress get_mac_address() const { return mac_address; }
128 
129   [[nodiscard]] short_address_t get_short_address() const
130   {
131     return short_address;
132   }
133 
134   [[nodiscard]] bool is_reacheable() const { return reacheable; }
135 
136   [[nodiscard]] bool is_in_network() const { return pan.lock() != nullptr; }
137 
138   [[nodiscard]] const endpoint_list_t& get_endpoints() const
139   {
140     return endpoints;
141   }
142 
143   Endpoint& get_endpoint(const endpoint_id_t ep_id)
144   {
145     auto ept = std::find_if(endpoints.begin(), endpoints.end(),
146                  [ep_id](const Endpoint& ept) { return ept.get_endpoint_id() == ep_id; });
147 
148     if (ept == endpoints.end())
149     {
150       throw std::runtime_error("Endpoint not found");
151     }
152 
153     return *ept;
154   }
155 
156   template <typename... Args>
157   zcl::ZclStatus execute_cluster_command(const endpoint_id_t     ep_id,
158                                          const zcl::cluster_id_t cluster_id,
159                                          const zcl::command_id_t command_id,
160                                          bool is_common, Args... args)
161   {
162     Endpoint     ept     = get_endpoint(ep_id);
163     zcl::Cluster cluster = ept.get_cluster(cluster_id);
164 
165     return cluster.execute_cluster_command<Args...>(command_id, is_common,
166                                                     args...);
167   }
168 
169   bool join_pan(const std::shared_ptr<nwk::Pan>& pan)
170   {
171     if (!pan->is_permit_joining())
172     {
173       std::cout << "Joining not allowed" << std::endl;
174       return false;
175     }
176 
177     this->pan = pan;
178     return true;
179   }
180 
181   void leave_pan()
182   {
183     pan.reset();
184   }
185 };
186 
187 class OnOffDevice : public Device
188 {
189  public:
190   explicit OnOffDevice(MacAddress mac_address)
191       : Device(mac_address,
192                {Endpoint{1, {zcl::on_off_cluster::OnOffCluster()}}}){};
193 };
194 
195 }  // namespace device
196 
197 #endif  // ZCL_DEVICE_HPP__
>>> Path: include/device_pool/pool.hpp:

0 #ifndef DEVICE_POOL_POOL_HPP
1 #define DEVICE_POOL_POOL_HPP
2 
3 #include <device/device.hpp>
4 #include <nwk/pan.hpp>
5 
6 #include <memory>
7 
8 namespace device
9 {
10 class Pool
11 {
12   using device_list   = std::vector<Device>;
13   device_list devices = {};
14 
15   // Each pool has its own PAN
16     std::shared_ptr<nwk::Pan> pan;
17 
18  public:
19   Pool() = delete;
20 
21   explicit Pool(nwk::pan_id_t pan_id) : pan(std::make_shared<nwk::Pan>(pan_id))
22   {
23   }
24   
25   Pool(device_list devices, nwk::pan_id_t pan_id)
26       : devices(std::move(devices)), pan(std::make_shared<nwk::Pan>(pan_id))
27   {
28   }
29 
30   [[nodiscard]] std::shared_ptr<nwk::Pan> get_pan() const { return pan; }
31 
32   [[nodiscard]] const device_list& get_devices() const { return devices; }
33 
34   void add_device(Device& device) { devices.push_back(device); }
35 
36   device::Device& get_device_by_mac(const device::MacAddress& mac)
37   {
38     for (auto& device : devices)
39     {
40       if (device.get_mac_address() == mac)
41       {
42         return device;
43       }
44     }
45 
46     throw std::runtime_error("Device not found");
47   }
48 
49   device::Device& get_device_by_short(
50       const device::short_address_t& short_address)
51   {
52     for (auto& device : devices)
53     {
54       if (device.get_short_address() == short_address)
55       {
56         return device;
57       }
58     }
59 
60     throw std::runtime_error("Device not found");
61   }
62 };
63 }  // namespace device
64 
65 #endif  // DEVICE_POOL_POOL_HPP
>>> Path: include/nwk/nwk_mgt_commands.hpp:

0 #ifndef NWK_MGT_COMMANDS_HPP
1 #define NWK_MGT_COMMANDS_HPP
2 
3 #include <device/device.hpp>
4 #include <device_pool/pool.hpp>
5 #include <zcl/common/commands.hpp>
6 
7 //////////////////////////////
8 // Command descriptors
9 //////////////////////////////
10 
11 namespace nwk
12 {
13 
14 // Request NWK address command
15 const zcl::CommandDescriptor requestNwkAddressCmdDescriptor{
16     /*cmd_id=*/0,
17     /*is_common=*/true,
18     /*is_mandatory=*/true,
19     /*description=*/"Request NWK address"};
20 
21 zcl::ZclStatus requestNwkAddressExecuter(
22     device::Pool& pool, const device::MacAddress& input_mac_address,
23     device::short_address_t& output_nwk_address);
24 
25 const zcl::Command requestNwkAddressCommand{/*exec=*/requestNwkAddressExecuter};
26 
27 // Request mac address command
28 const zcl::CommandDescriptor requestMacAddressCmdDescriptor{
29     /*cmd_id=*/1,
30     /*is_common=*/true,
31     /*is_mandatory=*/true,
32     /*description=*/"Request MAC address"};
33 
34 zcl::ZclStatus requestMacAddressExecuter(
35     device::Pool& pool, const device::short_address_t& input_nwk_address,
36     device::MacAddress& output_mac_address);
37 
38 const zcl::Command requestMacAddressCommand{/*exec=*/requestMacAddressExecuter};
39 
40 // Leave command
41 const zcl::CommandDescriptor leaveCmdDescriptor{/*cmd_id=*/0x34,
42                                                 /*is_common=*/true,
43                                                 /*is_mandatory=*/true,
44                                                 /*description=*/"leave"};
45 
46 zcl::ZclStatus leaveExecuter(device::Device& device);
47 
48 const zcl::Command leaveCommand{/*exec=*/leaveExecuter};
49 
50 }  // namespace nwk
51 
52 #endif  // NWK_MGT_COMMANDS_HPP
>>> Path: include/zcl/clusters/global_commands.hpp:

0 #ifndef ZCL_CLUSTERS_GLOBAL_COMMANDS_HPP
1 #define ZCL_CLUSTERS_GLOBAL_COMMANDS_HPP
2 
3 #include <zcl/common/attributes.hpp>
4 #include <zcl/common/cluster.hpp>
5 #include <zcl/common/commands.hpp>
6 #include <zcl/common/reporting_configuration.hpp>
7 #include <zcl/common/zcl_status.hpp>
8 
9 namespace zcl
10 {
11 // Default commands
12 // For each command we need to define:
13 // 1. Command descriptor
14 // 2. Command executer
15 // 3. Command object
16 
17 // Read attribute command
18 const CommandDescriptor read_attribute_command_descriptor{
19     /*id*/ 0x00,
20     /*is_common*/ true,
21     /*is_mandatory*/ true,
22     /*description*/ "Read attribute"};
23 ZclStatus     readAttributeCommandExecuter(Cluster&         cluster,
24                                            const attr_id_t& attribute_id,
25                                            attr_value_t&    value);
26 const Command readAttributeCommand{/*exec=*/readAttributeCommandExecuter};
27 
28 // Write attribute command
29 const CommandDescriptor write_attribute_command_descriptor{
30     /*id*/ 0x02,
31     /*is_common*/ true,
32     /*is_mandatory*/ true,
33     /*description*/ "Write attribute"};
34 ZclStatus     writeAttributeCommandExecuter(Cluster&            cluster,
35                                             const attr_id_t&    attribute_id,
36                                             const attr_value_t& value);
37 const Command writeAttributeCommand{/*exec=*/writeAttributeCommandExecuter};
38 
39 // Configure reporting command
40 const CommandDescriptor configure_reporting_command_descriptor{
41     /*id*/ 0x06,
42     /*is_common*/ true,
43     /*is_mandatory*/ true,
44     /*description*/ "Configure reporting"};
45 ZclStatus configureReportingCommandExecuter(
46     Cluster& cluster, const attr_id_t& attribute_id,
47     const ReportingConfiguration& reporting_configuration);
48 const Command configureReportingCommand{
49     /*exec=*/configureReportingCommandExecuter};
50 
51 // Discover attributes command
52 const CommandDescriptor discover_attributes_command_descriptor{
53     /*id*/ 0x0C,
54     /*is_common*/ true,
55     /*is_mandatory*/ true,
56     /*description*/ "Discover attributes"};
57 ZclStatus discoverAttributesCommandExecuter(
58     Cluster&                             cluster,
59     std::vector<attribute_descriptor_t>& attribute_descriptors);
60 const Command discoverAttributesCommand{
61     /*exec=*/discoverAttributesCommandExecuter};
62 
63 // FIXME This command requires a special handling
64 // since it is send by the device
65 const CommandDescriptor report_attributes_command_descriptor{
66     /*id*/ 0x0A,
67     /*is_common*/ true,
68     /*is_mandatory*/ true,
69     /*description*/ "Report attributes"};
70 ZclStatus     reportAttributesCommandExecuter(Cluster&         cluster,
71                                               const Attribute& attribute);
72 const Command reportAttributesCommand{/*exec=*/reportAttributesCommandExecuter};
73 
74 }  // namespace zcl
75 
76 #endif  // ZCL_CLUSTERS_GLOBAL_COMMANDS_HPP```

The list of files in the repo that we haven't taken a look at yet:
```.clang-format (170 tokens)
.clang-tidy (148 tokens)
.gitignore (225 tokens)
.gitmodules (45 tokens)
.travis.yml (1315 tokens)
CMakeLists.txt (2468 tokens)
Makefile (340 tokens)
README.md (231 tokens)
first_setup.sh (93 tokens)
.idea/.gitignore (6 tokens)
.idea/cmake-project-template.iml (37 tokens)
.idea/workspace.xml.example (1444 tokens)
src/main.cpp (573 tokens)
.github/workflows/build.yml (388 tokens)
.github/workflows/gpt-auto-pr.yml (543 tokens)
.idea/dictionaries/kig.xml (60 tokens)
.idea/inspectionProfiles/Project_Default.xml (177 tokens)
.idea/markdown-navigator/profiles_settings.xml (27 tokens)
include/nwk/pan.hpp (211 tokens)
src/clusters/global_commands.cpp (943 tokens)
src/clusters/on_off.cpp (490 tokens)
include/zcl/clusters/on_off_cluster.hpp (2038 tokens)
include/zcl/common/attributes.hpp (862 tokens)
include/zcl/common/cluster.hpp (1742 tokens)
include/zcl/common/commands.hpp (836 tokens)
include/zcl/common/reporting_configuration.hpp (294 tokens)
include/zcl/common/zcl_status.hpp (128 tokens)```

Take some notes that will help us plan commits and write code to fix the issue. 
Also, let me know if we should take a look at any other files – our budget is 5000 tokens.
Error
Traceback (most recent call last):
  File "/app/autopr/services/action_service.py", line 186, in run_action
    results = action.run(arguments, context)
  File "/app/autopr/actions/look_at_files.py", line 379, in run
    notes = self.write_notes_about_files(files, context, filepaths)
  File "/app/autopr/actions/look_at_files.py", line 355, in write_notes_about_files
    response = self.rail_service.run_prompt_rail(rail)
  File "/app/autopr/services/rail_service.py", line 355, in run_prompt_rail
    prompt = self.completions_repo.complete(
  File "/app/autopr/repos/completions_repo.py", line 74, in complete
    raise e
  File "/app/autopr/repos/completions_repo.py", line 65, in complete
    result = self._complete(
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
  File "/app/autopr/repos/completions_repo.py", line 142, in _complete
    openai_response = openai.ChatCompletion.create(
  File "/venv/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/venv/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 230, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 624, in _interpret_response
    self._interpret_response_line(
  File "/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 687, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: This model's maximum context length is 4097 tokens. However, you requested 5558 tokens (3558 in the messages, 2000 in the completion). Please reduce the length of the messages or completion.

@cr-gpt
Copy link

cr-gpt bot commented Jul 16, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Jul 16, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@zakaria1193 zakaria1193 force-pushed the master branch 2 times, most recently from fd54977 to 66030e8 Compare July 20, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash if cluster commands list is init to empty map
2 participants