Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Create Llama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Create Llama
Commits
f29561cd
Commit
f29561cd
authored
9 months ago
by
leehuwuj
Browse files
Options
Downloads
Patches
Plain Diff
add cache to toolfactory load_tools
parent
442abae8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/components/engines/python/agent/tools/__init__.py
+10
-1
10 additions, 1 deletion
templates/components/engines/python/agent/tools/__init__.py
with
10 additions
and
1 deletion
templates/components/engines/python/agent/tools/__init__.py
+
10
−
1
View file @
f29561cd
import
os
import
yaml
import
json
import
importlib
from
cachetools
import
cached
,
LRUCache
from
llama_index.core.tools.tool_spec.base
import
BaseToolSpec
from
llama_index.core.tools.function_tool
import
FunctionTool
...
...
@@ -19,6 +20,14 @@ class ToolFactory:
}
@staticmethod
@cached
(
LRUCache
(
maxsize
=
100
),
key
=
lambda
tool_type
,
tool_name
,
config
:
(
tool_type
,
tool_name
,
json
.
dumps
(
config
,
sort_keys
=
True
),
),
)
def
load_tools
(
tool_type
:
str
,
tool_name
:
str
,
config
:
dict
)
->
list
[
FunctionTool
]:
source_package
=
ToolFactory
.
TOOL_SOURCE_PACKAGE_MAP
[
tool_type
]
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment