Skip to content

Commit 324a365

Browse files
authored
Merge pull request #29 from gitbito/add_logs
Add logs for usage
2 parents c486636 + a637b91 commit 324a365

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

documentation/create_code_doc/createdoc.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/bin/bash
22
set +x
33

4+
# Setting some required variables
5+
BITO_CMD=`which bito`
6+
BITO_CMD_VEP=""
7+
BITO_VERSION=`$BITO_CMD -v | awk '{print $NF}'`
8+
# Compare BITO_VERSION to check if its greater than 3.7
9+
if awk "BEGIN {exit !($BITO_VERSION > 3.7)}"; then
10+
BITO_CMD_VEP="--agent create_code_doc"
11+
fi
12+
13+
414
# Check if folder name is provided as command line argument
515
if [ $# -eq 0 ]; then
616
echo "Please provide folder name as command line argument"
@@ -43,7 +53,7 @@ find "$folder" -type f -name "*.sh" -o -name "*.py" -o -name "*.php" -o -name "*
4353
# The below command does not work and gives following error
4454
# Only "-p" flag is applicable for this command. Remove any additional flags and then try again.
4555
# bito -p docprmt.txt -f "$file" >> "$file2write"
46-
cat $file | bito -p ./prompts/structured_doc.txt > $file2write
56+
cat $file | bito -p ./prompts/structured_doc.txt $BITO_CMD_VEP > $file2write
4757
done
4858

4959
echo "Documentation created in $doc_folder"

documentation/create_overview_doc/createdoc.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/bin/bash
22
#set -x
33

4+
# Setting some required variables
5+
BITO_CMD=`which bito`
6+
BITO_CMD_VEP=""
7+
BITO_VERSION=`$BITO_CMD -v | awk '{print $NF}'`
8+
# Compare BITO_VERSION to check if its greater than 3.7
9+
if awk "BEGIN {exit !($BITO_VERSION > 3.7)}"; then
10+
BITO_CMD_VEP="--agent create_overview_doc"
11+
fi
12+
13+
414
# Log file for storing the token usage information
515
log_file="bito_usage_log.txt"
616

@@ -151,7 +161,7 @@ function call_bito_with_retry() {
151161
echo "Calling bito with retry logic. Attempt $attempt of $MAX_RETRIES with prompt file '$filename'..." >&2
152162

153163
# Call bito and capture the standard output only.
154-
output=$(echo -e "$input_text" | bito -p "$prompt_file_path")
164+
output=$(echo -e "$input_text" | bito $BITO_CMD_VEP -p "$prompt_file_path")
155165
local ret_code=$? # Capture the return code from bito.
156166

157167
# Check if the response from bito is valid using the bito_response_ok function.
@@ -266,7 +276,7 @@ function extract_module_names_and_associated_objectives_then_call_bito() {
266276
# Retry logic for calling bito
267277
while [ $attempt -le $MAX_RETRIES ]; do
268278
echo "Attempt $attempt: Running bito for module: $current_module" >&2
269-
bito_output=$(echo -e "$combined_output" | bito -p "$prompt_file_path")
279+
bito_output=$(echo -e "$combined_output" | bito $BITO_CMD_VEP -p "$prompt_file_path")
270280
local ret_code=$?
271281

272282
if ! bito_response_ok "$ret_code" "$bito_output"; then
@@ -304,7 +314,7 @@ function fix_mermaid_syntax() {
304314
# Function to fix Mermaid diagram syntax using bito AI
305315
function fix_mermaid_syntax_with_bito() {
306316
local fixed_mermaid_content
307-
fixed_mermaid_content=$(echo "$mermaid_content" | bito -p "$prompt_folder/mermaid_doc_prompt.txt" | awk '/^```mermaid$/,/^```$/{if (!/^```mermaid$/ && !/^```$/) print}')
317+
fixed_mermaid_content=$(echo "$mermaid_content" | bito $BITO_CMD_VEP -p "$prompt_folder/mermaid_doc_prompt.txt" | awk '/^```mermaid$/,/^```$/{if (!/^```mermaid$/ && !/^```$/) print}')
308318

309319
local ret_code=$?
310320
if ! bito_response_ok "$ret_code" "$fixed_mermaid_content"; then
@@ -396,7 +406,7 @@ function create_mermaid_diagram() {
396406

397407
while [ $attempt -le $MAX_RETRIES ]; do
398408
echo "Attempt $attempt: Creating Mermaid diagram for module: $module_name" >&2
399-
bito_output=$(echo -e "Module: $module_name\n---\n$mermaid_definition" | bito -p "$prompt_folder/mermaid_doc_prompt.txt")
409+
bito_output=$(echo -e "Module: $module_name\n---\n$mermaid_definition" | bito $BITO_CMD_VEP -p "$prompt_folder/mermaid_doc_prompt.txt")
400410
local ret_code=$?
401411

402412
if ! bito_response_ok "$ret_code" "$bito_output"; then
@@ -460,7 +470,7 @@ function generate_mdd_overview() {
460470
echo "Attempt $attempt: Processing Mermaid script for $mdd_file" >&2
461471
# Use bito to process the Mermaid script
462472
temp_file=$(mktemp)
463-
echo -e "$mermaid_script" | bito -p "$mermaid_doc_prompt_file" > "$temp_file"
473+
echo -e "$mermaid_script" | bito $BITO_CMD_VEP -p "$mermaid_doc_prompt_file" > "$temp_file"
464474

465475
# Validate the Mermaid script
466476
if validate_mermaid_syntax "$(cat "$temp_file")"; then

unittests/gentestcase/generate_testcases.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ then
88
exit 1
99
fi
1010

11+
# Setting some required variables
12+
BITO_CMD=`which bito`
13+
BITO_CMD_VEP=""
14+
BITO_VERSION=`$BITO_CMD -v | awk '{print $NF}'`
15+
# Compare BITO_VERSION to check if its greater than 3.7
16+
if awk "BEGIN {exit !($BITO_VERSION > 3.7)}"; then
17+
BITO_CMD_VEP="--agent gentestcase"
18+
fi
19+
20+
1121
# Ensure at least one argument is provided
1222
if [ "$#" -lt 1 ]; then
1323
echo "Usage: $0 <code_file> [<context_file>...]"
@@ -54,7 +64,7 @@ echo "$prompt" > "$temp_prompt"
5464

5565
echo "Generating unit tests..."
5666
# Run the bito command with the first prompt
57-
if ! bito -p "$temp_prompt" -f $inputfile_for_ut_gen -c "context.txt" > /dev/null; then
67+
if ! bito $BITO_CMD_VEP -p "$temp_prompt" -f $inputfile_for_ut_gen -c "context.txt" > /dev/null; then
5868
echo "Error: The bito command failed."
5969
rm "$temp_prompt"
6070
exit 1
@@ -63,7 +73,7 @@ fi
6373
echo "$prompt2" > "$temp_prompt"
6474

6575
# Run the bito command with the second prompt and store the output
66-
if ! bito -p "$temp_prompt" -f $inputfile_for_ut_gen -c "context.txt" > "${filename}.$"; then
76+
if ! bito $BITO_CMD_VEP -p "$temp_prompt" -f $inputfile_for_ut_gen -c "context.txt" > "${filename}.$"; then
6777
echo "Error: The bito command failed."
6878
rm "$temp_prompt"
6979
exit 1

0 commit comments

Comments
 (0)