From fb46621a58cd6cb4478efa7c2f3a4424eeb67945 Mon Sep 17 00:00:00 2001 From: JAlcocerT Date: Wed, 25 Dec 2024 20:45:35 +0100 Subject: [PATCH] testing langchain and ready for v2 release --- .gitignore | 2 + Deploy/Docker-compose.yml | 3 +- Deploy/README.md | 9 +- Development/readme.md | 1 + README.md | 46 +++- Tests/langchain_pandasDF.ipynb | 473 +++++++++++++++++++++++++++++++++ Tests/readme.md | 8 + Tests/requirements.txt | 11 + app/helpers.py/plot_weather.py | 1 + images/readme.md | 1 + requirements.txt | 4 +- 11 files changed, 552 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 Development/readme.md create mode 100644 Tests/langchain_pandasDF.ipynb create mode 100644 Tests/readme.md create mode 100644 Tests/requirements.txt create mode 100644 app/helpers.py/plot_weather.py create mode 100644 images/readme.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b50d285 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*_venv/ +.env \ No newline at end of file diff --git a/Deploy/Docker-compose.yml b/Deploy/Docker-compose.yml index 7ed5859..9d61f67 100644 --- a/Deploy/Docker-compose.yml +++ b/Deploy/Docker-compose.yml @@ -5,4 +5,5 @@ services: container_name: tripplanner ports: - 8051:8050 - restart: unless-stopped \ No newline at end of file + restart: unless-stopped + command: python3 ./app/app.py \ No newline at end of file diff --git a/Deploy/README.md b/Deploy/README.md index 1a2f60a..0f9c00b 100644 --- a/Deploy/README.md +++ b/Deploy/README.md @@ -1,9 +1,14 @@ # Local Deployment -Deploy me with docker! +[**Deploy**](https://fossengineer.com/understanding-containers-for-selfhosting/) me with docker! + + +**Container Image** creation: * [DockerHub - x86,ARM32/64](https://hub.docker.com/repository/docker/fossengineer/trip_planner/general) * [Build Locally](https://fossengineer.com/building-docker-container-images/#building-images-locally-x86-arm32-arm64) +* Use [Github Actions MultiArch CI/CD](https://jalcocert.github.io/JAlcocerT/github-actions-use-cases/#actions-cicd-for-python-projects) + ## Usage @@ -33,7 +38,7 @@ docker run -p 8051:8050 --name trip-planner fossengineer/trip-planner:latest Simply pulling `fossengineer/trip-planner:latest` will retrieve the correct image for your arch, but you can also pull specific arch images via tags. -The architectures supported by this image are: +The **architectures supported** by this container image are: | Architecture | Available | Tag | | :----: | :----: | ---- | diff --git a/Development/readme.md b/Development/readme.md new file mode 100644 index 0000000..7090971 --- /dev/null +++ b/Development/readme.md @@ -0,0 +1 @@ +> [Post](https://jalcocert.github.io/JAlcocerT/blog/dev-in-docker/) \ No newline at end of file diff --git a/README.md b/README.md index bdb431f..638110d 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,50 @@ Using **historical weather data** together with location data in a DASH App to answer your question: **How is the expected weather at a particular period of the year in my destination?** -* [Deployed the App](https://github.com/JAlcocerT/Py_Trip_Planner/tree/main/Deploy) +* [Deploy the App](https://github.com/JAlcocerT/Py_Trip_Planner/tree/main/Deploy) * Further Description at: - * For V1: Historical Weather, [MeteoStat](https://jalcocert.github.io/JAlcocerT/python-trip-planner/) - * For V2: Historical and [Forecast Weather](https://jalcocert.github.io/JAlcocerT/python-weather-forecast-with-open-meteo-api/) + * For V1: Historical Weather, with [MeteoStat](https://jalcocert.github.io/JAlcocerT/python-trip-planner/) + * For V2: Historical and [Forecasted Weather](https://jalcocert.github.io/JAlcocerT/python-weather-forecast-with-open-meteo-api/) + * For V3: Adding AI capabilities - [Chat with Weather Data DF via LangChain](https://jalcocert.github.io/JAlcocerT/using-langchain-with-pandas-df/) + + + +###$ Quick Setup + +> [!IMPORTANT] +> Prepare the API key for v3 + + +
+ Using Python Venv...👇 +   + + +```sh +#sudo apt install python3.12-venv +python3 -m venv trip_planner_venv + +#Unix +source trip_planner_venv/bin/activate +#.\trip_planner_venv\Scripts\activate #Windows + +pip install -r requirements.txt + + +source .env +#export OPENAI_API_KEY="your-api-key-here" +#set OPENAI_API_KEY=your-api-key-here +#$env:OPENAI_API_KEY="your-api-key-here" +echo $GROQ_API_KEY $OPENAI_API_KEY $ANTHROPIC_API_KEY + +streamlit run Z_ST_AIssistant_v2.py + +# git add . +# git commit -m "better st offer analyzer" +# git push +``` + +
## Powered Thanks To ❤️ diff --git a/Tests/langchain_pandasDF.ipynb b/Tests/langchain_pandasDF.ipynb new file mode 100644 index 0000000..3f5601c --- /dev/null +++ b/Tests/langchain_pandasDF.ipynb @@ -0,0 +1,473 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.12.3 (main, Nov 6 2024, 18:32:19) [GCC 13.2.0]\n" + ] + } + ], + "source": [ + "#Rabbitmetrics YT - https://www.youtube.com/watch?v=rFQ5Kmkd4jc\n", + "\n", + "import sys\n", + "print(sys.version)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#pip install -r requirements.txt" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2.2.3\n" + ] + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "print(pd.__version__)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from dotenv import load_dotenv, find_dotenv\n", + "#import pandas as pd\n", + "\n", + "load_dotenv(find_dotenv())" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "from langchain.chat_models import ChatOpenAI\n", + "#from langchain.agents import create_pandas_dataframe_agent\n", + "from langchain_experimental.agents import create_pandas_dataframe_agent" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.3.4\n" + ] + } + ], + "source": [ + "import langchain_experimental as le\n", + "\n", + "print(le.__version__)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " date price\n", + "0 Jan 1 2000 1394.46\n", + "1 Feb 1 2000 1366.42\n", + "2 Mar 1 2000 1498.58\n", + "3 Apr 1 2000 1452.43\n", + "4 May 1 2000 1420.60\n" + ] + } + ], + "source": [ + "# URL of the dataset\n", + "url = \"https://raw.githubusercontent.com/vega/vega/main/docs/data/sp500.csv\" \n", + "\n", + "# Import the dataset into a pandas DataFrame\n", + "df = pd.read_csv(url) \n", + "\n", + "# Display the first few rows of the DataFrame\n", + "print(df.head())" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "date Oct 1 2007\n", + "price 1549.38\n", + "Name: 93, dtype: object\n" + ] + } + ], + "source": [ + "# Find the index of the row with the maximum price\n", + "max_price_index = df['price'].idxmax()\n", + "\n", + "# Retrieve the row with the maximum price\n", + "max_price_row = df.loc[max_price_index]\n", + "\n", + "# Print the row with the highest price value\n", + "print(max_price_row)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_343233/1811009375.py:1: LangChainDeprecationWarning: The class `ChatOpenAI` was deprecated in LangChain 0.0.10 and will be removed in 1.0. An updated version of the class exists in the :class:`~langchain-openai package and should be used instead. To use it run `pip install -U :class:`~langchain-openai` and import as `from :class:`~langchain_openai import ChatOpenAI``.\n", + " chat = ChatOpenAI(model_name=\"gpt-4o-mini\", temperature=0)\n" + ] + } + ], + "source": [ + "chat = ChatOpenAI(model_name=\"gpt-4o-mini\", temperature=0)\n", + "#chat = ChatOpenAI(model_name=\"gpt-4\", temperature=0)\n", + "\n", + "agent = create_pandas_dataframe_agent(chat, df, verbose=True,allow_dangerous_code=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_343233/68035407.py:1: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 1.0. Use :meth:`~invoke` instead.\n", + " agent.run(\"what were the period with crisis? Understanding crisis when for 3 consecutive months the price goes down from the previous month\")\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", + "\u001b[32;1m\u001b[1;3mThought: To identify periods of crisis, I need to check for three consecutive months where the price decreases compared to the previous month. I will first calculate the month-to-month price changes and then look for sequences of three consecutive months with negative changes.\n", + "\n", + "Action: I will calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "import pandas as pd\n", + "\n", + "# Assuming df is already defined\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "import pandas as pd\n", + "\n", + "# Assuming df is already defined\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3mI need to execute the code to calculate the month-to-month price changes and identify the periods of crisis using the correct tool.\n", + "\n", + "Action: I will execute the code to calculate the month-to-month price changes and identify the periods of crisis.\n", + "Action Input: \n", + "```python\n", + "df['price_change'] = df['price'].diff()\n", + "df['crisis'] = (df['price_change'] < 0).astype(int)\n", + "\n", + "# Identify periods of three consecutive months of crisis\n", + "df['crisis_period'] = df['crisis'].rolling(window=3).sum()\n", + "crisis_periods = df[df['crisis_period'] == 3]\n", + "crisis_periods[['date', 'price']]\n", + "```\u001b[0mI will execute the code to calculate the month-to-month price changes and identify the periods of crisis. is not a valid tool, try one of [python_repl_ast].\u001b[32;1m\u001b[1;3m\u001b[0m\n", + "\n", + "\u001b[1m> Finished chain.\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "'Agent stopped due to iteration limit or time limit.'" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agent.run(\"what were the period with crisis? Understanding crisis when for 3 consecutive months the price goes down from the previous month\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/tmp/ipykernel_146760/1894638340.py:1: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 1.0. Use :meth:`~invoke` instead.\n", + " agent.run(\"what is the highest year and month for SP500 value?\")\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", + "\u001b[32;1m\u001b[1;3mThought: To find the highest SP500 value, I need to find the maximum value in the 'price' column. Then, I need to find the corresponding date for this maximum value.\n", + "Action: python_repl_ast\n", + "Action Input: df['price'].idxmax()\u001b[0m\u001b[36;1m\u001b[1;3m93\u001b[0m\u001b[32;1m\u001b[1;3mThe index of the row with the highest SP500 value is 93. Now, I need to find the date corresponding to this index.\n", + "Action: python_repl_ast\n", + "Action Input: df.loc[93, 'date']\u001b[0m\u001b[36;1m\u001b[1;3mOct 1 2007\u001b[0m\u001b[32;1m\u001b[1;3mThe highest SP500 value corresponds to the date 'Oct 1 2007'.\n", + "Final Answer: The highest year and month for SP500 value is October 2007.\u001b[0m\n", + "\n", + "\u001b[1m> Finished chain.\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "'The highest year and month for SP500 value is October 2007.'" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "agent.run(\"what is the highest year and month for SP500 value?\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "trip_planner_venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Tests/readme.md b/Tests/readme.md new file mode 100644 index 0000000..60ea28a --- /dev/null +++ b/Tests/readme.md @@ -0,0 +1,8 @@ + +## Tests to add LangChain as RAG + +Chat over Pandas Dataframe containing weather info: + +* https://github.com/JAlcocerT/Data-Chat/tree/main/LangChain/ChatWithPandas + +* https://jalcocert.github.io/JAlcocerT/using-langchain-with-pandas-df/ \ No newline at end of file diff --git a/Tests/requirements.txt b/Tests/requirements.txt new file mode 100644 index 0000000..f388464 --- /dev/null +++ b/Tests/requirements.txt @@ -0,0 +1,11 @@ +openai==1.58.1 #https://pypi.org/project/openai/ +python-dotenv==1.0.1 + +pandas==2.2.3 +tabulate==0.9.0 + +langchain==0.3.13 +langchain_experimental==0.3.4 +langchain-community==0.3.13 + +###pip install -r requirements.txt \ No newline at end of file diff --git a/app/helpers.py/plot_weather.py b/app/helpers.py/plot_weather.py new file mode 100644 index 0000000..4287ca8 --- /dev/null +++ b/app/helpers.py/plot_weather.py @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/images/readme.md b/images/readme.md new file mode 100644 index 0000000..907154c --- /dev/null +++ b/images/readme.md @@ -0,0 +1 @@ +To be used in the main readme.md \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 00de7f2..d528bdc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,6 @@ pandas==1.2.4 plotly==5.11.0 meteostat==1.6.5 -openmeteo-py==0.0.1 \ No newline at end of file +openmeteo-py==0.0.1 + +###pip install -r requirements.txt \ No newline at end of file