-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.