From 7b8546fff03605f72e2d5cbbd4df748a2bcb8aa7 Mon Sep 17 00:00:00 2001 From: Artem-Darius Atlas Date: Sun, 8 Oct 2023 01:21:24 +0300 Subject: [PATCH] feat: added featured measure register --- .idea/workspace.xml | 28 ++++++++++++++++++ .../agw/src/measures/measures.controller.ts | 29 ++++++++++++++++++- .../apps/py-tg-bot-weather-agent/main.py | 21 +++++++++----- 3 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8da40ba --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/weather_platform/apps/agw/src/measures/measures.controller.ts b/weather_platform/apps/agw/src/measures/measures.controller.ts index eea0443..cf41b22 100644 --- a/weather_platform/apps/agw/src/measures/measures.controller.ts +++ b/weather_platform/apps/agw/src/measures/measures.controller.ts @@ -1,4 +1,4 @@ -import {Body, Controller, Get, Post} from "@nestjs/common"; +import {Body, Controller, Get, Param, Post} from "@nestjs/common"; import { MeasureCreateDTOLocalClass, MeasuresService } from "./measures.service"; import { ApiInternalServerErrorResponse, @@ -65,6 +65,33 @@ export class MeasuresController { return check ? { code: '200' } : { code: '500' }; } + + @ApiOperation({ summary: 'Register Measure', description: 'Create Measure using ASC_WEATHER_RGM', operationId: 'create', tags: ['Measures StorePackages'], }) + @ApiResponse({ status: 200, type: MeasuresCreateSuccessResponse, description: 'The found measures', }) + @Get('register/:sendedInDate/:sensor_uuid/:agregator_uuid/:math_time/:msg_type/:msg_value') + async createMeasuresPackBody( + @Param('sendedInDate') sendedInDate: string, + @Param('sensor_uuid') sensor_uuid: string, + @Param('agregator_uuid') agregator_uuid: string, + @Param('math_time') math_time: string, + @Param('msg_type') msg_type: string, + @Param('msg_value') msg_value: string, + ): Promise | null> { + + const measure_create_data: MeasureCreateDTOLocalClass = { + sendedInDate: sendedInDate, + sensor_uuid: sensor_uuid, + agregator_uuid: agregator_uuid, + time: math_time, + type: msg_type, + value: msg_value, + } + + const res = await this.measuresService.create(measure_create_data); + + return res ? { code: '200' } : { code: '500' }; + } + @ApiOperation({ diff --git a/weather_platform/apps/py-tg-bot-weather-agent/main.py b/weather_platform/apps/py-tg-bot-weather-agent/main.py index a7cd620..f3a1091 100644 --- a/weather_platform/apps/py-tg-bot-weather-agent/main.py +++ b/weather_platform/apps/py-tg-bot-weather-agent/main.py @@ -10,9 +10,15 @@ import requests import telebot from langchain.agents import create_json_agent, AgentExecutor from langchain.agents.agent_toolkits import JsonToolkit +import os -# OPENAI_API = "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" -OPENAI_API = "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" +OPENAI_API = "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" + +os.environ["LANGCHAIN_TRACING_V2"] = "true" +os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com" +os.environ["LANGCHAIN_API_KEY"] = "ls__f7252ae2e7e4433d965ad37d94d63d6d" +project_name = "k-lab-weather" +os.environ["LANGCHAIN_PROJECT"] = "project_name" BOT_KEY = '6415742729:AAHVyDkHHF57ZsVd9gJjVtXjKE2M9CydzPk' @@ -21,10 +27,10 @@ WELCOME_MSG = """" Спроси что-нибудь у нашего бота 🙂 """ -# Weather AGW -AGW_PORT = 8045 -AGW_HOST = 'localhost' -AGW_URL = f"http://{AGW_HOST}:{AGW_PORT}/" +# AGW_PORT = 8045 +# AGW_HOST = 'localhost' +# AGW_URL = f"http://{AGW_HOST}:{AGW_PORT}/" +AGW_URL = f"https://gw.cg.k-lab.su/" bot = telebot.TeleBot(BOT_KEY) @@ -111,7 +117,8 @@ agent_chain = initialize_agent( max_iterations=4, agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True, - output_parser=output_parser + output_parser=output_parser, + project_name=project_name ) # print(get_weather_data_history_insight())