TaskWeaver
TaskWeaver copied to clipboard
How to set a plugin (dataset from backend)
Instated of asking initially pull a data from 'time_series' table from 'sqlite://test.db' How can I set this (database) in backend when app loads then start directly asking questions.?
We would suggest wrap around the taskweaver and automatically send a request (e.g., pull the data) to Taskweaver on behalf of human when starting the services.
We would suggest wrap around the taskweaver and automatically send a request (e.g., pull the data) to Taskweaver on behalf of human when starting the services.
Can you please elaborate how to set this up in code? I want to work with one csv file that can be accessed from plugins and stays in memory in the session.
CodeInterpreter File Handling
To enable CodeInterpreter to access data, I supplied the complete file path, and the file was successfully read and processed. It is important to emphasize that the file must be reachable by the user executing TaskWeave and must have the necessary read permissions.
Plugins in the Application
-
sql_pull_data Plugin
- Source Code
- The path to the SQLite database is determined from an environment variable.
-
anomaly_detection Plugin
- Source Code
- The file is incorporated into the context.
Creating a custom plugin might prove more convenient than exploring alternatives. Consider specifying the full file path for CodeInterpreter, as it could enhance control and compatibility.
CodeInterpreter File Handling
To enable CodeInterpreter to access data, I supplied the complete file path, and the file was successfully read and processed. It is important to emphasize that the file must be reachable by the user executing TaskWeave and must have the necessary read permissions.
Plugins in the Application
sql_pull_data Plugin
- Source Code
- The path to the SQLite database is determined from an environment variable.
anomaly_detection Plugin
- Source Code
- The file is incorporated into the context.
Creating a custom plugin might prove more convenient than exploring alternatives. Consider specifying the full file path for CodeInterpreter, as it could enhance control and compatibility.
Thanks for the response, looks more promising.
I have one Query here,
I have a SQL Db sitting on the Cloud and i am using similar Function to connect to it db = SQLDatabase.from_uri("SQL PATH")
I am Seeing this observation that when the CI calls the Plugin , it takes time to make connection every time.
I dont want to make connection every time i want to reuse the Connection so that i can reduce latency and not needing to connect to the DB every time the plugin gets called
Can some one suggest a solution where DB object is only instanciated once and Reused again in the plugins. Hence Reducing Latency
I have one Query here,
I have a SQL Db sitting on the Cloud and i am using similar Function to connect to it db = SQLDatabase.from_uri("SQL PATH")
I am Seeing this observation that when the CI calls the Plugin , it takes time to make connection every time.
I dont want to make connection every time i want to reuse the Connection so that i can reduce latency and not needing to connect to the DB every time the plugin gets called
Can some one suggest a solution where DB object is only instanciated once and Reused again in the plugins. Hence Reducing Latency
A simple way to achieve this is as follows:
@register_plugin
class SqlPullData(Plugin):
db = None
def __call__(self, query: str):
...
if db is None:
db = SQLDatabase.from_uri(self.config.get("sqlite_db_path"))
The connection will be created at the first time calling this plugin and reused in following calls.
Will revise the implementation later.
Thanks @liqul , One more question : Lets say i initialize it once and use it again, what if the connection is broken or it is stale.
what would be a best way to implement above logic while also handling scenarios where connection would be stale or lost?
This may be a bit going beyond developing the plugin. It is a common issue for all db access scenarios. I didn't investigate it and you can take a look at langchain's implementation details here.

