Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ошибка при запуске агента с функциями на базе GigaChat #69

Closed
gritaro opened this issue Feb 16, 2024 · 2 comments

Comments

@gritaro
Copy link

gritaro commented Feb 16, 2024

Description: Ubuntu 22.04.3 LTS
Python 3.10.12
gigachain 0.1.4
gigachain-community 0.0.16
gigachain-core 0.1.17
gigachat 0.1.16

@Rai220 здравствуйте
Пытаюсь запускать код из примера https://github.com/ai-forever/gigachain/blob/master/docs/docs/modules/agents/how_to/gigachat_agent.ipynb

from langchain_community.chat_models import GigaChat
from langchain.tools import tool
import pyfiglet
from langchain.agents import AgentExecutor, create_gigachat_functions_agent
from langchain.schema import HumanMessage, SystemMessage, AIMessage

@tool
def draw_bunner(number: str) -> None:
    """Рисует баннер с текстом

    Args:
        number (str): Число, который нужно нарисовать на баннере
    """
    pyfiglet.print_figlet(number, font="epic")

giga = GigaChat(credentials=***", verify_ssl_certs=False, model="GigaChat-Plus")
new_tools = [draw_bunner]
agent = create_gigachat_functions_agent(giga, new_tools)
agent_executor = AgentExecutor(
    agent=agent,
    tools=new_tools,
    verbose=True,
)

agent_executor.invoke(
    {"input": "Найди курс биткоина в долларах и нарисуй это число на банере."}
)["output"]

В ответ получаю HTTP 422
Пробовал указывать разные модели, результат один
Стектрейс:

> Entering new AgentExecutor chain...
Traceback (most recent call last):
  File "/home/roman/GIT/hass/gigachain/1test-model.py", line 25, in <module>
    agent_executor.invoke(
  File "/usr/local/lib/python3.10/dist-packages/langchain/chains/base.py", line 162, in invoke
    raise e
  File "/usr/local/lib/python3.10/dist-packages/langchain/chains/base.py", line 156, in invoke
    self._call(inputs, run_manager=run_manager)
  File "/usr/local/lib/python3.10/dist-packages/langchain/agents/agent.py", line 1391, in _call
    next_step_output = self._take_next_step(
  File "/usr/local/lib/python3.10/dist-packages/langchain/agents/agent.py", line 1097, in _take_next_step
    [
  File "/usr/local/lib/python3.10/dist-packages/langchain/agents/agent.py", line 1097, in <listcomp>
    [
  File "/usr/local/lib/python3.10/dist-packages/langchain/agents/agent.py", line 1125, in _iter_next_step
    output = self.agent.plan(
  File "/usr/local/lib/python3.10/dist-packages/langchain/agents/agent.py", line 387, in plan
    for chunk in self.runnable.stream(inputs, config={"callbacks": callbacks}):
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 2424, in stream
    yield from self.transform(iter([input]), config, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 2411, in transform
    yield from self._transform_stream_with_config(
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 1497, in _transform_stream_with_config
    chunk: Output = context.run(next, iterator)  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 2375, in _transform
    for output in final_pipeline:
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 1035, in transform
    for chunk in input:
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 4145, in transform
    yield from self.bound.transform(
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/runnables/base.py", line 1045, in transform
    yield from self.stream(final, config, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/language_models/chat_models.py", line 250, in stream
    raise e
  File "/usr/local/lib/python3.10/dist-packages/langchain_core/language_models/chat_models.py", line 234, in stream
    for chunk in self._stream(
  File "/usr/local/lib/python3.10/dist-packages/langchain_community/chat_models/gigachat.py", line 235, in _stream
    for chunk in self._client.stream(payload):
  File "/usr/local/lib/python3.10/dist-packages/gigachat/client.py", line 246, in stream
    for chunk in stream_chat.sync(self._client, chat=chat, access_token=self.token):
  File "/usr/local/lib/python3.10/dist-packages/gigachat/api/stream_chat.py", line 90, in sync
    _check_response(response)
  File "/usr/local/lib/python3.10/dist-packages/gigachat/api/stream_chat.py", line 79, in _check_response
    raise ResponseError(response.url, response.status_code, b"", response.headers)
gigachat.exceptions.ResponseError: (URL('https://gigachat.devices.sberbank.ru/api/v1/chat/completions'), 422, b'', Headers([('server', 'nginx'), ('date', 'Fri, 16 Feb 2024 17:33:26 GMT'), ('content-type', 'application/json; charset=utf-8'), ('content-length', '70'), ('connection', 'keep-alive'), ('access-control-allow-credentials', 'true'), ('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization'), ('access-control-allow-methods', 'GET, POST, DELETE, OPTIONS'), ('access-control-allow-origin', 'https://beta.saluteai.sberdevices.ru'), ('x-request-id', 'b05d648f-ac12-4e13-86b3-dfcc782ed7bd'), ('x-session-id', '625022d4-55a7-417e-86e8-47432f94efd6'), ('allow', 'GET, POST'), ('strict-transport-security', 'max-age=31536000; includeSubDomains'), ('allow', 'GET, POST'), ('strict-transport-security', 'max-age=31536000; includeSubDomains')]))

@gritaro
Copy link
Author

gritaro commented Feb 17, 2024

btw, https://github.com/ai-forever/gigachain/blob/master/.github/ISSUE_TEMPLATE/bug-report.yml#L55

@Rai220
Copy link
Collaborator

Rai220 commented Feb 19, 2024

Здравствуйте! Нужен доступ именно к "модели с поддержкой функций", сейчас она есть только у ограниченного круга лиц в рамках тестирования. В ближайшее время будет доступна для всех. Если очень нужна до запуска, можно обратиться gigachat@sberbank.ru, вероятно помогут получить к ней доступ (но тут я не могу гарантировать).

@Rai220 Rai220 closed this as completed Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants