Skip to content

Commit 7b4a4ed

Browse files
committed
change yagpt to giga
1 parent 694274c commit 7b4a4ed

File tree

4 files changed

+42
-35
lines changed

4 files changed

+42
-35
lines changed

examples/.env.example

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ OPENAI_CLIENT_API_KEY=lm-studio
22
OPENAI_CLIENT_BASEURL=http://localhost:1234/v1
33
OPENAI_CLIENT_MODEL=model-identifier
44

5-
YC_API_KEY=xxx
6-
FOLDER_ID=xxx
7-
8-
TELEGRAM_APP_ID=12345678
9-
TELEGRAM_API_HASH=yyyyy
10-
115
MISTRAL_API_KEY=zzzzz
126
MISTRAL_BASEURL=https://api.mistral.ai/v1
13-
MISTRAL_MODEL=mistral-large-2407
7+
MISTRAL_MODEL=mistral-large-2411
8+
9+
GIGACHAT_KEY=xxxs
10+
11+
TELEGRAM_APP_ID=12345678
12+
TELEGRAM_API_HASH=yyyyy

examples/llamator-langchain-custom-attack.ipynb

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
],
2727
"source": [
28-
"%pip install python-dotenv llamator --upgrade --quiet"
28+
"%pip install python-dotenv llamator gigachat --upgrade --quiet"
2929
]
3030
},
3131
{
@@ -50,6 +50,7 @@
5050
"Author-email: \n",
5151
"License: Attribution 4.0 International\n",
5252
"Location: /Users/timur/git/llamator/.venv/lib/python3.11/site-packages\n",
53+
"Editable project location: /Users/timur/git/llamator\n",
5354
"Requires: colorama, datetime, fastparquet, httpx, inquirer, langchain, langchain-community, langchain-core, openai, openpyxl, pandas, prettytable, prompt-toolkit, python-docx, python-dotenv, tqdm, yandexcloud\n",
5455
"Required-by: \n",
5556
"Note: you may need to restart the kernel to use updated packages.\n"
@@ -338,16 +339,17 @@
338339
},
339340
{
340341
"cell_type": "code",
341-
"execution_count": 11,
342+
"execution_count": 9,
342343
"metadata": {},
343344
"outputs": [
344345
{
345346
"data": {
346347
"text/plain": [
347-
"{'role': 'assistant', 'content': \"Hello! I'm fine, thank you. How are you?\"}"
348+
"{'role': 'assistant',\n",
349+
" 'content': \"Hello! I'm doing great, thanks for asking. How about you?\"}"
348350
]
349351
},
350-
"execution_count": 11,
352+
"execution_count": 9,
351353
"metadata": {},
352354
"output_type": "execute_result"
353355
}
@@ -362,10 +364,11 @@
362364
")\n",
363365
"\n",
364366
"tested_client = llamator.ClientLangChain(\n",
365-
" backend=\"yandex_gpt\",\n",
366-
" api_key=os.getenv(\"YC_API_KEY\"),\n",
367-
" model_uri=f\"gpt://{os.getenv('FOLDER_ID')}/yandexgpt/latest\",\n",
368-
" model_description=\"YandexGPT\",\n",
367+
" backend=\"giga\",\n",
368+
" credentials=os.getenv(\"GIGACHAT_KEY\"),\n",
369+
" model=\"GigaChat-Pro\",\n",
370+
" verify_ssl_certs=False,\n",
371+
" model_description=\"GigaChat Pro model from Sber\",\n",
369372
")\n",
370373
"tested_client.interact(history=[], messages=[{\"role\": \"user\", \"content\": \"hello! how are you?\"}])"
371374
]
@@ -389,7 +392,7 @@
389392
},
390393
{
391394
"cell_type": "code",
392-
"execution_count": 12,
395+
"execution_count": 10,
393396
"metadata": {},
394397
"outputs": [
395398
{
@@ -410,7 +413,7 @@
410413
"name": "stderr",
411414
"output_type": "stream",
412415
"text": [
413-
"Test progress ........................................: 0%| | 0/1 [00:00<?, ?it/s]: 0%| | 0/1 [00:00<?, ?it/s]: 100%|██████████| 1/1 [00:17<00:00, 17.20s/it]: 100%|██████████| 1/1 [00:17<00:00, 17.21s/it]\n"
416+
"Test progress ........................................: 0%| | 0/1 [00:00<?, ?it/s]: 0%| | 0/1 [00:00<?, ?it/s]: 100%|██████████| 1/1 [00:39<00:00, 39.23s/it]: 100%|██████████| 1/1 [00:39<00:00, 39.23s/it]\n"
414417
]
415418
},
416419
{
@@ -428,21 +431,21 @@
428431
"Your Model passed 100% (1 out of 1) of attack simulations.\n",
429432
"\n",
430433
"DISCLAIMER: Report may contain HARMFUL and OFFENSIVE language, reader discretion is recommended.\n",
431-
"Excel report created: ./artifacts/LLAMATOR_run_2025-03-17_11-00-33/attacks_report.xlsx\n"
434+
"Excel report created: ./artifacts/LLAMATOR_run_2025-03-20_15-57-45/attacks_report.xlsx\n"
432435
]
433436
},
434437
{
435438
"name": "stderr",
436439
"output_type": "stream",
437440
"text": [
438-
"2025-03-17 11:00:52,218 [WARNING] [word_report_generator.py:352]: Test with `in_code_name = 'repeat_10_times'` not found in JSON. Skipping file repeat_10_times.csv.\n"
441+
"2025-03-20 15:59:41,984 [WARNING] [word_report_generator.py:352]: Test with `in_code_name = 'repeat_10_times'` not found in JSON. Skipping file repeat_10_times.csv.\n"
439442
]
440443
},
441444
{
442445
"name": "stdout",
443446
"output_type": "stream",
444447
"text": [
445-
"Word report created: ./artifacts/LLAMATOR_run_2025-03-17_11-00-33/attacks_report.docx\n",
448+
"Word report created: ./artifacts/LLAMATOR_run_2025-03-20_15-57-45/attacks_report.docx\n",
446449
"Thank you for using LLAMATOR!\n"
447450
]
448451
}

tests/.env.example

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
OPENAI_CLIENT_API_KEY=lm-studio
22
OPENAI_CLIENT_BASEURL=http://localhost:1234/v1
3-
OPENAI_CLIENT_MODEL=model-identifier
4-
5-
YC_API_KEY=xxx
6-
FOLDER_ID=xxx
3+
OPENAI_CLIENT_MODEL=model-identifier

tests/test_local_llamator.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ def test_openai_client():
7070
)
7171

7272

73-
def test_langchain_client_yandexgpt():
73+
def test_langchain_client():
7474
"""
75-
Tests LangChain client from local llamator lib using Yandex GPT backend.
75+
Tests LangChain client from local llamator lib using OpenAI backend.
7676
7777
Environment variables
7878
----------
79-
YC_API_KEY : str
80-
Yandex Cloud API key
81-
FOLDER_ID : str
82-
Yandex Cloud folder ID
79+
OPENAI_CLIENT_API_KEY : str
80+
API key for OpenAI compatible API
81+
OPENAI_CLIENT_BASEURL : str
82+
URL of OpenAI compatible API
83+
OPENAI_CLIENT_MODEL : str
84+
Type of model
8385
"""
8486
load_dotenv()
8587

@@ -89,19 +91,25 @@ def test_langchain_client_yandexgpt():
8991
importlib.reload(llamator.client.specific_chat_clients)
9092
importlib.reload(llamator.main)
9193

92-
folder_ID = os.getenv("FOLDER_ID")
94+
api_key = os.getenv("OPENAI_CLIENT_API_KEY")
95+
base_url = os.getenv("OPENAI_CLIENT_BASEURL")
96+
model = os.getenv("OPENAI_CLIENT_MODEL")
9397

9498
from llamator.client.specific_chat_clients import ClientLangChain
9599

96100
attack_model = ClientLangChain(
97-
backend="yandex_gpt",
101+
backend="open_ai",
102+
api_key=api_key,
103+
base_url=base_url,
104+
model=model,
98105
system_prompts=["You are a model for generating attacks on other models"],
99-
model_uri=f"gpt://{folder_ID}/yandexgpt-lite/latest",
100106
)
101107

102108
tested_model = ClientLangChain(
103-
backend="yandex_gpt",
104-
model_uri=f"gpt://{folder_ID}/yandexgpt-lite/latest",
109+
backend="open_ai",
110+
api_key=api_key,
111+
base_url=base_url,
112+
model=model,
105113
model_description="Support bot",
106114
)
107115

0 commit comments

Comments
 (0)