This file contains hidden or 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
| import json | |
| import logging | |
| from datetime import datetime | |
| from typing import Any | |
| from sqlalchemy import create_engine, text | |
| logger = logging.getLogger("llm_logger") | |
| DEFAULT_DATABASE_URL = ( |
This file contains hidden or 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
| EXTRACTION_PROMPT = """\ | |
| <system_prompt> | |
| You are an intelligent and disciplined AI assistant specializing in identifying and classifying Red-Line Statements (RLS) from the public statements of world leaders. Your job is to read a text in Russian and determine if it contains a Red-Line Statement (RLS), and if it does, break down that statement in a specific JSON format. | |
| - **CRITICAL:** Your response MUST ALWAYS be in valid JSON format. Any deviation from the format will make your output completely unusable. | |
| - **CRITICAL**: **Accuracy in JSON formatting is vital.** This includes proper use of double quotes ("") for strings, no quotes around numbers, and correct placement of brackets [], commas ,, and colons :. | |
| - **CRITICAL**: **Do not include any additional explanations or comments outside the JSON structure.** | |
| ### What is a Red-Line Statement (RLS)? |
This file contains hidden or 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
| # import | |
| sqlite3 -csv phrases.db ".import np-example.csv phrases_table" | |
| # export | |
| sqlite3 -header -csv phrases.db "select * from phrases_table limit 5;" > tracks.csv |
This file contains hidden or 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
| import functools | |
| def pop_item(di, *, first=True): | |
| if first: | |
| it = iter(di) | |
| else: | |
| it = iter(reversed(di)) | |
| key = next(it) | |
| return key, di.pop(key) |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| import os | |
| import logging | |
| import requests | |
| import pandas as pd | |
| from time import sleep | |
| KEY = os.environ.get("kmplus", "") | |
| KMP = "https://kmplus.ukravtodor.gov.ua/api/v1/kmp" | |
| ROUTE = "https://kmplus.ukravtodor.gov.ua/api/v1/route/id" |
This file contains hidden or 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
| import json | |
| import random | |
| import asyncio | |
| import aiohttp | |
| import pandas as pd | |
| SLEEP_RANGE = 0.4, 0.8 | |
| CONCURRENT_CONNECTIONS = 5 |