aisuite icon indicating copy to clipboard operation
aisuite copied to clipboard

Add Sentiment Analysis Example Using Anthropics' Claude Model

Open M-Ehtesham-Ul-Hassan-Malik opened this issue 1 year ago • 0 comments

Pull Request: Add Sentiment Analysis Example Using Anthropics' Claude Model

Overview

This pull request introduces a new example notebook (SentimentAnalysis.ipynb) to the examples folder. The notebook demonstrates how to perform sentiment analysis using the aisuite library with Anthropics' Claude-3-5-sonnet model.

Key Features

  • Integration with Anthropics' Claude Model: Uses the aisuite library to interact with Claude-3-5-sonnet.
  • Sentiment Analysis Workflow: Includes prompts and configurations to analyze text sentiment (positive/negative).
  • Environment Setup: Demonstrates API key setup using environment variables for secure integration.
  • Reusable Example: Provides a clear and reusable structure for developers to perform sentiment analysis with LLMs.

File Details

SentimentAnalysis.ipynb

  1. Dependencies
    • Install the necessary library using:
      pip install anthropic
      
  2. API Key Setup
    • Securely configure API keys using:
      import os
      os.environ["ANTHROPIC_API_KEY"] = "<your-anthropic-api-key>"
      
  3. Sentiment Analysis Code
    • Prompt the model to analyze text sentiment (positive/negative).
    • Example response:
      Pakistan: The Sentiment is positive
      

Testing

  • Verified functionality with real API keys and the Anthropics library.
  • Output is consistent with the prompts and expectations.

Why This Contribution?

This example provides a practical use case for developers leveraging aisuite for natural language processing tasks. It aligns with the repository's goal of offering unified access to multiple LLM providers.

Checklist

  • [x] Added the SentimentAnalysis.ipynb example.
  • [x] Included detailed comments and documentation in the notebook.
  • [x] Verified the code's functionality and output.

Feedback and Suggestions

Maintainers are welcome to provide feedback or suggest improvements for this contribution.