Skip to content

Commit

Permalink
tutorial54
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Apr 6, 2024
1 parent 99b8964 commit c132400
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion tutorial2/single_url.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from langchain.document_loaders import youtube
import io

loader=youtube.YoutubeLoader.from_youtube_url("https://youtu.be/Jupb5v9Z-vQ")
loader=youtube.YoutubeLoader.from_youtube_url("https://youtu.be/zeVEPhDvHUQ")
docs=loader.load()
print(docs)
with io.open("transcript.txt","w",encoding="utf-8")as f1:
Expand Down
2 changes: 1 addition & 1 deletion tutorial2/transcript.txt

Large diffs are not rendered by default.

Binary file removed tutorial52/~$tutorial51.pptx
Binary file not shown.
27 changes: 27 additions & 0 deletions tutorial53/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import streamlit as st
import pandas as pd
from langchain.agents.agent_types import AgentType
from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain_openai import ChatOpenAI



llm=ChatOpenAI(model="gpt-4",temperature=0)
st.title("CSV CHAT APP")
st.write("upload your csv & and ask anything")
file=st.file_uploader("select your file",type=["csv"])
if file is not None:
df=pd.read_csv(file)
#st.write(df)
input=st.text_area("ask your question here")
if input is not None:
button=st.button("Submit")
agent=create_pandas_dataframe_agent(
llm,df,verbose=False,agent_type=AgentType.OPENAI_FUNCTIONS
)
if button:
result=agent.invoke(input)
st.write(result["output"])



Binary file removed tutorial53/~$tutorial53.pptx
Binary file not shown.
Binary file added tutorial54/__pycache__/llmload.cpython-311.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions tutorial54/llmload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from langchain_community.llms import CTransformers

def loadllm():
config={
"max_new_tokens":1048,
"temperature":0.1,
"context_length":4096,
"gpu_layers":32,
"threads":-1
}
llm=CTransformers(model="/Users/roni/Documents/GitHub/LLMtutorial/tutorial54/mistral-7b-instruct-v0.1.Q5_K_S.gguf",
model_type="mistral",
config=config
)
return llm
21 changes: 21 additions & 0 deletions tutorial54/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from llmload import loadllm
import requests
from langchain.agents import AgentType,initialize_agent
from langchain.tools import Tool

def getPrice(input):
url="https://api.coincap.io/v2/assets/"+input.lower()
response=requests.get(url).json()
price=response["data"]["priceUsd"]
return price

apicall=Tool(
name="getCryptoPrice",
func=getPrice,
description="use to get the price for any given crypto from user input"

)
tools=[apicall]
llm=loadllm()
agent=initialize_agent(tools,llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,verbose=True)
print(agent.run("what is the price of shiba-inu"))
Binary file added tutorial54/tutorial54.pptx
Binary file not shown.

0 comments on commit c132400

Please sign in to comment.