Skip to content

Conversation

@jsle97
Copy link

@jsle97 jsle97 commented Aug 27, 2025

A simple implementation for fun even in someone elses cloud.

A simple implementation for fun even in someone elses cloud.
Copilot AI review requested due to automatic review settings August 27, 2025 06:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a simple LLM interaction tool that provides a command-line interface for querying Mistral AI models. The implementation creates a bash function that maintains conversation history and provides a terminal-based chat experience.

Key Changes

  • Adds a new .askllm file containing environment variable exports and a bash function for LLM interaction
  • Implements conversation history management with automatic truncation to keep the last 6 exchanges
  • Provides interactive terminal interface with colored output and word wrapping

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -0,0 +1,81 @@
# command: askllm

export ASKLLM_MISTRAL_API_KEY="mistral-api-key"
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API key is hardcoded as a placeholder value. This should be documented as needing user configuration, or the export should be removed entirely to require users to set their own key securely.

Suggested change
export ASKLLM_MISTRAL_API_KEY="mistral-api-key"
# NOTE: You must set ASKLLM_MISTRAL_API_KEY in your environment before using askllm.

Copilot uses AI. Check for mistakes.
fi

echo -e "\033[36mEnter query (empty to exit, 'clear' to reset history):\033[0m"
USER_INPUT=$(cat)
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using cat without any input source will hang indefinitely waiting for stdin. This should be read -r USER_INPUT or read -p 'prompt: ' USER_INPUT to properly capture user input.

Suggested change
USER_INPUT=$(cat)
read -r USER_INPUT

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +42
if ((${#ROLES[@]} > 7)); then
ROLES=("system" "${ROLES[@]: -6}")
CONTENTS=("${CONTENTS[0]}" "${CONTENTS[@]: -6}")
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The history truncation logic is incorrect. When truncating to keep the last 6 exchanges plus the system prompt, the CONTENTS array should preserve the system prompt at index 0, but line 42 assumes CONTENTS[0] is always the system content which may not be true after multiple truncations.

Suggested change
if ((${#ROLES[@]} > 7)); then
ROLES=("system" "${ROLES[@]: -6}")
CONTENTS=("${CONTENTS[0]}" "${CONTENTS[@]: -6}")
CONTENTS=("$ASKLLM_SYSTEM_PROMPT" "${CONTENTS[@]: -6}")

Copilot uses AI. Check for mistakes.
max_tokens: 512,
stream: false
}')")

Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling doesn't distinguish between API errors and missing response content. Consider checking for API error responses first (e.g., .error.message) before attempting to extract the content.

Suggested change
ERROR_MSG=$(echo "$RESPONSE" | jq -r '.error.message // empty')
if [[ -n "$ERROR_MSG" ]]; then
echo -e "\033[31mAPI Error: $ERROR_MSG\033[0m"
echo -e "\033[33mAPI response:\n$RESPONSE\033[0m"
return 1
fi

Copilot uses AI. Check for mistakes.
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.

1 participant