Введение
Chat.openai - это платформа, которая позволяет людям (неважно каких профессий) создавать контент(писать сценарии к роликам на тытрубе, детские сказки), искать информацию (иногда очень даже недостоверную),
и конечно же писать программы.
Настройка чат-бота
Первым шагом является регистрация учетной записи и создание нового чат-бота.(Требуется номер телефона и учетные записи Microsoft либо Google). Это можно сделать через веб-сайт chat.openai.com.
Chat.openai поддерживает множество языков программирования, включая Python, Java и C #.
Я лично использовал для написания этой статьи и эксперементировал с m/n/fASM, Rust, Powershell.
Написание кода
После того, как вы зарегистрировались, вы можете начать писать код для своего чат-бота:
(Можно использовать русский язык и OpenAI его прекрасно понимает, но пока лучше так)
МОЙ ЗАПРОС: use cargo to create rust project
To create a new Rust project using cargo, follow these steps:
This will create a new directory with the given project-name, and generate the basic files needed for a Rust project, including:
This will build and run your project, using the default main.rs as the entry point.
- Open a terminal and navigate to the directory where you want to create your project.
- Run the following command to create a new Rust project:
Код:
cargo new project-name
This will create a new directory with the given project-name, and generate the basic files needed for a Rust project, including:
- Cargo.toml: the configuration file for your project, which includes metadata about your project as well as its dependencies
- src/main.rs: the entry point for your project, which contains the main function
- src/lib.rs: a library crate file, which you can use if you want to create a library crate instead of an executable crate
- Change into the new project directory:
Код:
cd project-name
- Run the following command to build and run your project:
Код:
cargo run
This will build and run your project, using the default main.rs as the entry point.
- You can also use cargo build to just build the project, or cargo test to run the tests in your project (if you have any).
Данный ответ рассказал мне как создавать проект на языке Rust. Я начал разговор именно с этого запроса,
что бы убить двух зайцев - рассказать Боту о каком языке программирования мы будем говорить (а он обязательно
запомнит этот факт и сможет в любой момент поддержать беседу), во вторых ну я реально допустим не знаю,
как создать проект на расте
Моя задача не ставит за собой, то что Бот будет писать весь код
правильно и за меня, я вполне понимаю что библиотеки такого быстро развивающегося языка так же быстро
меняются - методы прыгают от одного класса к другому и тому подобное.
МОЙ ЗАПРОС: write function who recursive search files with txt extension on winapi, in folders and subfolders
Here's an example of a function that uses the Windows API to search for files with the .txt extension in a given folder and its subfolders:
This function takes a folder argument which is the path to the folder to search. It uses the FindFirstFileExA function to search for files in the given folder, and then the FindNextFileA function to search for subsequent files. If a file is found with the .txt extension, it is printed to the console. If a subdirectory is found, the function calls itself recursively to search the subdirectory.
I hope this helps! Let me know
Код:
use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;
use std::ptr;
use winapi::shared::minwindef::{FALSE, MAX_PATH, TRUE};
use winapi::um::fileapi::FindFirstFileExA;
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
use winapi::um::winbase::FindExInfoBasic;
use winapi::um::winnt::{FILE_ATTRIBUTE_DIRECTORY, FIND_FIRST_EX_LARGE_FETCH};
fn search_files(folder: &str) {
let mut path = OsString::from(folder);
path.push("\\*");
let path_ptr = path.as_ptr();
let mut handle = INVALID_HANDLE_VALUE;
let mut data: winapi::um::winbase::WIN32_FIND_DATAA = unsafe { std::mem::zeroed() };
loop {
handle = unsafe {
FindFirstFileExA(
path_ptr,
FindExInfoBasic,
&mut data as *mut _,
FIND_FIRST_EX_LARGE_FETCH,
ptr::null_mut(),
0,
)
};
if handle == INVALID_HANDLE_VALUE {
break;
}
let mut keep_searching = TRUE;
while keep_searching == TRUE {
let file_name = unsafe {
std::ffi::CStr::from_ptr(data.cFileName.as_ptr())
.to_str()
.unwrap()
};
if file_name == "." || file_name == ".." {
// Ignore current and parent directory
} else if data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0 {
// Recurse into subdirectory
let mut subfolder = OsString::from(folder);
subfolder.push("\\");
subfolder.push(file_name);
search_files(subfolder.to_str().unwrap());
} else if file_name.ends_with(".txt") {
// Found a text file!
println!("Found file: {}", file_name);
}
keep_searching = unsafe {
FindNextFileA(
handle,
&mut data as *mut _,
)
};
}
unsafe {
FindClose(handle);
}
break;
}
}
I hope this helps! Let me know
Справилась ли AIшка с этим ответом? Конечно же нет - а потому что библиотеки устарели, и всё равно
Вам нужно будет переделывать что то под себя.
Функции из одних пакетов перекочевали в другие, например:
winapi: :winbase::FindExInfoBasic убежала в winapi: :minwinbase::FindExInfoBasic |
Находим ее в поиске по docs.rs и заменяем в коде, но правда в том, что сам раст слишком изменился
с тех пор как наш AI накапливал свою базу данных.
Но по идее мы можем получать вполне удобоваримые результаты (без знания языка программирования)
если начнем использовать что то попроще и не так быстро изменяющееся, например тот же Powershell
МОЙ ЗАПРОС: u know powershell?
Yes, I am familiar with PowerShell. PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. It provides a powerful environment for managing and automating tasks, including those related to the operating system, file system, registry, and more. Do you have any specific questions about PowerShell?
МОЙ ЗАПРОС: use Powershell V3.0
To use PowerShell version 3.0, you will need to have a system that meets the following requirements:
This will display the version of PowerShell, as well as other information about the environment. If you need to upgrade to PowerShell 3.0 or later, you can download the latest version from the Microsoft website and install it on your system.
I hope this helps! Let me know if you have any other questions.
- Operating system: Windows 7 SP1, Windows Server 2008 R2 SP1, or later
- .NET Framework: .NET Framework 4.5 or later
Код:
$PSVersionTable
This will display the version of PowerShell, as well as other information about the environment. If you need to upgrade to PowerShell 3.0 or later, you can download the latest version from the Microsoft website and install it on your system.
I hope this helps! Let me know if you have any other questions.
МОЙ ЗАПРОС: on Powershell write me function to get system info about Username,
Computer name, Domain name of Active Directory (if Domain is empty return Nope),
and hardware id of computer, return like json
Код:
function Get-SystemInfo {
# Get the current user's name
$username = $env:USERNAME
# Get the current computer's name
$computerName = $env:COMPUTERNAME
# Get the current domain name, or "Nope" if not in a domain
$domain = (Get-WmiObject Win32_ComputerSystem).Domain
if (!$domain) {
$domain = "Nope"
}
# Get the hardware ID of the current computer
$hardwareId = (Get-WmiObject Win32_ComputerSystemProduct).UUID
# Return the information as a JSON object
@{
"Username" = $username
"ComputerName" = $computerName
"Domain" = $domain
"HardwareId" = $hardwareId
} | ConvertTo-Json
}
To use this function, simply type Get-SystemInfo and press Enter. It will return the system information as a JSON object.
Проверяем код в Powershell:
Прекрасно работает!
Проблемы и решения
А теперь очень клёвый совет Вам от меня, AI иногда тупит и упирается в лимит на 1000 символов (как и я)и зачастую обрывает функцию, для того что бы продолжить код, введите фразу
continue from codecodecodeкак на скриншоте что бы продолжить выдачу Вам остальной порции кода
Я до сих пор каждый день провожу различные эксперементы с этой моделью в разных областях,
это великолепный инструмент, такой же как и SD (
c хентаем конечно модельки юзаю
)
Не претендую ни на что, просто поделился с вами своими мыслями, может кому поможет
:winbase::FindExInfoBasic