История изменений
Исправление rtxtxtrx, (текущая версия) :
А кто его напишет? Его нет… Решил я значит выпотрошить расширение аля blackbox ai. Ну думаю ну где кроме тестов смотреть какие он запросы шлет… Смотрю:
import { isCodeValid } from '../src/utils/extractors/utils';
require('jest');
test("AI Code Validation - Valid", () => {
expect(isCodeValid("function test() { return 1; }")).toBe(true);
expect(isCodeValid("function test() { return 1; }\nfunction test2() { return 1; }")).toBe(true);
});
test("AI Code Validation - Invalid", () => {
expect(isCodeValid("thisisnotcode")).toBe(false);
});
const testCases: [string, boolean][] = [['public int counter = 0;', true],
['Toast msg;', true],
['public int counter = 0;', true],
/// ...
VALUE()`, true],
['SELECT COUNT(CompanyID) FROM email_archive WHERE attachment = \'\'', true],
['SELECT COUNT(CompanyID) FROM email_archive', true],
['I have joined two tables via CompanyID to get the count of those attachment that have null and those that are not null. I have then calculated the percentage and to the result I have concatenated \'%\' string.', false]
];
test("Testing for 95% of tests to be valid", () => {
let succeeded = 0;
let failed = 0;
for (let i = 0; i < testCases.length; i++) {
const testCase = testCases[i];
const result = isCodeValid(testCase[0]);
result == testCase[1] ? succeeded++ : failed++;
}
expect(succeeded).toBeGreaterThan(testCases.length * 0.95);
});
Там тесты - это просто проверка содержат ли строки волшебные слова… Сам запрос не сложен:
http POST https://www.blackbox.ai/api/chat \
messages:='[{"id": "6cdrFCv", "content": "Привет, мир!", "role": "user"}]' \
id='6clrFCv' \
previewToken:=null \
userId='0d264665-73ae-498f-aa3f-4b7b65997963' \
codeModelMode:=true \
agentMode:='[]' \
trendingAgentMode:='[]' \
isMicMode:=false \
isChromeExt:=false \
githubToken:=null \
webSearchMode:=false \
maxTokens:=10240
HTTP/2 200
date: Sun, 20 Oct 2024 02:58:58 GMT
content-type: text/plain; charset=utf-8
cf-ray: <cut>-HEL
cf-cache-status: DYNAMIC
set-cookie: sessionId=<cut>; Path=/; Expires=Fri, 19 Oct 2029 02:58:58 GMT
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
rndr-id: <cut>
x-experimental-stream-data: false
x-render-origin-server: Render
server: cloudflare
alt-svc: h3=":443"; ma=86400
$@$v=undefined-rv1$@$Привет! Как я могу помочь тебе сегодня?
Автоподстановка не работает:
http https://www.useblackbox.io/autocomplete userId='0d264665-73ae-498f-aa3f-4b7b65997963' textInput="document.getE" source="visual studio"
{
"status": "success",
"response": ""
}
Но то старое расширение было…
Из нового я ключи какие-то выдрал:
~/workspace/hacking
(.venv) ❯ vim blackbox.py
{'error': {'code': 'unsupported_country_region_territory', 'message': 'Country, region, or territory not supported', 'param': None, 'type': 'request_forbidden'}}
Press ENTER or type command to continue
~/workspace/hacking
(.venv) ❯ proxychains python blackbox.py
[proxychains] config file found: /home/sergey/workspace/hacking/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.17
[proxychains] Strict chain ... 127.0.0.1:1080 ... api.openai.com:443 ... OK
{'error': {'message': 'Incorrect API key provided: sk-o7gz6***************************************DoxJ. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
~/workspace/hacking
(.venv) ❯ cat blackbox.py
import requests
OPENAI_API_KEY = "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"
def describe_code(code):
url = "https://api.openai.com/v1/engines/davinci-codex/completions"
prompt = f'{code}\n"""\ndescribe the above code:'
headers = {
"Authorization": f"Bearer {OPENAI_API_KEY}",
"Content-Type": "application/json",
}
data = {
"prompt": prompt,
"temperature": 0,
"max_tokens": 170,
"top_p": 1.0,
"frequency_penalty": 0.0,
"presence_penalty": 0.0,
"stop": ['"""'],
}
response = requests.post(url, headers=headers, json=data)
return response.json()
# Пример использования
code_to_describe = """
def add(a, b):
return a + b
"""
description = describe_code(code_to_describe)
print(description)
Исправление rtxtxtrx, :
А кто его напишет? Его нет… Решил я значит выпотрошить расширение аля blackbox ai. Ну думаю ну где кроме тестов смотреть какие он запросы шлет… Смотрю:
import { isCodeValid } from '../src/utils/extractors/utils';
require('jest');
test("AI Code Validation - Valid", () => {
expect(isCodeValid("function test() { return 1; }")).toBe(true);
expect(isCodeValid("function test() { return 1; }\nfunction test2() { return 1; }")).toBe(true);
});
test("AI Code Validation - Invalid", () => {
expect(isCodeValid("thisisnotcode")).toBe(false);
});
const testCases: [string, boolean][] = [['public int counter = 0;', true],
['Toast msg;', true],
['public int counter = 0;', true],
/// ...
VALUE()`, true],
['SELECT COUNT(CompanyID) FROM email_archive WHERE attachment = \'\'', true],
['SELECT COUNT(CompanyID) FROM email_archive', true],
['I have joined two tables via CompanyID to get the count of those attachment that have null and those that are not null. I have then calculated the percentage and to the result I have concatenated \'%\' string.', false]
];
test("Testing for 95% of tests to be valid", () => {
let succeeded = 0;
let failed = 0;
for (let i = 0; i < testCases.length; i++) {
const testCase = testCases[i];
const result = isCodeValid(testCase[0]);
result == testCase[1] ? succeeded++ : failed++;
}
expect(succeeded).toBeGreaterThan(testCases.length * 0.95);
});
Там тесты - это просто проверка содержат ли строки волшебные слова… Сам запрос не сложен:
http POST https://www.blackbox.ai/api/chat \
messages:='[{"id": "6cdrFCv", "content": "Привет, мир!", "role": "user"}]' \
id='6clrFCv' \
previewToken:=null \
userId='0d264665-73ae-498f-aa3f-4b7b65997963' \
codeModelMode:=true \
agentMode:='[]' \
trendingAgentMode:='[]' \
isMicMode:=false \
isChromeExt:=false \
githubToken:=null \
webSearchMode:=false \
maxTokens:=10240
HTTP/2 200
date: Sun, 20 Oct 2024 02:58:58 GMT
content-type: text/plain; charset=utf-8
cf-ray: <cut>-HEL
cf-cache-status: DYNAMIC
set-cookie: sessionId=<cut>; Path=/; Expires=Fri, 19 Oct 2029 02:58:58 GMT
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
rndr-id: <cut>
x-experimental-stream-data: false
x-render-origin-server: Render
server: cloudflare
alt-svc: h3=":443"; ma=86400
$@$v=undefined-rv1$@$Привет! Как я могу помочь тебе сегодня?
Автоподстановка не работает:
http https://www.useblackbox.io/autocomplete userId='0d264665-73ae-498f-aa3f-4b7b65997963' textInput="document.getE" source="visual studio"
{
"status": "success",
"response": ""
}
Исходная версия rtxtxtrx, :
А кто его напишет? Его нет… Решил я значит выпотрошить расширение аля blackbox ai. Ну думаю ну где кроме тестов смотреть какие он запросы шлет… Смотрю:
import { isCodeValid } from '../src/utils/extractors/utils';
require('jest');
test("AI Code Validation - Valid", () => {
expect(isCodeValid("function test() { return 1; }")).toBe(true);
expect(isCodeValid("function test() { return 1; }\nfunction test2() { return 1; }")).toBe(true);
});
test("AI Code Validation - Invalid", () => {
expect(isCodeValid("thisisnotcode")).toBe(false);
});
const testCases: [string, boolean][] = [['public int counter = 0;', true],
['Toast msg;', true],
['public int counter = 0;', true],
/// ...
VALUE()`, true],
['SELECT COUNT(CompanyID) FROM email_archive WHERE attachment = \'\'', true],
['SELECT COUNT(CompanyID) FROM email_archive', true],
['I have joined two tables via CompanyID to get the count of those attachment that have null and those that are not null. I have then calculated the percentage and to the result I have concatenated \'%\' string.', false]
];
test("Testing for 95% of tests to be valid", () => {
let succeeded = 0;
let failed = 0;
for (let i = 0; i < testCases.length; i++) {
const testCase = testCases[i];
const result = isCodeValid(testCase[0]);
result == testCase[1] ? succeeded++ : failed++;
}
expect(succeeded).toBeGreaterThan(testCases.length * 0.95);
});
Там тесты - это просто проверка содержат ли строки волшебные слова… Сам запрос не сложен:
http POST https://www.blackbox.ai/api/chat \
messages:='[{"id": "6cdrFCv", "content": "Привет, мир!", "role": "user"}]' \
id='6clrFCv' \
previewToken:=null \
userId='0d264665-73ae-498f-aa3f-4b7b65997963' \
codeModelMode:=true \
agentMode:='[]' \
trendingAgentMode:='[]' \
isMicMode:=false \
isChromeExt:=false \
githubToken:=null \
webSearchMode:=false \
maxTokens:=10240
HTTP/2 200
date: Sun, 20 Oct 2024 02:58:58 GMT
content-type: text/plain; charset=utf-8
cf-ray: <cut>-HEL
cf-cache-status: DYNAMIC
set-cookie: sessionId=<cut>; Path=/; Expires=Fri, 19 Oct 2029 02:58:58 GMT
vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Url, Accept-Encoding
rndr-id: <cut>
x-experimental-stream-data: false
x-render-origin-server: Render
server: cloudflare
alt-svc: h3=":443"; ma=86400
$@$v=undefined-rv1$@$Привет! Как я могу помочь тебе сегодня?