Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
litesh1123 authored Sep 10, 2023
1 parent fd68999 commit a57eb14
Show file tree
Hide file tree
Showing 14 changed files with 1,090 additions and 0 deletions.
568 changes: 568 additions & 0 deletions Tkinter Menu Bar.py

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions boto3_ec2_instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/python3

print("content-type: text/html")
print()


import cgi


import boto3

#AWS credentials and region
aws_access_key = ''
aws_secret_key = ''
region = 'ap-south-1' # Change this to your desired region

# EC2 instance settings
instance_type = 't2.micro' # Change this to your desired instance type
ami_id = '' # Change this to your desired AMI ID


# Create a Boto3 EC2 client
ec2_client = boto3.client('ec2', aws_access_key_id=aws_access_key, aws_secret_access_key=aws_secret_key, region_name=region)

# Launch EC2 instance
response = ec2_client.run_instances(
ImageId=ami_id,
InstanceType=instance_type,

MinCount=1,
MaxCount=1
)

print("Instance has been launched.")
25 changes: 25 additions & 0 deletions boto3_s3_bucket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python3

print("content-type: text/html")
print()

import boto3

region = 'ap-south-1'

def create_s3_bucket(bucket_name, region=region):
try:
s3_client = boto3.client('s3', region_name=region)
location_constraint = region if region != 'us-east-1' else ''

s3_client.create_bucket(
Bucket=bucket_name,
CreateBucketConfiguration={
'LocationConstraint': location_constraint
}
)
print(f"Bucket '{bucket_name}' created successfully.")
except Exception as e:
print(f"Error creating bucket '{bucket_name}': {e}")

create_s3_bucket("azfar653725")
18 changes: 18 additions & 0 deletions chatGPT_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python3

import cgi

print("content-type: text/html")
print()

data=cgi.FieldStorage()
tb=data.getvalue("name")
from langchain.llms import OpenAI
myllm=OpenAI(
model="text-davinci-003",
openai_api_key="",
temperature=0

)
res=myllm.generate( prompts=[tb])
print(res.generations[0][0].text)
20 changes: 20 additions & 0 deletions docker_os_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python3

print("content-type: text/html")

print()

import subprocess

s=subprocess.getoutput("sudo docker ps -a")

leng=len(s.split("\n"))-1
for i in range(1,leng):
al=s.split("\n")
ls=al[1:]
lss=ls[0].split()

finalimage=lss[0]+":"+lss[1]

print(finalimage)
print("\n")
66 changes: 66 additions & 0 deletions langchain_combine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/python3
import os
import json
import time
import cgi
print("Content-Type: text/html")
print()

form = cgi.FieldStorage()
data1=form.getvalue("search_query1")
print(data1)
from langchain.llms import OpenAI
my_openapi_key="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"
from langchain.chains import LLMChain


myllm = OpenAI(temperature=0, openai_api_key=my_openapi_key)


output = myllm( prompt= data1)

print(output)

from langchain.prompts import PromptTemplate

myprompt=PromptTemplate(
template="tell me top 2 {thing} of india ,Give only name of it." ,
input_variables=["thing"]
)

myprompt.format(thing="birds")
output = myllm( prompt=myprompt.format(thing="birds") )

my_things_prompt=myprompt.format(thing="birds")

type(myllm)

mychain= LLMChain(
prompt=myprompt ,
llm=myllm
)
data2=form.getvalue("search_query2")
print(mychain.run(thing=data2))

from langchain.agents import load_tools

import os

# Replace 'YOUR_API_KEY' with your actual SerpApi API key
api_key = 'c384209be726262c36ae60aeefad89ffe2e91ebb3ffa8ff904c1ca179cc93127'

# Set the environment variable
os.environ['SERPAPI_API_KEY'] = api_key

mytools= load_tools(tool_names = ["serpapi"] ,llm=myllm)

from langchain.agents import initialize_agent

from langchain.agents import AgentType

my_google_chain =initialize_agent(tools=mytools ,
llm=myllm ,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True)
data3=form.getvalue("search_query3")
my_google_chain.run(data3)
45 changes: 45 additions & 0 deletions langchain_google.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/python3

print("content-type: text/html")
print()

import cgi
data=cgi.FieldStorage()
promp=data.getvalue("name")

from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.agents import load_tools
from langchain.agents import AgentType
from langchain.agents import initialize_agent
import os


myllm=OpenAI(
model="text-davinci-003",
openai_api_key="...",
temperature=0
)
mylw=PromptTemplate(
template="tell me two best{item} in {country}. ",
input_variables=["item","country"]

)
mychain=LLMChain(
llm=myllm,
prompt=mylw
)
os.environ['SERPAPI_API_KEY']="..."

myserptool=load_tools(tool_names=['serpapi'])

mygooglechain=initialize_agent(
llm=myllm,
tools=myserptool,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True

)

mygooglechain.run(promp)
15 changes: 15 additions & 0 deletions linux_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/python3

print("content-type: text/html")
print()

import cgi
import subprocess

data=cgi.FieldStorage()

daat1=data.getvalue("na")

sub=subprocess.getoutput(daat1)

print(sub)
18 changes: 18 additions & 0 deletions notepad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python3

print("content-type: text/html")
print()

import cgi

data=cgi.FieldStorage()

mydaat=data.getalue("w")

file_path = "usr/bin/data.txt"


with open(file_path, "w") as file:
file.write(data)

print("Note Saved Successfully !!")
78 changes: 78 additions & 0 deletions projectY.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-image: url('https://images.pexels.com/photos/1964471/pexels-photo-1964471.jpeg?auto=compress&cs=tinysrgb&w=600');
background-size: cover;
background-position: center;
font-family: Arial, sans-serif;
}

.container {
text-align: center;
padding: 30px;
background-color: rgba(255, 255, 255, 0.7);
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.big-font {
font-size: 36px;
font-weight: bold;
margin-bottom: 20px;
}

.input-field {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 10px;
font-size: 16px;
}

.submit-button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 18px;
transition: background-color 0.3s;
margin-right: 10px;
}

.submit-button:hover {
background-color: #0056b3;
}
</style>
<title>####</title>
</head>
<body>
<div class="container">
<div class="big-font">MywebUI</div>
<form action="http://65.0.130.148/cgi-bin/project10.py">
<input class="input-field" type="text" name="name" placeholder="Chrome...">
<button class="submit-button" type="submit">Submit </button>
</form>
<form action="http://65.0.130.148/cgi-bin/project11.py">
<input class="input-field" type="text" name="name2" placeholder="Wikipedia...">
<button class="submit-button" type="submit">Submit </button>
</form>
<form action="http://65.0.130.148/cgi-bin/project12.py">
<input class="input-field" type="text" name="name3" placeholder="Youtube...">
<button class="submit-button" type="submit">Submit </button>
</form>
</div>
</body>
</html>
Loading

0 comments on commit a57eb14

Please sign in to comment.