Closed twtester2 closed 7 months ago
We currently don't support this. If you need this feature, you can modify the code inside code interpreter adding the custom code before the generated code before sending it to the executor.
close inactive issues
Is your feature request related to a problem? Please describe. I have a Python script that I wrote. I want the script to run every time I start a session. Therefore, it would be nice to avoid having to go through the LLM, code interpreter, etc. because LLM can give stochastic results, and it's simpler and faster to just run the code.
Describe the solution you'd like I would like to be able to send a message to the kernel manager, such that a Python script in TaskWeaver/project/custom_code will run every time a session starts.
Describe alternatives you've considered I defined a new function in code executor:
Then I tried using the code executor in TaskWeaver/taskweaver/session/session.py initialization as follows: self.code_executor.execute_restclient("1", "persistent_variable= 23")
This appears to work successfully, because I can make other calls to self.code_executor.execute_restclient that will see the variable. For example CLI output:
However, when I send another message using session.send_message(message), e.g. "print the value of the variable persistent_variable", I get the following error:
Additional context The purpose of starting the same function every time is to initialize a class in the kernel context so that it can be used every time by other plugins. I want the code to run deterministically without affecting other parts of TaskWeaver, e.g. the number of conversation rounds, etc.