Openai
How to work with large language models | OpenAI Cookbook
Large language models are functions that map text to text. Given an input string of text, a large language model predicts the text that s...
Руководства, библиотеки и примеры кодов для выполнения различных задач с API OpenAI
Полезное:
Библиотеки:
Пример транскрибации
import requests
import base64
import os
import json
# Load the API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY")
def process_audio_with_gpt_4o(base64_encoded_audio, output_modalities, system_prompt):
# Chat Completions API end point
url = "https://api.openai.com/v1/chat/completions"
# Set the headers
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
# Construct the request data
data = {
"model": "gpt-4o-audio-preview",
"modalities": output_modalities,
"audio": {
"voice": "alloy",
"format": "wav"
},
"messages": [
{
"role": "system",
"content": system_prompt
},
{
"role": "user",
"content": [
{
"type": "input_audio",
"input_audio": {
"data": base64_encoded_audio,
"format": "wav"
}
}
]
}
]
}
request_response = requests.post(url, headers=headers, data=json.dumps(data))
if request_response.status_code == 200:
return request_response.json()
else:
print(f"Error {request_response.status_code}: {request_response.text}")
return
audio_wav_path = "./sounds/keynote_recap.wav"
# Read the WAV file and encode it to base64
with open(audio_wav_path, "rb") as audio_file:
audio_bytes = audio_file.read()
english_audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
modalities = ["text"]
prompt = "The user will provide an audio file in English. Transcribe the audio to English text, word for word. Only provide the language transcription, do not include background noises such as applause. "
response_json = process_audio_with_gpt_4o(english_audio_base64, modalities, prompt)
english_transcript = response_json['choices'][0]['message']['content']
print(english_transcript)
#openai #api #cheatsheet #llm
Please open Telegram to view this post
VIEW IN TELEGRAM
❤1
Недавно был пост об отличном сервисе Weakpass у которого в наличии абсолютно бесплатный API
Прикрутил к боту Password lookup (MD5, NTLM, SHA1 или SHA256)
import requests
from aiogram import Router, F
from aiogram.types import Message
import logging
import app.config.cfg as cfg
import json
router: Router = Router()
def check_hash_string(hash_string: str):
try:
headers = {'Content-Type': 'application/json'}
url = requests.get(f'https://weakpass.com/api/v1/search/{hash_string}.json', headers=headers)
output = json.loads(url.text)
hash_info = json.dumps(output, indent=2)
return hash_info
except Exception as e:
logging.warning(e)
@router.message(F.text.startswith(cfg.all_commands['check_hash']))
async def check_hash(message: Message):
try:
msg = message.text.split()
if len(msg) == 2:
await message.answer(f'<b>{check_hash_string(msg[1])}</b>', disable_web_page_preview=True)
else:
await message.answer(f'Пример:\n<code>!check_hash 5f4dcc3b5aa765d61d8327deb882cf99</code>')
except Exception as e:
logging.warning(e)
Работает в чате канала
!check_hash 5f4dcc3b5aa765d61d8327deb882cf99#weakpass #api #bot #python
Please open Telegram to view this post
VIEW IN TELEGRAM
Платформа с открытым исходным кодом для обмена, оценки, улучшения и управления правилами обнаружения (YARA, Sigma, Suricata и др.) с поддержкой API
Форматы:
Yara
Sigma
Zeek
Suricata
Crs
Nova
Elastic
Пример:
title: Encoded or Base64 Payload in HTTP POST to F5 Management API
id: f5-base64-upload-2025
description: Detects long base64 strings in HTTP POST body to management or shared endpoints.
author: abdulmyid@gmail.com
status: experimental
logsource:
product: webproxy
service: http
detection:
selection:
http.method: POST
url|contains:
- '/mgmt'
- '/shared'
http.request.body|contains_regexp: '[A-Za-z0-9+/]{200,}={0,2}'
condition: selection
level: medium
falsepositives:
- Legitimate encoded payloads (token exchanges, APIs).
#ti #rules #detection #soc #api
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3❤2😭1 1