Introduction: In the rapidly evolving landscape of technology, building dynamic and engaging applications is a skill that sets developers apart. In this detailed guide, we will explore the step-by-step process of creating a ChatGPT-powered app using Python and StreamLit. Additionally, we’ll delve into the intricacies of integrating the RazorPay payment gateway for seamless and secure transactions. To top it off, we’ll learn how to deploy our creation to the cloud using GitHub repositories and StreamLit Cloud.

Part 1: ChatGPT App Development Our journey begins with harnessing the power of ChatGPT, a large language model that revolutionizes natural language understanding. Learn the fundamentals of incorporating ChatGPT into your Python application, enhancing user interactions and creating a more immersive experience. We’ll cover the coding aspects, exploring the nuances of building applications that leverage the capabilities of this state-of-the-art language model.

Part 2: Integrating RazorPay for Seamless Transactions In the second chapter, we turn our attention to the critical aspect of monetizing our applications. RazorPay, a popular payment gateway, will be seamlessly integrated into our StreamLit app. You’ll gain insights into the RazorPay API, learning how to incorporate secure and efficient payment processing capabilities. From user authentication to transaction completion, this chapter covers it all.

Part 3: StreamLit Cloud Deployment with GitHub The final chapter focuses on making our app accessible to users globally. We’ll explore the world of StreamLit Cloud and master the art of deploying our application using GitHub repositories. This ensures that our app is not only functional but also easily deployable and scalable. You’ll gain a comprehensive understanding of the deployment process, making your creations available to users worldwide.

Resources and Links: Throughout the guide, we provide essential resource links to GitHub repositories, StreamLit documentation, and the RazorPay integration guide. These resources serve as valuable references for developers looking to dive deeper into the intricacies of each component.

Conclusion: By the end of this comprehensive guide, you will have acquired the skills to create, monetize, and deploy language model-powered applications with ease. Whether you’re a seasoned developer or a coding enthusiast, this tutorial series is designed to empower you with the knowledge and tools needed to stay ahead in the ever-evolving world of technology.

Embark on this exciting journey of tech mastery, and transform your coding skills into a force to be reckoned with. Happy coding! 🚀💻

 

You can directly download the files from the following link also:

Link to Download the Files

Content of the files are described below.

config.py

api_key = “sk-OGygcBQtL0-Your API-Key-iIAVF90xnoHrREs”

 

requirements.txt

openai==1.3.6
charset-normalizer==2.1.0
streamlit
requests
razorpay==1.3.0
streamlit-javascript==0.1.5

 

test.html

 

<!DOCTYPE html>
<head></head>
<body>
<div id=”paymentId”></div>
<!– <button id=”rzp-button1″>Pay with Razorpay</button> –>
<script src=”https://checkout.razorpay.com/v1/checkout.js”></script>
<script>
const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get(‘order_id’);
var options = {
“key”: “rzp_live_ccdgxUrjuwvI5O”, // Enter the Key ID generated from the Dashboard
“amount”: “5000”, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
“currency”: “INR”,
“name”: “InstaDataHelp Analytics Services”,
“description”: “Test Transaction”,
“image”: “https://instadatahelp.com/wp-content/uploads/2019/12/SmallLogo-Copy-1.jpg”,
“order_id”: myParam, //This is a sample Order ID. Pass the `id` obtained in the response of Step 1
“handler”: function (response){
document.getElementById(‘paymentId’).innerHTML = response.razorpay_payment_id;
alert(‘Payment Successful’);
localStorage.setItem(“status”, “success”);
localStorage.setItem(“paymentId”, response.razorpay_payment_id);
urlParams.append(‘order_id’, response.razorpay_payment_id);
},
“prefill”: {
“name”: “”,
“email”: “”,
“contact”: “”
},
“notes”: {
“address”: “Razorpay Corporate Office”
},
“theme”: {
“color”: “#3399cc”
}
};
var rzp1 = new Razorpay(options);
rzp1.on(‘payment.failed’, function (response){
alert(‘Payment Failed’);
urlParams.append(‘order_id’, ‘failed’);
});
rzp1.open();
e.preventDefault();
// document.getElementById(‘rzp-button1’).onclick = function(e){
// rzp1.open();
// e.preventDefault();
// }
</script>
</body>

 

 

Literature_Review_Writer.py

import openai
from openai import OpenAI
import streamlit as st
#from charset_normalizer import md__mypyc
import config
#import requests
import razorpay
client = razorpay.Client(auth=(“rzp_live_ccdgxUrjuwvI5O”, “lHxlvFXCwt8qz6StKedTMab2”))
client.set_app_details({“title” : “Streamlit App”, “version” : “1.0.0”})
import streamlit.components.v1 as components
from streamlit_javascript import st_javascript
import time
from streamlit.components.v1 import html

def get_from_local_storage(k):
v = st_javascript(
f”JSON.parse(localStorage.getItem(‘{k}’));”
)
return v or {}

def set_to_local_storage(k, v):
jdata = json.dumps(v)
st_javascript(
f”localStorage.setItem(‘{k}’, JSON.stringify({jdata}));”
)

#openai.api_key=config.api_key
clt = OpenAI(
# defaults to os.environ.get(“OPENAI_API_KEY”)
api_key=config.api_key,
)

# Set your Stripe API key

def main():
st.title(“Research Writer”)
st.subheader(‘This app has been developed and maintained by InstaDataHelp Analytics Services‘)
#st.write(‘This app is supposed to help in writing literature review and writeup on any topic. The write-up includes in-text citations and references’)
#st.write(‘Please mail to info@instadatahelp.com for suggestions and improvements. Per write-up cost is INR 50 currently. The articles generated are plag-free.’)
#st.write(‘Please write any topic of interest in the below box to get detailed writeup.’)
#st.write(‘This is for reference purpose only.’)
#st.write(‘Please Note: The write-up generated are for references and researchers may use it in their manuscript with or without modification.’)
#st.write(‘We charge a nominal fee of INR 50.00 (0.65 USD) for each literature review.’)
#st.write(‘Please enter your topic and click Pay INR 50. Once payment ID is generated, please put that in the below box and generate blog writeup.’)
#st.write(‘Please Whatsapp or call at +91 9903726517 if you face any issue after payment. Currently accepting payments from India only.’)
#st.write(‘It is secure RazorPay Payment Gateway and your payment details will not be stored anywhere.’)
st.write(‘Please visit https://www.instadatahelp.com/research-writer/ for details’)

notes = st.text_area(“Enter Topic Information:”)

st.subheader(‘Generate Writeup’)
if st.button(“Pay INR 50”):

#First Payment will happen and then once it happen following code should run
order = client.order.create({
“amount”: int(5000),
“currency”: “INR”,

})
paymentId = order[‘id’]
st.experimental_set_query_params(
order_id=paymentId
)
p = open(“./test.html”)
components.html(p.read(),height=800,width=500)

id = st.text_input(‘Enter Payment Id Generated After Making Payment’)

if st.button(“Generate Writeup”):
payment = client.payment.fetch(id)

if payment[‘status’] == ‘captured’ or payment[‘status’] == ‘authorized’:
st.write(“Payment successful”)
with st.spinner(“Generating Writeup …”):
response = clt.chat.completions.create(
model=”gpt-3.5-turbo”,
messages=[{‘role’:’user’,’content’:f’You act as reseracher. Write research paper with more than 3000 words. Include real references. Include in-text citations. Write on topic \n\n{notes}\n\nDescription:’}]

)
description = response.choices[0].message.content
st.subheader(“Generated Literature Review”)
st.write(description)

else:
st.write(“Payment failed”)

if __name__ == ‘__main__’:
main()