Langroid

Latest version: v0.2.2

Safety actively analyzes 638452 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 24 of 41

0.1.126

For those wondering about the limitation in the Assistants API that we are only allowed to add a message with user role in the thread: this was a blocker to implementing caching of assistant responses (critical for cost-saving if you are repeatedly running the same conversation, e.g. in a test).

Then I realized -- if the role parameter is not allowed to be other than user, well then we instead simply stick our own role in the content field, and it works just fine! With this ability, we can now cache assistant responses in Langroid, see (https://github.com/langroid/langroid/blob/main/langroid/agent/openai_assistant.py#L447)

I keep an updated hash H of the conversation in the thread metadata, and cache the assistant response R at any stage so C[H] = R. On any run, before starting an assistant run, I look whether there is a cached R = C[H] , and if there is, I stick in R (the cached assistant response) onto the thread, as a msg with user role (since that is the only role allowed), but I prefix the content with "ASSISTANT:...". This assistant spoofing is handled in the expected way by the assistant, i.e. it treats the ASSISTANT-labled messages as if they were generated by the assistant. E.g. see this test (https://github.com/langroid/langroid/blob/main/tests/main/test_openai_assistant.py#L58)

0.1.125

Minor: Typo, AssitantTool => AssistantTool

0.1.124

Minor fix in task.py color_log

0.1.123

Minor: Add `notebook` flag in global settings, to use in `task.py` to suppress color logs,
which for some reason show up in the output cell rather than in log file (in Colab for example)

0.1.122

Minor: ChatAgent.enable_message() has new arg `include_default`
to indicate if the fn schema should include fields that have default values (default is True)

0.1.121

Minor: Bail when redis cache access causes "max clients reached" error

Page 24 of 41

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.