Files
privateGPT/private_gpt/components/tools/tool_placeholders.py
Javier Martinez 21d42fd97a feat: code execution v4 (#2295)
* feat: add bundle to remove

* fix: spaces

* feat: add xml render as skill spec

* feat: add skill volume root to cache

* fix: deduplicate values

* fix: change the mount path to skill_id

* fix: use different paths

* feat: add principal

(cherry picked from commit 5db64fe721d5706440ce9f342b1388ffe742bc16)

# Conflicts:
#	private_gpt/components/code_execution/base.py
#	private_gpt/components/code_execution/code_execution_component.py
#	private_gpt/components/code_execution/local.py
#	private_gpt/components/environment/manager.py
#	private_gpt/components/tools/builders/bash_tool_builder.py
#	private_gpt/components/tools/builders/text_editor_tool_builder.py
#	private_gpt/components/tools/processors/bash_processor.py

* fix: mypy

...

* fix: config

* fix: sandbox config

* feat: add forward cookies

* fix: loop

* feat: add present server

* feat: add feature flag for tools

* refactor: move principal to another better place

* feat: add api key principal

* docs: fix docs

* docs: add present server

* fix: principal

* fix: mypy

* fix: avoid to block the loop

* fix: blocks in expansion

* fix: remove maximum concurrent users

...

* fix: multiplexer

* fix: readers

* fix: more fixes

...

* fix: impl

* feat: tool scheduler

* feat: add adaptative

* feat: add chat worker

* fix: config

* fix: max

* feat: add chat/tools workers

* fix: mypy

* feat: add generic scheduler

* fix: get result

* feat: do serializable the tool executor

* fix: tools

* fix: config

* fix: config

* fix: args

* fix: config

* fix: serializer

* Revert "fix: blocks in expansion"

This reverts commit a2110f94a8.

* fix: unify all logic

* feat: add ingestion scheduler

* fix: settings

* fix: config

* feat: add arq worker to chat

* fix: arq worker

* fix: add nest

* fix: mypy

* fix: await

* fix: script stress

* fix: tokenizer

* fix: chat scheduler

* fix: mypy

* fix: add async tokenizer

* fix: improve condense

* fix: tool scheduler

* feat: add initial real async chat worker

* fix: mypy

* fix: do resumable local executor

...

...

...

fix: revert usleess changes

fix: remove parent chat job

fix: refactor

fix: loop

ref: rename models

fix: chat engine

fix: mypy

...

...

...

fix: fix deps

* fix: tests

* fix: tests

* ...

* fix: stream

* fix: config

* fix: scheduler

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Handle PGPT_WORKER_MODE=celery in health check worker status

* fix: cancel

* fix: arch

* fix: test ingestion

* fix: deserialization of chat messages

* fix: broken results

* fix: mypy

* fix: test

* fix: config

* fix: remove arq tool worker

* fix: output cls

* fix: preserve early resumable tool callbacks

* fix: preserve async tool result order

* refactor: address worker PR review comments

* fix: mypy

* test: colocate ARQ chat enqueue coverage

* fix: remove redis from tests

* fix: mypy

* fix: tests

* test: isolate chat mocks and cancellation timing

* fix: tests

* fix: tests

* fix: test

(cherry picked from commit f8ee460af2)

* fix: worker config

* test: remove flaky chat cancellation assertion

(cherry picked from commit 1115ff2349)

# Conflicts:
#	tests/server/chat/test_chat_routes.py

* fix: emit chat pings from stream listeners

* fix: don't duplciate the output

* fix: rss memory

...

* fix: pass the args

* fix: threads

* fix: websearch

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-07-15 13:05:23 +02:00

134 lines
4.3 KiB
Python

from typing import Any
from llama_index.core.tools import FunctionTool
from private_gpt.components.tools.tool_names import (
BASH_TOOL_NAME,
CODE_EXECUTION_TOOL_NAME,
DATABASE_QUERY_TOOL_NAME,
PRESENT_FILES_TOOL_NAME,
PRESENT_SERVER_TOOL_NAME,
SEMANTIC_SEARCH_TOOL_NAME,
SKILLS_TOOL_NAME,
SUMMARIZE_TOOL_NAME,
TABULAR_DATA_ANALYSIS,
TEXT_EDITOR_CREATE_TOOL_NAME,
TEXT_EDITOR_INSERT_TOOL_NAME,
TEXT_EDITOR_STR_REPLACE_TOOL_NAME,
TEXT_EDITOR_TOOL_NAME,
TEXT_EDITOR_VIEW_TOOL_NAME,
WEB_FETCH_TOOL_NAME,
WEB_SEARCH_TOOL_NAME,
)
def _placeholder_fn(*args: Any, **kwargs: Any) -> Any:
raise NotImplementedError("This is a placeholder function for a internal tool.")
def _placeholder_tool(name: str, description: str) -> FunctionTool:
return FunctionTool.from_defaults(
name=name,
description=description,
fn=_placeholder_fn,
return_direct=True,
)
SEMANTIC_SEARCH_TOOL_FN = _placeholder_tool(
SEMANTIC_SEARCH_TOOL_NAME,
"Perform semantic search over the files in the knowledge base. "
"Searches should only be done for a single topic at a time, so this tool should be "
"used multiple times to get better results.",
)
TABULAR_DATA_TOOL_FN = _placeholder_tool(
TABULAR_DATA_ANALYSIS,
"Perform Pandas queries over the files in the knowledge base. "
"It receives a query where it explain what to do, it will perform a search to find all tables"
"and it will run python code to generate aggregate queries, sorters, charts, etc.",
)
DATABASE_QUERY_TOOL_FN = _placeholder_tool(
DATABASE_QUERY_TOOL_NAME,
"Run a search using natural language against connected databases and return the results.",
)
SUMMARIZE_TOOL_FN = _placeholder_tool(
SUMMARIZE_TOOL_NAME,
"Summarize the content of the files in the knowledge base. "
"Summarization should be used to get a high level overview of the content of "
"the knowledge base, and should be used multiple times to get better results.",
)
WEB_FETCH_TOOL_FN = _placeholder_tool(
WEB_FETCH_TOOL_NAME,
"Extract text from a web by it's url."
"It will return the text content of the page in human readable format."
"This tool should only be used when the content of a website is needed, "
"not for general web search. The website url must use http or https protocol.",
)
WEB_SEARCH_TOOL_FN = _placeholder_tool(
WEB_SEARCH_TOOL_NAME,
"Search the web for relevant information."
"It will return a list of relevant links and a brief summary of each link."
"This tool should only be used when the content of a website is needed, "
"not for general web search. The website url must use http or https protocol.",
)
CODE_EXECUTION_TOOL_FN = _placeholder_tool(
CODE_EXECUTION_TOOL_NAME,
"Execute commands and manipulate files in the session workspace.",
)
BASH_TOOL_FN = _placeholder_tool(
BASH_TOOL_NAME,
"Execute bash commands in the session workspace.",
)
TEXT_EDITOR_TOOL_FN = _placeholder_tool(
TEXT_EDITOR_TOOL_NAME,
"View and edit files in the session workspace.",
)
TEXT_EDITOR_VIEW_TOOL_FN = _placeholder_tool(
TEXT_EDITOR_VIEW_TOOL_NAME,
"View a file or directory in the session workspace.",
)
TEXT_EDITOR_STR_REPLACE_TOOL_FN = _placeholder_tool(
TEXT_EDITOR_STR_REPLACE_TOOL_NAME,
"Replace a single exact string in a file.",
)
TEXT_EDITOR_CREATE_TOOL_FN = _placeholder_tool(
TEXT_EDITOR_CREATE_TOOL_NAME,
"Create a new file in the session workspace.",
)
TEXT_EDITOR_INSERT_TOOL_FN = _placeholder_tool(
TEXT_EDITOR_INSERT_TOOL_NAME,
"Insert text into a file after a given line number.",
)
PRESENT_FILES_TOOL_FN = _placeholder_tool(
PRESENT_FILES_TOOL_NAME,
"Present one or more output files to the user after they have been created.",
)
PRESENT_SERVER_TOOL_FN = _placeholder_tool(
PRESENT_SERVER_TOOL_NAME,
(
"Expose an HTTP service running inside the sandbox on a given port and present "
"its URL to the user. Call this after starting a server (e.g. a web app, "
"Jupyter, Streamlit) so the user can open or interact with it. "
"Optionally pass an initial_path to deep-link to a specific route."
),
)
SKILLS_TOOL_FN = _placeholder_tool(
SKILLS_TOOL_NAME,
"Load, unload, and list skills available to the current conversation.",
)