This repository provides a convenient way to interact with Claude3, an advanced AI assistant developed by Anthropoc Inc., directly through the command line interface (CLI). It consists of a Python script (claude.py) that utilizes the Anthropoc SDK and a shell script (claude_script.sh) to handle environment setup and script execution.
Before using this repository, ensure you have the following:
- An API key from Anthropoc. You can obtain it from Anthropic.
- Python and pip installed on your system.
- macOS environment with Zsh shell, if you're using bash just replace anywhere it says .zshrc with .bashrc and it should work the same for you.
-
Set API Key: Add your Anthropoc API key to your shell environment. Open your terminal and execute the following command, replacing
{Your-API-Key}with your actual API key:echo "ANTHROPIC_API_KEY={Your-API-Key}" >> ~/.zshrc
-
Download the Repository: Clone or download this repository to your local machine.
-
Set Alias: Add an alias to easily run the script in the terminal. Execute the following command in your terminal, replacing
/PATH/TO/anthropicwith the path where you've saved the scripts:echo "alias ask='/PATH/TO/anthropic/claude_script.sh'" >> ~/.zshrc
-
Make Script Executable: Make the shell script executable using the following command:
chmod +x /PATH/TO/anthropic/claude_script.sh
-
Restart Shell: Restart your shell or reload the shell configuration file for changes to take effect. You can do this by closing and reopening your terminal or running:
source ~/.zshrc
To interact with Claude3, follow these steps:
-
Open your terminal.
-
Run the script using the defined alias (
ask) followed by your query and temperature value. The temperature value indicates how creative the AI's response will be, ranging from 0.1 to 1, where 1 represents maximum creativity.ask "Your query here" 0.5 -
Claude3 will process your query and provide a response, streamed directly to your terminal.
- The
claude.pyscript accepts two arguments: the query string and the temperature value. - The script checks for Python and pip installation, creates a virtual environment if one doesn't exist, installs the required dependencies, and runs the query.
- After each query, the virtual environment is deactivated.
- Ensure that your API key is correctly set in your shell environment for the script to function properly.
- You can modify the code as needed and contribute to the repository.
- For any issues or suggestions, feel free to open an issue on GitHub.
- Uncomment the role and content object in the python script and edit it to add a pretext to Claude's answer to jumpstart the generation (i.e if you like step-by-step instructions you can pretext with "Certainly! Here is a list that will help you:", then Claude will output the message in that context
- The system context allows you to give the whole system context (i.e "You are a powerful AI assistant helping me cure cancer" and can give you more control over the AI responses
Now you can start interacting with Claude3 directly from your terminal!
