Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/text rewriter #164

Open
wants to merge 6 commits into
base: Develop
Choose a base branch
from

Conversation

Sarang-Nambiar
Copy link

@Sarang-Nambiar Sarang-Nambiar commented Jan 18, 2025

Description

This PR introduces the Text-Rewriter Tool, a feature that enables users to rewrite text with specific instructions or by uploading files. Below are the main functionalities implemented in this PR:

Key Features

  • Accept input text directly or via file uploads in the following formats:
    • Supported Formats: CSV, PDF, DOCX, PPT, Plain Text.
    • URLs: YouTube videos, websites, Google Sheets.
  • Process the uploaded content based on the provided rewriting instructions (e.g., simplify, summarize, rephrase).
  • Generate rewritten text tailored to user instructions.
  • Export rewritten text in formats such as Plain Text, DOCX, or PDF.

Related Issue

This PR addresses the following issue:
#128


Type of Change

Please select the type(s) of change that apply:

  • New feature: A non-breaking change that adds functionality.

Proposed Solution

The implementation follows a modular structure and integrates seamlessly with the existing codebase. Key details include:

  • Structure:

    • The tool is implemented within app/features/text-rewriter.
    • Core functionalities such as data validation and document retrieval are defined in core.py.
    • The main business logic resides in tools.py.
  • Rewriting Logic:

    • Input text and rewriting instructions are sent to the LLM for processing.
    • The LLM response is parsed using JsonOutputParser from LangChain.
    • The processed output is returned as a response to the user.

How to Test

Testing Instructions

  1. Start the FastAPI server from the root directory:

    ./local-start.sh
  2. Use Postman or a similar tool to send a POST request to:
    http://localhost:8000/submit-tool

    Headers:

    • api-key: dev

    JSON Body:

    {
      "user": {
        "id": "string",
        "fullName": "string",
        "email": "string"
      },
      "type": "tool",
      "tool_data": {
        "tool_id": "text-rewriter",
        "inputs": [
          {
            "name": "instructions",
            "value": "Rephrase it in a formal tone"
          },
          {
            "name": "raw_text",
            "value": "The quick brown fox jumped over the fence."
          },
          {
            "name": "file_url",
            "value": ""
          },
          {
            "name": "file_type",
            "value": ""
          }
        ]
      }
    }
  3. Expected Output:

    {
      "data": {
        "rewritten_text": "The agile brown fox successfully cleared the fence."
      }
    }

Unit Tests

Tests Added:

  • Valid Inputs: Ensures successful processing for all supported file types.
  • Invalid Inputs: Validates error handling for incorrect formats or missing data.

Documentation Updates

Does this PR require documentation updates?

  • Yes
  • No

If yes, provide the necessary details and link the relevant documentation.


Checklist

  • Performed a self-review of the code.
  • Added comments to clarify complex areas.
  • Updated documentation where necessary.
  • Verified all unit tests pass locally.
  • Added unit tests to verify functionality.
  • No new warnings are introduced with these changes.
  • Ensured dependent changes are merged and published downstream.

Additional Information

Feel free to reach out for further clarification or if additional changes are required.


Choose a reason for hiding this comment

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

please include Langchain

Copy link
Author

Choose a reason for hiding this comment

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

I have made the requested changes

@stevenrayhinojosa-gmail-com

Awesome, I will run this on my machine and I will get back to you, great job !

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.

2 participants