This project provides a command-line interface for interacting with IBM's Watson AI using the watsonX.ai API. It allows users to engage in conversations with the AI model, supporting both English and Arabic languages.
Created by Sultan Wehaibi
- Python 3.6 or higher
- An IBM Cloud account with access to watsonX.ai
- API key and Project ID from IBM Cloud
-
Clone this repository or download the
ibm_watsonx_ai_wrapper.pyfile. -
Install the required Python packages using the provided
requirements.txtfile:pip install -r requirements.txtThis will install the following packages:
- requests
- python-dotenv
-
Create a
.envfile in the same directory as the script with the following content:IBM_WATSONX_API_KEY=your_api_key_here IBM_WATSONX_PROJECT_ID=your_project_id_here IBM_WATSONX_URL=https://eu-de.ml.cloud.ibm.comReplace
your_api_key_hereandyour_project_id_herewith your actual IBM Watson API key and Project ID.Note: The
.envfile is a hidden file. If you can't see it in your file explorer, you may need to enable "Show hidden files" in your operating system settings. -
Editing the
.envfile:- On Windows:
- Open File Explorer and navigate to the script's directory.
- Click on 'View' in the top menu and check 'Hidden items'.
- Right-click on the .env file and select 'Edit'.
- On macOS or Linux:
- Open a terminal and navigate to the script's directory.
- Run the following command to edit the file:
nano .env
Update the values with your actual API key and Project ID.
- On Windows:
Run the script from the command line:
python ibm_watsonx_ai_wrapper.py
The script will check if you've updated the .env file with your actual API key and Project ID. If you haven't, it will provide instructions on how to do so.
You can also specify additional parameters:
python ibm_watsonx_ai_wrapper.py --max_new_tokens 900 --temperature 0.7 --top_p 1 --repetition_penalty 1.0 --timeout 60
--max_new_tokens: Maximum number of new tokens to generate (default: 900)--decoding_method: Decoding method, either "greedy" or "sample" (default: "greedy")--temperature: Temperature for sampling (default: 0.7)--top_p: Top-p sampling value (default: 1)--repetition_penalty: Repetition penalty (default: 1.0)--timeout: Timeout for API calls in seconds (default: 60)
Once the script is running, you can start chatting with the AI. Type your messages and press Enter to send them. The AI will respond to each of your inputs.
To exit the program, type '/q' and press Enter.
This wrapper fully supports Arabic input and output. You can type questions or prompts in Arabic, and the AI will respond in Arabic as well.
If you encounter any issues:
- Ensure your API key and Project ID are correct in the
.envfile. - Check your internet connection.
- Verify that you have the necessary permissions in your IBM Cloud account.
- If you're having trouble with Arabic text display, make sure your terminal supports UTF-8 encoding.
- If you encounter package-related issues, ensure you've installed all required packages using the
requirements.txtfile.
This wrapper is an unofficial tool and is not affiliated with, officially maintained, or endorsed by IBM. Use it responsibly and in accordance with IBM's terms of service.
This IBM Watson AI Wrapper was created by Sultan Wehaibi for the ALLaM Challange 2024.
For any questions or issues, please open an issue in this repository.