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

Silicon Sages - AI-Resistant Assignments Expedition #108

Open
wants to merge 12 commits into
base: STAGING
Choose a base branch
from

Conversation

AaronSosaRamos
Copy link
Collaborator

@AaronSosaRamos AaronSosaRamos commented Oct 9, 2024

Silicon Sages - AI-Resistant Assignments Expedition - PR

Summary

This PR introduces several enhancements and new features to the AI-Resistant Assignments Expedition. The document loaders included in this PR support the following file types:

  • PDF
  • CSV
  • TXT
  • MD
  • URL (e.g., Wikipedia or other info sources)
  • PPTX
  • DOCX
  • XLS / XLSX
  • XML
  • GOOGLE DOCS
  • GOOGLE SHEETS
  • GOOGLE SLIDES
  • GOOGLE PDF
  • IMAGES (PNG / JPG / JPEG)

Changes

  • Reused the document loaders from Epic 7.2 Epic 7.2 - Synthwave Sentinels - Extended File Support for Flashcard Generator (Dynamo) #61.
  • Reused the utility file allowed_file_extensions.py to manage file types robustly.
  • Created a new tool.py to integrate the designed workflow for generating AI-resistant assignments.
  • Created a new core.py to integrate the AI-resistant assignments generator workflow from tool.py appropriately.
  • Decoupled the input arguments as a best practice to allow for flexible maintainability.
  • Created new error classes to improve the error mapping process.
  • Enabled a multimodal approach for generating responses from images, representing an innovative proposal for the project.

Testing

Each document loader was tested using pytest, with scenarios and edge cases properly managed.
image

Results

All document loaders are functioning as expected, yielding optimal results.
image

Notes

For Google Docs, Slides, Sheets, and PDF files:

  • These files need to be shared as public in Google Drive.
  • Files created in Google Drive need to be downloaded and then uploaded to be detected. This was determined to be the most appropriate approach, as the GoogleDriver loader from LangChain requires OAuth2, which is not suitable for production deployment.

How to Test

  1. Clone the repository to your local environment.

  2. Create and activate a virtual environment.

  3. Run pip install -r requirements.txt to install the required libraries.

  4. Create a .env file with the following fields:

    • ENV_TYPE (e.g., dev)
    • GCP_PROJECT_ID (your project ID from Cloud Console)
    • GOOGLE_API_KEY (your API key from AI Studio)
  5. Start the application by running ./local-start.sh.

  6. Add sample requests and responses for each file type mentioned above (with screenshots), and test them.

Request interface

Schema:

class AIResistantArgs(BaseModel):
    topic: str = Field(..., min_length=1, max_length=255, description="Topic or subject related to the content")
    assignment: str = Field(..., min_length=1, max_length=255, description="The given assignment")
    grade_level: Literal["elementary", "middle", "high", "college", "professional"] = Field(..., description="Educational level to which the content is directed")
    file_type: str = Field(..., description="Type of file being handled, according to the defined enumeration")
    file_url: str = Field(..., description="URL or path of the file to be processed")
    lang: str = Field(..., description="Language in which the file or content is written")

Example:

{
  "user": {
    "id": "string",
    "fullName": "string",
    "email": "string"
  },
  "type": "chat",
  "tool_data": {
    "tool_id": 5,
    "inputs": [
      {
        "name": "ai_resistant_args",
        "value": {
          "topic": "Introduction to Data Science",
          "assignment": "Develop a Neural Network Architecture for emulating Data Science Workflow",
          "grade_level": "college",
          "file_type": "pdf",
          "file_url": "http://ijsmsjournal.org/2021/volume-4%20issue-4/ijsms-v4i4p137.pdf",
          "lang": "en"
        }
      }
    ]
  }
} 

Response interface

Schema:

class AIResistanceIdea(BaseModel):
    assignment_description: str = Field(..., description="Detailed description of the modified assignment")
    explanation: str = Field(..., description="Explanation of how this modification makes the assignment AI-resistant")

class AIResistantOutput(BaseModel):
    topic: str = Field(..., description="Topic or subject related to the assignment")
    grade_level: str = Field(..., description="Educational level to which the assignment is directed")
    ideas: List[AIResistanceIdea] = Field(..., description="List of 3 ideas to make the assignment AI-resistant, including explanation")

@AaronSosaRamos AaronSosaRamos added type:enhancement For minor updates or changes that improve an existing feature or process. EXPEDITION This is an expedition that is currently being worked on in the Notion page: https://radicalxco.notio AI-Resistant For the AI-Resistant Assignments expedition labels Nov 17, 2024
@AaronSosaRamos AaronSosaRamos self-assigned this Nov 17, 2024
Copy link
Contributor

@yunusj yunusj left a comment

Choose a reason for hiding this comment

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

Check comment

import uuid
import requests
import gdown

Copy link
Contributor

Choose a reason for hiding this comment

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

since we have been using document loader in multiple tools, shouldn't we move it to global util? @WilfredoAaronSosaRamosBoushtech

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yunusj I've refactored the AI-Resistant Assignments Generator moving the document loaders to a global utils folder for better reusability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI-Resistant For the AI-Resistant Assignments expedition EXPEDITION This is an expedition that is currently being worked on in the Notion page: https://radicalxco.notio type:enhancement For minor updates or changes that improve an existing feature or process.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] - Develop AI-Resistant Assignment Generator
3 participants