Merge remote-tracking branch 'origin/main'

pull/1/head
o.likhogub 1 year ago
commit 5301229df4

@ -6,6 +6,7 @@
<component name="ChangeListManager">
<list default="true" id="6cb4dca5-d93c-4b61-8425-4ba8b7c9b2ff" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/weather_platform/apps/py-tg-bot-weather-agent/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/weather_platform/apps/py-tg-bot-weather-agent/main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -51,6 +52,9 @@
<recent name="$PROJECT_DIR$/weather_platform/apps" />
<recent name="$PROJECT_DIR$/weather_platform/ui-modules/src/lib/navbar" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/assets" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@ -61,7 +65,7 @@
<option name="presentableId" value="Default" />
<updated>1696663237589</updated>
<workItem from="1696663238626" duration="5030000" />
<workItem from="1696670312018" duration="20846000" />
<workItem from="1696670312018" duration="26053000" />
</task>
<servers />
</component>

@ -4,6 +4,10 @@
![Screenshot 2023-10-07 at 19.07.30.png](assets%2FScreenshot%202023-10-07%20at%2019.07.30.png)
![photo_2023-10-07 23.14.18.jpeg](assets%2Fphoto_2023-10-07%2023.14.18.jpeg)
![photo_2023-10-07 23.14.16.jpeg](assets%2Fphoto_2023-10-07%2023.14.16.jpeg)
## Software Platform
![Screenshot 2023-10-07 at 19.08.07.png](assets%2FScreenshot%202023-10-07%20at%2019.08.07.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@ -1,5 +1,6 @@
import pandas as pd
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
from langchain.agents import initialize_agent, AgentType, AgentOutputParser
from typing import List, Union
from langchain.schema import AgentAction, AgentFinish, OutputParserException
@ -7,8 +8,11 @@ from langchain.tools.base import StructuredTool
from typing import Optional
import requests
import telebot
from langchain.agents import create_json_agent, AgentExecutor
from langchain.agents.agent_toolkits import JsonToolkit
OPENAI_API = "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"
# OPENAI_API = "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"
OPENAI_API = "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"
BOT_KEY = '6415742729:AAHVyDkHHF57ZsVd9gJjVtXjKE2M9CydzPk'
@ -55,17 +59,17 @@ def fetch_get_weather_data(params={}):
return None
def get_sensors_insight() -> str:
"""Tool that using for get meteo weather sensors"""
"""This tool provides data about the sensors (sensors) of the weather station. Data: lat, lng, height, name, agregator_uuid. Use it to answer questions related to this data. """
data = fetch_get_sensors()
return data
def get_agregators_insight() -> str:
"""Tool that using for get meteo weather sensors"""
"""This tool provides data on adapters (repeaters that transmit data from sensors to the server) of the weather station. Data: lat, lng, height (altitude above sea level), name, country, city, region, street. Use it to answer questions related to this data."""
data = fetch_get_agregator()
return data
def get_weather_data_history_insight() -> str:
"""Tool that using for get meteo weather history from sensors using in the meteo system"""
"""This tool provides information about the history of changes in weather data readings. It will return an array of measurements including the following data: Sensor UUID, Agregator UUID, Type (Temperature, Humidity), Value, Time (date string). Use it to answer questions using this data."""
data = fetch_get_weather_data()
return data
@ -104,7 +108,7 @@ output_parser = CustomOutputParser()
agent_chain = initialize_agent(
tools,
chat,
max_iterations=3,
max_iterations=4,
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
output_parser=output_parser
@ -121,13 +125,16 @@ def echo_all(message):
user_id = message.from_user.id
print(message.text)
bot.reply_to(message, "AI думает... 🤔")
result = agent_chain(message.text)
llm = OpenAI(model_name="text-davinci-003", openai_api_key=OPENAI_API)
msg = llm("Translate the text to English: " + message.text)
request = "You are a system for monitoring data from weather systems. Solve the problem: " + msg + ". for this solution you can use any tool without me but you can run tool only one step."
result = agent_chain(request)
if (result):
final_answer = result['output']
print(final_answer)
bot.reply_to(message, str(final_answer))
msg = llm("Переведи на красивый русский язык: " + final_answer)
print("AGENT_FINAL: " + final_answer)
print("DAVINCHI_FINAL: " + msg)
bot.reply_to(message, str(msg))
bot.infinity_polling()

Loading…
Cancel
Save