Skip to content

Commit 702124d

Browse files
committed
feat: Switch to the custom chat bot feature and improve the suggestions
1 parent 98afb25 commit 702124d

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

action.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ inputs:
1111
description: Issue title.
1212
required: false
1313
default: ''
14+
bot_behavior_setup:
15+
required: false
16+
description: Sets the behavior of the bot who should know where it is being deployed.
17+
default: >
18+
You are an Engineer tasked to solve Github issues. You are professional, knowledgeable, helpful and always
19+
friendly. You try to understand the given issue (bug report, feature request) and provide several ideas which
20+
the customer can try until an Espressif Engineer handles the issue.
1421
bot_query_prefix:
15-
description: The issue message can be prefixed with this string before evaluation.
22+
description: Instructions to the bot how to respond to issues.
1623
required: false
1724
default: >
18-
The customer opened a Github issue with the following information. Please help and I'll post your answer there.
25+
Write a detailed reaction to the Github issue. Please warn the customer if you suggest to try something which
26+
can do irreversible damage (e.g. writing eFuses, enabling security features). Check if the bug report have
27+
enough information for reproducing the issue. Feature requests should give detailed justification of the request
28+
including why existing solutions are insufficient. Ask the customer to provide more information if needed.
29+
Try to provide links to documentation, troubleshooting guides or other Espressif documents if you used
30+
knowledge from them. If possible then link related and similar issues. Suggest to open a new Github issue only
31+
in the case the customer is opened it for the wrong Github repository. Provide the output in Github Markdown
32+
format.
1933
github_comments:
2034
description: If set to false, the bot will not post a reply to the issue.
2135
default: true
@@ -69,13 +83,19 @@ runs:
6983
run: |
7084
source venv/bin/activate
7185
cat << 'EOF' > input.txt
86+
The issue posted in the Github repository: ${{ inputs.github_repository }}
87+
Github issue title: ${{ inputs.title }}
88+
Github issue text: ${{ inputs.in_msg }}
89+
EOF
90+
cat << 'EOF' > bot_instructions.txt
7291
${{ inputs.bot_query_prefix }}
73-
${{ inputs.title }}
74-
${{ inputs.in_msg }}
92+
EOF
93+
cat << 'EOF' > bot_behavior.txt
94+
${{ inputs.bot_behavior_setup }}
7595
EOF
7696
printf "%s\n" "${{ inputs.prefix_out_msg }}" > output.txt
7797
printf "\n---\n" >> output.txt
78-
python bot_action/bot_action.py input.txt >> output.txt || exit 1
98+
python bot_action/bot_action.py --behavior bot_behavior.txt --instructions bot_instructions.txt input.txt >> output.txt || exit 1
7999
80100
- name: Archive artifacts
81101
uses: actions/upload-artifact@v4
@@ -85,6 +105,8 @@ runs:
85105
path: |
86106
output.txt
87107
input.txt
108+
bot_instructions.txt
109+
bot_behavior.txt
88110
89111
- name: Comment
90112
if: ${{ inputs.github_comments == 'true' }}

bot_action/bot_action.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@
1010
import requests
1111

1212

13-
def get_suggestion(issue_body: str) -> str:
14-
payload = json.dumps({'integration_id': os.environ['BOT_INTEGRATION_ID'], 'query': issue_body})
13+
def get_suggestion(query: str, instructions: str, behavior: str) -> str:
14+
payload = json.dumps(
15+
{
16+
'integration_id': os.environ['BOT_INTEGRATION_ID'],
17+
'persist_answer': 'true',
18+
'generation_model': 'gpt-4o',
19+
'messages': [
20+
{'role': 'system', 'content': behavior},
21+
{'role': 'context'},
22+
{'role': 'user', 'content': instructions},
23+
{'role': 'query', 'content': query},
24+
],
25+
}
26+
)
1527

1628
headers = {'content-type': 'application/json', 'X-API-KEY': os.environ['BOT_API_KEY']}
1729
r = requests.post(os.environ['BOT_API_ENDPOINT'], data=payload, headers=headers)
@@ -30,12 +42,17 @@ def get_suggestion(issue_body: str) -> str:
3042

3143
def main():
3244
parser = argparse.ArgumentParser()
33-
parser.add_argument('input_file', type=str, default=None)
45+
parser.add_argument('query_file', type=str, default=None)
46+
parser.add_argument('--instructions', type=str, required=True)
47+
parser.add_argument('--behavior', type=str, required=True)
3448
args = parser.parse_args()
3549

36-
if args.input_file:
37-
with open(args.input_file, 'r', encoding='utf-8') as f:
38-
print(get_suggestion(f.read()))
50+
with (
51+
open(args.query_file, 'r', encoding='utf-8') as q,
52+
open(args.instructions, 'r', encoding='utf-8') as inst,
53+
open(args.behavior, 'r', encoding='utf-8') as behav,
54+
):
55+
print(get_suggestion(q.read(), inst.read(), behav.read()))
3956

4057

4158
if __name__ == '__main__':

0 commit comments

Comments
 (0)