ant.py is a Python script designed to facilitate conversational interactions using the Anthropic API. It allows users to simulate conversations, save and load conversation histories, and handle multiple turns of dialogue. The script leverages the rich library for enhanced console output.
- API Key Handling: Ensures the Anthropic API key is set in the environment variables before running.
- Conversation History:
- Option to load a conversation history from a file.
- Saves the conversation history to a file upon exiting.
- Simulated Conversation:
- Handles multiple turns of dialogue between the user and the assistant.
- Uses the Anthropic API to generate responses.
- Displays the assistant's response using the
richlibrary.
- Error Handling:
- Provides informative messages if the API key is missing or if there are errors communicating with the API.
- Handles file not found errors when loading conversation history.
-
Set Up Environment Variables:
- Ensure the Anthropic API key is set in your environment variables:
export ANTHROPIC_API_KEY=your_api_key_here
- Ensure the Anthropic API key is set in your environment variables:
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Run the Script:
python ant.py
-
Interact with the Script:
- Optionally load a conversation history file when prompted.
- Enter your messages when prompted by
User:. - Type
:qto exit and save the conversation history.
$ python ant.py
Do you want to load a conversation history file? (y/n): y
Enter the file path of the conversation history: previous_conversation.txt
User: Hi there!
Assistant: Hello! How can I help you today?
User: What is the weather like?
Assistant: I'm not sure, but you can check your local weather forecast.
User: :q
Conversation saved to conversation_history.txt.
Exiting the application.- Enhanced Error Handling: Improve error messages and provide options for recovery.
- Customizable Configurations: Allow users to configure the model parameters and other settings.
- GUI Interface: Develop a graphical user interface for a more user-friendly experience.
- Integration with Other APIs: Expand the script to integrate with additional APIs for more features.
- Conversation Analysis: Implement features for analyzing and summarizing conversation histories.
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.
This project is licensed under the MIT License. README.md ned to facilitate conversational interactions using the Anthropic API. It allows users to simulate conversations, save and load conversation histories, and handle multiple turns of dialogue. The script leverages the rich library for enhanced console output.