Skip to content

Instantly share code, notes, and snippets.

View praneethkvs's full-sized avatar

Praneeth Kandula praneethkvs

View GitHub Profile
@praneethkvs
praneethkvs / chatGPT_python_API.ipynb
Last active March 16, 2023 21:15
How to use the chatGPT Python API
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@praneethkvs
praneethkvs / chatGPT_python_API.py
Created March 16, 2023 18:47
Using chatGPT python API
#!pip install --upgrade openai
import openai
API_KEY = YOUR_API_KEY #Replace with your Own API Key
openai.api_key = API_KEY
# Create the chat completion request
messages = []
#install packages
!pip install openai
import os
import openai
#openai.organization = "YOUR_ORG_ID" #Not required for a personal use Open AI account
API_KEY = "YOUR_API_KEY"
openai.api_key = API_KEY
@praneethkvs
praneethkvs / app.yaml
Last active March 6, 2021 20:40
app.yaml config file for Google App Engine.
service: streamlit-test-app
runtime: custom
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
@praneethkvs
praneethkvs / Dockerfile
Last active October 2, 2021 21:23
Dockerfile for streamlist test application.
#Base Image to use
FROM python:3.7.9-slim
#Expose port 8080
EXPOSE 8080
#Optional - install git to fetch packages directly from github
RUN apt-get update && apt-get install -y git
#Copy Requirements.txt file into app directory
@praneethkvs
praneethkvs / requirements.txt
Created February 9, 2021 19:02
Requirements file for stocks_test.py Google Cloud Function script.
pandas==0.25.3
requests==2.24.0
google-api-core==1.21.0
google-api-python-client==1.10.0
google-auth==1.19.2
google-auth-httplib2==0.0.4
google-cloud-core==1.3.0
google-cloud-trace==0.23.0
google-auth-oauthlib==0.4.1
google-cloud==0.34.0
@praneethkvs
praneethkvs / stocks_test.py
Created February 9, 2021 18:56
Google Cloud Function to Fetch Stocks data from Yahoo Finance and Upload to a BigQuery Dataset.
import pandas as pd
import yfinance as yf
from google.cloud import bigquery
def stocks_test(event, context):
get_tickers = pd.read_csv("https://raw.githubusercontent.com/datasets/s-and-p-500-companies-financials/master/data/constituents.csv")
stock_dat = yf.download(get_tickers.Symbol.head(5).tolist(),period="2d",actions=False,group_by=None)
@praneethkvs
praneethkvs / stock_tracker.py
Last active January 24, 2021 20:50
Python Script to fetch stock market data from yfinance and upload to BigQuery table.
#Import Packages
import pandas as pd
import yfinance as yf
from google.cloud import bigquery
from google.oauth2 import service_account
#Authentication
key_path = "your_service_token_path.json" ##Replace with path to your service token file
credentials = service_account.Credentials.from_service_account_file(
Date Open High Low Close Volume
03-01-00 1469.25 1478.0 1438.359985 1455.219971 931800000
04-01-00 1455.219971 1455.219971 1397.430054 1399.420044 1009000000
05-01-00 1399.420044 1413.27002 1377.680054 1402.109985 1085500000
06-01-00 1402.109985 1411.900024 1392.099976 1403.449951 1092300000
07-01-00 1403.449951 1441.469971 1400.72998 1441.469971 1225200000
@praneethkvs
praneethkvs / time_logger.py
Created February 6, 2020 03:37
Log Function Execution and Process Time
from functools import wraps
import logging
import time
logging.basicConfig(filename="log_file.txt",level=logging.INFO)
def time_logger(original_function):
@wraps(original_function)
def wrapper_function(*args,**kwargs):