Skip to content

sparsh0106/SparshGPT--old-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SparshGPT: Custom GPT-Powered GUI Application


Introduction

SparshGPT is a custom GUI application built using CustomTkinter and powered by OpenAI's proxy API. The application provides two primary features:

  1. TextGPT: Generates text responses to user prompts, similar to ChatGPT.
  2. ImageGPT: Provides insights into images based on user-provided URLs and captions.

This project demonstrates the integration of GPT-based models into a user-friendly GUI environment, catering to tasks involving text generation and image caption analysis.


Features

1. TextGPT

  • Allows users to input text prompts.
  • Utilizes OpenAI’s API to generate responses based on the input.
  • Displays the generated response in the GUI.

2. ImageGPT

  • Accepts an image URL and a caption from the user.
  • Sends the data to the API to generate insights based on the image and the caption.
  • Outputs the insights directly in the GUI.

3. User Interface

  • Built with CustomTkinter for a modern and responsive UI.
  • Dark mode and green-themed appearance for an enhanced user experience.

How It Works

Technology Stack

  • Python: Core programming language.
  • CustomTkinter: Framework for building modern GUIs.
  • Requests: Used for HTTP communication with the OpenAI API.
  • JSON: Handles API payload and response parsing.

Project Structure

SparshGPT/
│
├── t.py           # Main Python script containing all functionality
├── README.md         # Documentation
└── requirements.txt  # Python dependencies

Code Walkthrough

1. Main GUI (SparshGPT)

  • Description: The primary window that offers buttons to switch between TextGPT and ImageGPT.
  • Key Features:
    • Welcome message.
    • Buttons for accessing the two main functionalities.

2. TextGPT

  • Function: TEXT()
  • Workflow:
    1. Opens a new window (root_text).
    2. Accepts user input via a text entry box.
    3. Sends the input as a prompt to the GPT model using OpenAI's proxy API.
    4. Displays the model's response in the same window.

3. ImageGPT

  • Function: IMAGE()
  • Workflow:
    1. Opens a new window (root_image).
    2. Accepts an image URL and a caption from the user.
    3. Sends the inputs to the GPT model using the API.
    4. Displays insights generated by the model.

4. API Integration

  • Endpoint: https://aiproxy.sanand.workers.dev/openai/v1/chat/completions
  • Authentication: Uses a Bearer token provided in the api_key variable.
  • Data Payload:
    • TextGPT: Sends user input in the messages field.
    • ImageGPT: Sends a combination of text and image URL in the messages field.

Dependencies

  • Python Libraries:
    • customtkinter
    • requests
    • json
  • These are listed in requirements.txt for easy installation.

Usage Example

TextGPT

  1. Launch the application.
  2. Click on the "Text" button.
  3. Enter your prompt and click "Generate."
  4. View the generated response in the same window.

ImageGPT

  1. Launch the application.
  2. Click on the "Image" button.
  3. Enter an image URL and a relevant caption.
  4. Click "Generate" to get insights about the image.

Key Points

  1. CustomTkinter:
    • Provides a modern and responsive GUI for the application.
  2. OpenAI Proxy API:
    • Serves as the backbone for GPT-based functionality.
  3. Error Handling:
    • Basic error handling is integrated for API communication failures.

Future Enhancements

  1. Add error messages for invalid inputs or API failures.
  2. Include file upload support for images instead of URLs.
  3. Optimize UI for smaller screen resolutions.
  4. Enhance functionality with more GPT model features.

License

This project is licensed under the MIT License.


Feel free to reach out if you have any questions or suggestions. Happy coding! 🚀