This file contains 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
from fastapi import FastAPI, HTTPException, Depends # pip install fastapi uvicorn | |
from pydantic import BaseModel | |
import mysql.connector # pip install mysql-connector-python | |
db_config = { | |
"host": "localhost", | |
"user": "root", | |
"password": "", | |
"database": "exemplo" | |
} |
This file contains 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
<?php | |
namespace FastPHP\Attributes; | |
#[\Attribute(\Attribute::TARGET_METHOD)] | |
class Route | |
{ | |
public string $method; | |
public string $path; | |
public function __construct(string $method, string $path) |
This file contains 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
<?php | |
namespace FastPHP; | |
use FastPHP\Attributes\Get; | |
use FastPHP\Attributes\Post; | |
class FastPHP | |
{ | |
private array $routes = []; |
This file contains 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
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
model_name = "output/lei_n_15_022_2024_full_training" | |
model = AutoModelForCausalLM.from_pretrained(model_name, device_map='auto') | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) | |
messages = [ | |
{ |
This file contains 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
from datasets import load_dataset | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
from trl import SFTTrainer, SFTConfig | |
import os, torch | |
torch.cuda.empty_cache() | |
os.environ['PYTORCH_CUDA_ALLOC_CONF'] = 'expandable_segments:True' | |
os.environ['WANDB_MODE'] = 'disabled' |
This file contains 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
"Create a vibrant and eye-catching YouTube thumbnail. The background should be split into two sections: one side featuring a futuristic AI theme with glowing neural networks, circuits, or lines of code, and the other side showing a legal theme with symbols like a justice scale ⚖️, a gavel, or a law book. In the center, include a person or avatar with closely shaved hair (like a buzz cut, machine level 1), wearing glasses, and pointing at the divide with a confident or excited expression. Add bold, large text that reads 'TREINE SUA IA' in bright yellow and white, with a smaller subtitle 'Usando Python' below in a clear, professional font. Use dynamic colors like blue, yellow, and red to make the design pop, and include subtle effects like a glow or burst around the text to draw attention." |
This file contains 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
// Seleciona todos os elementos <code> na página | |
var finalResult = JSON.stringify( | |
Array.from(document.querySelectorAll('code')) | |
.map(function(el) { | |
var textContent = el.textContent; | |
// Usa regex para encontrar todos os pares "prompt" e "response" válidos | |
var matches = [...textContent.matchAll(/"prompt"\s*:\s*"([^"]*?)",\s*"response"\s*:\s*"([^"]*?)"/g)]; | |
// Converte os pares encontrados em objetos |
This file contains 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 numpy as np | |
import urllib.request | |
# Ler os dados do CSV | |
url = 'https://gist.githubusercontent.com/celsowm/35fb4f6d5a9590fce2c79367e6f31a13/raw/853288d17afc03e6cc67c819659d0da60d74b2f5/diabetes.csv' | |
dados = np.genfromtxt(urllib.request.urlopen(url), delimiter=',', skip_header=1) | |
X = dados[:, :3] # Entradas: fumante, obeso, pratica_exercicios | |
y = dados[:, 3:] # Saída: diabetico | |
# Inicializar pesos aleatórios |
This file contains 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
pip install playwright | |
python -m playwright install |
This file contains 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
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
model_name = "Qwen/Qwen2.5-0.5B-Instruct" | |
model = AutoModelForCausalLM.from_pretrained(model_name, device_map='auto') | |
tokenizer = AutoTokenizer.from_pretrained(model_name) | |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) | |
messages = [ |
NewerOlder