Skip to content

Updates for v0.2.3 #40

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/help_and_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
readonly YO="✌️"

# All versioning follows semver as defined at https://semver.org/
readonly VERSION="0.2.1"
readonly VERSION="0.2.2"

# Display version information
show_version() {
Expand Down Expand Up @@ -37,6 +37,7 @@ show_help() {
including .pdf, .docx, images (.png, .jpeg, .tiff, etc.), and any text file (.txt, .md,
.py, .zsh, etc.). This flag can be repeated to bring in several files.
-y, --system Run a few system commands and integrate the information into Yo's context.
-t, --text "TEXT" Include the specified text in Yo's context.

Finally, we have several flags that require an internet connection:
-s, --search "TERMS" Perform a web search using the specified quoted terms and integrate the results into
Expand Down
15 changes: 15 additions & 0 deletions src/llm_session_management.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ generate_prompt() {
add_system_info=$8
add_directory_info=$9
add_clipboard_info=${10}
add_screenshot_info=${11}
text_input_list=${12}

# Check that inputs are valid
check_mode mode || return 1
Expand Down Expand Up @@ -71,6 +73,19 @@ generate_prompt() {
done
fi

# Add website information if available
if [ -n "${text_input_list}" ]; then
while [ -n "${text_input_list}" ]; do
text_input=$(echo "${text_input_list}" | head -n 1)
text_input_list=$(echo "${text_input_list}" | tail -n +2)
timestamp_log_to_stderr "🔗" "Reviewing \"$(echo "${text_input}" | cut -c1-30)\"..." >&2
prompt="${prompt} $(generate_text_context "${text_input}" "${query}")\n\n" || {
echo "Error: Failed to generate website information context for ${text_input}." >&2
return 1
}
done
fi

# Add website information if available
if [ -n "${website_urls}" ]; then
while [ -n "${website_urls}" ]; do
Expand Down
19 changes: 18 additions & 1 deletion src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ query=""
file_path_list=""
website_url_list=""
search_term_list=""
text_input_list=""
surf_and_add_results=false
add_directory_info=false add_system_info=false add_clipboard_info=false add_usage_info=false
task_model_override=false casual_model_override=false balanced_model_override=false serious_model_override=false
add_screenshot_info=false

# Make verbose a global variable
VERBOSE=false
Expand Down Expand Up @@ -156,6 +158,16 @@ while [ $# -gt 0 ]; do
exit 1
fi
;;
# Read in a text
-t | --text)
if [ -n "$2" ] && [ "${2#-}" = "$2" ]; then
text_input_list="${text_input_list}$2\n"
shift
else
echo "Error: --file requires a file." >&2
exit 1
fi
;;

# Read in a file
-w | --website)
Expand Down Expand Up @@ -206,6 +218,9 @@ while [ $# -gt 0 ]; do
surf_and_add_results=true
;;

# Add screenshot info
-sc | --screenshot) add_screenshot_info=true ;;

# Add system information to the context
-y | --system) add_system_info=true ;;

Expand Down Expand Up @@ -299,7 +314,9 @@ prompt=$(
"${add_usage_info}" \
"${add_system_info}" \
"${add_directory_info}" \
"${add_clipboard_info}"
"${add_clipboard_info}" \
"${add_screenshot_info}" \
"${text_input_list}"
) || {
echo "Error: Failed to generate prompt." >&2
exit 1
Expand Down
21 changes: 21 additions & 0 deletions src/prompt_generators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ generate_clipboard_info_context() {
EOF
}

# Generate text information
generate_text_context() {

# Parse arguments
text_info=$1
query=$2

# Compress if needed
text_info=$(compress_text "${clipboard_info}" true true true "${query}") || {
echo "Error: Failed to compress text_info information." >&2
return 1
}

cat <<-EOF
Here are the contents of a text input:
================= BEGINNING OF CURRENT CLIPBOARD CONTENTS =================
${text_info}
==================== END OF CURRENT CLIPBOARD CONTENTS ====================
EOF
}

# Generate file contents context
generate_file_context() {

Expand Down
12 changes: 11 additions & 1 deletion tests/test_local_flags.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
# shellcheck enable=all

source tests/utilities.zsh
. tests/utilities.sh

# Run setup
setup
Expand Down Expand Up @@ -37,5 +37,15 @@ answer_should_contain \
"--task-model --system" \
"how many cores do i have"

# Text the --text flag
answer_should_contain \
"3|three" \
"--task-model --text 'the ball is under cup number 3'" \
"what cup is the ball under"
answer_should_contain \
"3|three" \
"--task-model --text 'the ball is under cup number 3' --text 'the ball is really really under cup number 3'" \
"what cup is the ball under"

# Run cleanup
cleanup
Loading