Fix: defined default var for langchain cache path to enable custom path (issue 987) - #982
Fix: defined default var for langchain cache path to enable custom path (issue 987)#982m10mi5 wants to merge 2 commits into
Conversation
tpatel
left a comment
There was a problem hiding this comment.
Thanks for your code, I've added two comments.
|
|
||
| lc_cache_path = os.path.join(config_dir, ".langchain.db") | ||
|
|
||
| project_settings = ProjectSettings( |
There was a problem hiding this comment.
I believe you're missing something to change the project_config["lc_cache_path"] value, like:
| project_settings = ProjectSettings( | |
| project_config["lc_cache_path"] = project_config.get("lc_cache_path", lc_cache_path) | |
| project_settings = ProjectSettings( |
There was a problem hiding this comment.
the way i understand it and tested it locally, possible custom path will be picked up by toml_dict module here:
project_config = toml_dict.get("project", {})or will default to default value as proposed by my PR here
# default to "{config_dir}/.langchain.db"
lc_cache_path: Optional[str] = os.path.join(config_dir, ".langchain.db")There was a problem hiding this comment.
I think @necjamahim is right on this one. Could you please have another look @tpatel?
| set_llm_cache(SQLiteCache(database_path=config.project.lc_cache_path)) | ||
|
|
||
| if not os.path.exists(config.project.lc_cache_path): | ||
| if os.path.exists(config.project.lc_cache_path): |
There was a problem hiding this comment.
I'm not sure to understand why you've removed this?
There was a problem hiding this comment.
it is because previous line st_llm_cache generates sqlite db file at path
set_llm_cache(SQLiteCache(database_path=config.project.lc_cache_path))consequently in next line we want to inform cache was generated by testing if path exists and not the opposite. I hope I was clear - was trying not to use too many "if", "not" in the explaination
dokterbob
left a comment
There was a problem hiding this comment.
Thanks for your contribution @necjamahim!
I see where you're coming from; current config doesn't allow overriding the langchain cache configured through lc_cache_path, which seems hardcoded to {config_dir}/.langchain.db.
So this patch keeps the previously hardcoded value as a default and makes it configurable.
However, I don't see how your changes to set_chat_profiles come in. Could you please remove this from your patch and resolve any merge conflicts?
As soon as that's done I'll do a final manual test and I think we're good to go!
| ) | ||
| set_chat_profiles: Optional[ | ||
| Callable[[Optional["User"]], List["ChatProfile"]] | ||
| ] = None |
There was a problem hiding this comment.
How is this relevant to the issue at hand?
| cache = false | ||
|
|
||
| # Set langchain cache path (default is .langchain.db inside config dir) | ||
| # lc_cache_path = './.my-cache-path.db' |
There was a problem hiding this comment.
If this is a default config option, it seems better to uncomment it, in line with other default config options.
|
|
||
| lc_cache_path = os.path.join(config_dir, ".langchain.db") | ||
|
|
||
| project_settings = ProjectSettings( |
There was a problem hiding this comment.
I think @necjamahim is right on this one. Could you please have another look @tpatel?
When defining
lc_cache_pathand enabling cache in config:TypeError is thrown: