Java Mini-Report
Java Mini-Report
UNIVERSITY, BELAGAVI-590018
BHOOMIKA 4AL20AI009
GOUTHAM J S 4AL20AI015
VISHMA 4AL20AI049
Mr. SHRIKANTH N G
Assistant Professor
CERTIFICATE
This is to certify that the Mini Project entitled “PARA-GPT ANDROID APP” has been
successfully completed by
BHOOMIKA 4AL20AI009
GOUTHAM J S 4AL20AI015
VISHMA 4AL20AI049
External Viva
1.
2.
ALVA’S INSTITUTE OF ENGINEERING AND
TECHNOLOGY MIJAR, MOODBIDRI D.K. -574225
KARNATAKA
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & MACHINE
LEARNING
Declaration
We,
BHOOMIKA
GOUTHAM J S
VISHMA
hereby declare that the dissertation entitled, “CHAT-GPT ANDROID APP” is completed
and written by us under the supervision of my guide Mr. SHRIKANTH N G, Assistant
Professor, Department of Artificial Intelligence and Machine Learning, Alva’s Institute
of Engineering And Technology, Moodbidri, DEPARTMENT OF ARTIFICIAL
INTELLIGENCE & MACHINE LEARNING of the VISVESVARAYA
TECHNOLOGICAL UNIVERSITY, BELAGAVI during the academic year 2022-2023.The
dissertation report is original and it has not been submitted for any other degree in any university.
BHOOMIKA 4AL20AI009
GOUTHAM J S 4AL20AI015
VISHMA 4AL20AI049
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany a successful completion of any task
would be incomplete without the mention of people who made it possible, success is the
epitome of hard work and perseverance, but steadfast of all is encouraging guidance.
So, with gratitude we acknowledge all those whose guidance and encouragement
served as beacon of light and crowned the effort with success.
The selection of this mini project work as well as the timely completion is mainly due
to the interest and persuasion of our mini project guide Mr. Shrikanth N G, Assistant
Professor, Department of Artificial Intelligence & Machine Learning. We will remember his
contribution forever.
We sincerely thank, Prof Harish Kunder Professor and Head, Department of Artificial
Intelligence & Machine Learning who has been the constant driving force behind the
completion of the project.
We thank our beloved Principal Dr. Peter Fernandes, for his constant help and
support throughout.
.
TABLE OF CONTENTS
CHAPTER NO DESCRIPTION
PAGE.NO
CERTIFICATE
ACKNOWLEDGEMENT
ii
ABSTRACT
iii
01 INTRODUCTION
5-2
03 SYSTEM DESIGN
4-5
3.1 LANGUAGE USED FOR IMPLEMENATION
4
3.2 PLATFORM USED FOR IMPLEMENTATION
6
3.3 CODE IMPLEMENTATION
7
05 RESULTS
25-37
06 CONCLUSION
38
ABSTRACT
The Para-GPT Android app is a novel and user-friendly application developed to streamline the
process of generating contextually relevant paragraphs based on user input words. Leveraging the
power of a language model API, such as GPT-3, the app offers users the ability to effortlessly
produce coherent and meaningful paragraphs in real-time.
The development process of Para-GPT involved seamless integration of the language model API
into the Android app, complemented by a well-designed user interface that facilitates smooth
word input and paragraph display. The app's algorithm efficiently processes user inputs and sends
requests to the language model API, ensuring that the generated paragraphs align accurately with
the intended context.
Throughout the implementation journey, the project faced several challenges, including API
limitations, contextual understanding, and maintaining the quality of the generated content. These
challenges prompted a meticulous approach to ensure the app's performance and coherence,
driven by valuable user feedback and iterative improvements.
The Para-GPT app caters to a diverse range of users, offering customizable options to adjust
paragraph length, tone, and style, making it a versatile tool for various writing contexts. By
addressing user preferences and ensuring a user-friendly experience, Para-GPT aims to empower
users seeking quick and precise paragraph generation.
PARA-GPT APPLICATION
CHAPTER 1:
INTRODUCTION
The objective of this project is to develop a ChatGPT Android application that utilizes the
power of the GPT-3.5 language model to provide an interactive and conversational experience
for users. The application will allow users to have natural language conversations with the AI
model, enabling them to ask questions, seek information, and engage in meaningful discussions
Conversational AI: The core feature of the application will be the ability to have human-like
conversations with the AI model. Users can input text-based queries, and the model will
generate responses in a conversational manner, aiming to provide helpful and relevant
information.
Contextual Understanding: The AI model will be designed to maintain context throughout the
conversation, allowing users to have more natural and coherent exchanges. It will remember
previous queries and responses to provide a seamless conversational experience.
Multi-turn Conversations: The application will support multi-turn conversations, enabling users
to have back-and-forth interactions with the AI model. Users can ask follow-up questions, seek
clarifications, or dive deeper into a specific topic, fostering engaging and dynamic
conversations.Personalization: The application will incorporate personalization features,
allowing users to customize their experience. This can include options to set preferred
conversation styles, choose from different personas, or adjust the level of verbosity in the AI
model's responses.
Rich User Interface: The Android application will have an intuitive and user-friendly interface.
It will provide a chat-like environment where users can input their queries and view the AI
model's responses. The interface will support features such as message threading, message
history, and user-friendly error handling.
Continuous Learning and Improvement: The project will incorporate mechanisms for
continuous learning and improvement of the AI model. Feedback from users can be collected to
identify areas for enhancement and fine-tuning, ensuring a better user experience over time.
1
PARA-GPT APPLICATION
Offline Support: While the core functionality relies on an internet connection to interact with
the GPT-3.5 model, the application can include offline capabilities to handle basic queries or
provide helpful suggestions when offline.
1.2 Background:
In today's digital age, written communication plays a crucial role in various aspects of our lives,
ranging from academic assignments to professional documents and online content creation.
Writing a well-structured and coherent paragraph requires creativity, language proficiency, and
a deep understanding of the subject matter. However, many individuals often struggle with
formulating paragraphs that effectively convey their thoughts and ideas.
With recent advancements in natural language processing and artificial intelligence, language
models like OpenAI's GPT-3 have demonstrated impressive capabilities in generating human-
like text. Leveraging these advancements, the Para-GPT Android app aims to provide a solution
to the paragraph composition challenge by utilizing the powerful ChatGPT API.
The Para-GPT app builds upon the foundations laid by OpenAI's GPT-3 model, which has been
trained on vast amounts of textual data to develop an understanding of language patterns,
grammar, and context. By integrating the ChatGPT API into the app, users can leverage the
expertise of the model to generate coherent and contextually relevant paragraphs based on the
individual words or phrases they input.
The development of the Para-GPT app stems from the need for a convenient and user-friendly
tool that simplifies the process of paragraph composition. Traditional methods of writing often
involve manual brainstorming, organization, and rephrasing, which can be time-consuming and
mentally demanding. By utilizing the advanced natural language processing capabilities of the
ChatGPT API, Para-GPT aims to streamline the paragraph generation process and provide users
with an efficient and reliable tool for their writing needs.
Furthermore, the Para-GPT app addresses the growing demand for personalized content
2
PARA-GPT APPLICATION
creation. Users can customize the generated paragraphs by adjusting the length, tone, or style,
allowing them to tailor the output to their specific requirements and preferences. This level of
customization empowers users to craft paragraphs that align with their unique writing style and
effectively convey their intended message.
To ensure the app's success, rigorous testing and user feedback will be essential. By thoroughly
testing the app's functionality, stability, and accuracy in paragraph generation, potential issues
can be identified and addressed promptly. User feedback will serve as a valuable resource for
understanding user needs, identifying areas for improvement, and refining the app's features to
enhance the overall user experience.
Overall, the Para-GPT app combines the power of the ChatGPT API with the convenience of an
Android interface to provide users with a seamless and efficient solution for paragraph
composition. By leveraging the strengths of AI language models, the app aims to empower
individuals in their writing endeavors, facilitating the creation of well-structured and impactful
paragraphs in a user-friendly manner.
3
PARA-GPT APPLICATION
To develop the "Para-GPT" Android app that utilizes the ChatGPT API to facilitate efficient and
contextually relevant paragraph generation based on user-provided words.
Objectives:
User-friendly Interface: Create an intuitive and user-friendly app interface that allows users to
input words and receive well-structured paragraphs as output, simplifying the process of paragraph
composition.
Integration of ChatGPT API: Integrate the ChatGPT API seamlessly into the app to leverage its
natural language processing capabilities for generating grammatically correct and coherent paragraphs.
Customization and Personalization: Provide options for users to customize the generated
paragraphs, enabling them to adjust the length, tone, or style to meet their specific writing requirements
and preferences.
Efficient Performance: Optimize the app's performance to ensure real-time paragraph generation
with minimal latency, providing users with a seamless and responsive writing experience.
1.5 Flowchart
4
PARA-GPT APPLICATION
Chapter 2:
● Internet Connectivity: As real-time internet access is essential for utilizing the ChatGPT API
ChatGPT API Integration: The app must integrate with the ChatGPT API, enabling
seamless communication with the language model to generate paragraphs based on user input
5
PARA-GPT APPLICATION
6
PARA-GPT APPLICATION
Chapter 3:
Implementation
Implementing the Para-GPT system involves several technical steps, including API
integration, algorithm development, Android app development, and testing. Here's a concise
implementation outline:
- Register for access to the chosen language model API (e.g., OpenAI's GPT-3) and
obtain the necessary credentials for integration.
- Set up API endpoints to enable communication between the Android app and the language
model API.
- Develop an algorithm in the Android app that processes user input words and sends
requests to the API for paragraph generation.
- Receive and process the API's response to obtain the generated paragraph.
- Design the user interface (UI) of the Android app to allow users to input words and view
the generated paragraphs.
- Implement the app using Java or Kotlin, incorporating necessary libraries and frameworks.
- Ensure a smooth and responsive user experience by optimizing the app's performance and
loading times.
7
PARA-GPT APPLICATION
3. Customization Options:
- Implement customization options within the app to allow users to adjust the length, tone,
or style of the generated paragraphs.
- Implement robust error handling mechanisms to address invalid inputs, connectivity issues,
or API errors gracefully.
- Test the app on various Android devices with different screen sizes and OS versions to
ensure compatibility.
- Perform user testing and gather feedback to identify and address potential issues and
improvements.
- Ensure the app complies with data privacy regulations and securely handles user inputs
without storing any sensitive information.
- Implement encryption and secure communication protocols when exchanging data with the
language model API.
- Deploy the Para-GPT app on the Google Play Store or other distribution platforms.
- Monitor user feedback and analytics to identify any shortcomings and iterate on the app's
features and functionality.
- Regularly update the app to enhance user satisfaction and address any emerging issues.
By following this implementation plan, you can successfully develop and deploy the Para-
GPT system, providing users with an efficient and user-friendly Android app for paragraph
8
PARA-GPT APPLICATION
Android Studio is the official integrated development environment (IDE) for Android app
development, provided by Google. It serves as the primary platform for developing Android
applications and offers a wide range of tools and features to streamline the development
process. Here are the key aspects of Android Studio used for implementing the Para-GPT
system:
- Android Studio includes a powerful UI design editor that allows developers to create
visually appealing and responsive user interfaces.
- Developers can drag and drop UI components, define layouts, and preview the UI in real-
time across various screen sizes and orientations.
- Android Studio provides a code editor with intelligent code completion, syntax
highlighting, and error checking to aid developers in writing clean and efficient code.
- It supports Java, Kotlin, and C++ as programming languages for Android app
development. Kotlin is the recommended language by Google for modern Android
development.
- Android Studio facilitates the integration of third-party APIs, including the language
model API (e.g., ChatGPT API) used in the Para-GPT system.
- Developers can manage dependencies and add external libraries to extend the app's
capabilities and improve development efficiency.
- Android Studio comes with an emulator that allows developers to test their apps on virtual
Android devices with various configurations.
- Developers can also test the app on physical Android devices connected to their
development machine for real-world testing.
9
PARA-GPT APPLICATION
- Android Studio offers advanced debugging and profiling tools to identify and resolve
issues in the app.
- Developers can set breakpoints, inspect variables, and analyze app performance to
optimize resource usage.
- Android Studio integrates with version control systems like Git, making it easier for
developers to collaborate on the project and manage code changes.
- Android Studio utilizes the Gradle build system, which allows for flexible project
configuration and efficient dependency management.
- Gradle handles the compilation, packaging, and building of the Android app, making the
development process smoother.
8. App Deployment:
- Android Studio provides tools for packaging and signing the app for deployment to the
Google Play Store or other distribution platforms.
- Developers can generate signed APKs (Android Package) or app bundles for uploading to
the app store.
Overall, Android Studio offers a comprehensive and feature-rich environment for building
Android applications, making it an ideal platform for implementing the Para-GPT system as an
Android app. Its developer-friendly tools and continuous updates ensure a smooth and efficient
development process for creating high-quality Android applications.3.3
MainActivity.java
package com.example.easychatgpt;
import androidx.annotation.NonNull;
10
PARA-GPT APPLICATION
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
11
PARA-GPT APPLICATION
RecyclerView recyclerView;
TextView welcomeTextView;
EditText messageEditText;
ImageButton sendButton;
List<Message> messageList;
MessageAdapter messageAdapter;
= MediaType.get("application/json; charset=utf-8");
.readTimeout(60, TimeUnit.SECONDS)
.build();
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recycler_view);
welcomeTextView = findViewById(R.id.welcome_text);
messageEditText = findViewById(R.id.message_edit_text);
sendButton = findViewById(R.id.send_btn);
recyclerView.setAdapter(messageAdapter);
llm.setStackFromEnd(true);
12
PARA-GPT APPLICATION
recyclerView.setLayoutManager(llm);
sendButton.setOnClickListener((v)->{
addToChat(question,Message.SENT_BY_ME);
messageEditText.setText("");
callAPI(question);
welcomeTextView.setVisibility(View.GONE);
});
runOnUiThread(new Runnable() {
@Override
messageList.add(new Message(message,sentBy));
messageAdapter.notifyDataSetChanged();
recyclerView.smoothScrollToPosition(messageAdapter.getItemCount());
});
messageList.remove(messageList.size()-1);
addToChat(response,Message.SENT_BY_BOT);
13
PARA-GPT APPLICATION
//okhttp
try {
jsonBody.put("model","gpt-3.5-turbo");
obj.put("role","user");
obj.put("content",question);
messageArr.put(obj);
jsonBody.put("messages",messageArr);
} catch (JSONException e) {
e.printStackTrace();
.url("https://api.openai.com/v1/chat/completions")
.header("Authorization","Bearer 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")
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
14
PARA-GPT APPLICATION
if(response.isSuccessful()){
try {
.getJSONObject("message")
.getString("content");
addResponse(result.trim());
} catch (JSONException e) {
e.printStackTrace();
}else{
});
Chapter 4:
Challenges faced by Para-Gpt Application
The Para-GPT application might encounter several challenges during its development,
deployment, and usage. Some of the common challenges include:
1. API Limitations: The language model API (e.g., ChatGPT API) may have rate limits or
usage restrictions, affecting the number of requests the app can make in a given time period.
This can lead to delays in generating paragraphs during peak usage times.
15
PARA-GPT APPLICATION
3. Quality of Generated Content: The generated paragraphs may vary in quality and coherence
depending on the user's input, and the language model might produce text that appears
plausible but lacks accuracy or may seem nonsensical.
4. Cost of API Usage: The usage of a language model API often incurs costs, especially for
large-scale applications. Controlling expenses while ensuring a good user experience can be a
challenge.
5. Internet Connectivity: The app's functionality relies on internet connectivity to access the
language model API, making it unusable without an active internet connection.
6. User Data Privacy: Handling user inputs and API communication might raise concerns
about data privacy and security. Ensuring that user data is handled responsibly and not
misused is crucial.
7. Algorithm Optimization: Developing an efficient algorithm for processing user inputs and
obtaining coherent paragraphs can be complex, requiring fine-tuning and optimization.
8. User Experience and Customization: Balancing simplicity and customization options in the
user interface is a challenge. Providing customization without overwhelming users can be
tricky.
9. Model Understanding Bias: Language models like GPT-3 may inadvertently generate
biased or politically charged content based on the training data. Ensuring fairness and
impartiality in the generated paragraphs is essential.
10. Compatibility and Device Variation: The app must be compatible with a wide range of
Android devices with varying hardware configurations and screen sizes, leading to potential
fragmentation and compatibility issues.
11. App Store Guidelines: Meeting the guidelines and policies of app stores, such as Google
Play Store, is necessary to ensure successful app distribution.
16
PARA-GPT APPLICATION
Chapter 5:
RESULT
17
PARA-GPT APPLICATION
18
PARA-GPT APPLICATION
19
PARA-GPT APPLICATION
CHAPTER 6
CONCLUSION
In conclusion, the Para-GPT Android app represents a significant milestone in providing users
with a user-friendly and efficient platform for generating paragraphs based on their input
words. Throughout the development process, we successfully integrated a language model
API, such as GPT-3, into the app, allowing it to generate contextually relevant and coherent
paragraphs in real-time. The implementation journey involved designing an intuitive user
interface that facilitates easy word input and displays the generated paragraphs seamlessly.
Integrating the API and developing a robust algorithm were essential steps to ensure smooth
communication with the language model and to deliver paragraphs that align with users'
intentions and input. Nevertheless, the development journey was not without its challenges.
We encountered issues with API limitations, contextual understanding, and maintaining the
quality of the generated content. These challenges prompted us to carefully consider user
needs and continuously improve the app based on valuable user feedback. The Para-GPT app
now stands as a valuable tool for users seeking quick and relevant paragraph generation. With
customizable options allowing users to adjust paragraph length, tone, and style, the app
addresses a broad spectrum of user preferences. Looking ahead, we recognize the importance
of staying updated with advancements in language models, addressing potential bias concerns,
and further optimizing the app's algorithm and user experience. Our commitment to
continuous improvement aims to make the Para-GPT app a reliable, user-friendly, and
indispensable tool for users seeking instant and contextually accurate paragraph generation.
By deploying the app on the Google Play Store or other distribution platforms, we hope to
reach a broader audience and empower users with the ability to create well-crafted paragraphs
effortlessly.
20
PARA-GPT APPLICATION
21