Spaces:
Runtime error
Runtime error
Merge pull request #38 from EnvisionMindCa/codex/locate-method-for-llm-internet-search-with-execute_terminal
Browse files- README.md +12 -8
- src/config.py +5 -3
- src/tools.py +4 -1
README.md
CHANGED
@@ -6,11 +6,13 @@ database using Peewee. Histories are persisted per user and session so
|
|
6 |
conversations can be resumed with context. One example tool is included:
|
7 |
|
8 |
* **execute_terminal** – Executes a shell command inside a persistent Linux VM
|
9 |
-
with network access. Use it to read uploaded documents under ``/data
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
|
15 |
Sessions share state through an in-memory registry so that only one generation
|
16 |
can run at a time. Messages sent while a response is being produced are
|
@@ -19,9 +21,11 @@ pending response is cancelled and replaced with the new request.
|
|
19 |
|
20 |
The application injects a robust system prompt on each request. The prompt
|
21 |
guides the model to plan tool usage, execute commands sequentially and
|
22 |
-
verify results before replying.
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
|
26 |
## Usage
|
27 |
|
|
|
6 |
conversations can be resumed with context. One example tool is included:
|
7 |
|
8 |
* **execute_terminal** – Executes a shell command inside a persistent Linux VM
|
9 |
+
with network access. Use it to read uploaded documents under ``/data``, fetch
|
10 |
+
web content via tools like ``curl`` or run any other commands. The assistant
|
11 |
+
must invoke this tool to search online when unsure about a response. Output
|
12 |
+
from ``stdout`` and ``stderr`` is captured and returned. Commands run
|
13 |
+
asynchronously so the assistant can continue responding while they execute.
|
14 |
+
The VM is created when a chat session starts and reused for all subsequent
|
15 |
+
tool calls.
|
16 |
|
17 |
Sessions share state through an in-memory registry so that only one generation
|
18 |
can run at a time. Messages sent while a response is being produced are
|
|
|
21 |
|
22 |
The application injects a robust system prompt on each request. The prompt
|
23 |
guides the model to plan tool usage, execute commands sequentially and
|
24 |
+
verify results before replying. When the assistant is uncertain, it is directed
|
25 |
+
to search the internet with ``execute_terminal`` before giving a final answer.
|
26 |
+
The prompt is **not** stored in the chat history but is provided at runtime so
|
27 |
+
the assistant can orchestrate tool calls in sequence to fulfil the user's
|
28 |
+
request reliably.
|
29 |
|
30 |
## Usage
|
31 |
|
src/config.py
CHANGED
@@ -19,7 +19,9 @@ SYSTEM_PROMPT: Final[str] = (
|
|
19 |
"tool returns its result you will receive a tool message and must continue from "
|
20 |
"there. If the result arrives before your interim reply is complete, cancel the "
|
21 |
"reply and incorporate the tool output instead. Uploaded files live under /data "
|
22 |
-
"and are accessible via the execute_terminal tool.
|
23 |
-
"you
|
24 |
-
"
|
|
|
|
|
25 |
)
|
|
|
19 |
"tool returns its result you will receive a tool message and must continue from "
|
20 |
"there. If the result arrives before your interim reply is complete, cancel the "
|
21 |
"reply and incorporate the tool output instead. Uploaded files live under /data "
|
22 |
+
"and are accessible via the execute_terminal tool. When you are unsure about any "
|
23 |
+
"detail, you must use execute_terminal to search the internet or inspect files "
|
24 |
+
"before answering. Continue using tools until you have gathered everything "
|
25 |
+
"required to produce an accurate answer, then craft a clear and precise final "
|
26 |
+
"response that fully addresses the request."
|
27 |
)
|
src/tools.py
CHANGED
@@ -21,7 +21,10 @@ def set_vm(vm: LinuxVM | None) -> None:
|
|
21 |
def execute_terminal(command: str) -> str:
|
22 |
"""
|
23 |
Execute a shell command in a Ubuntu terminal.
|
24 |
-
Use this tool to inspect uploaded documents under ``/data
|
|
|
|
|
|
|
25 |
|
26 |
The command is executed with network access enabled. Output from both
|
27 |
``stdout`` and ``stderr`` is captured and returned. Commands are killed if
|
|
|
21 |
def execute_terminal(command: str) -> str:
|
22 |
"""
|
23 |
Execute a shell command in a Ubuntu terminal.
|
24 |
+
Use this tool to inspect uploaded documents under ``/data``, fetch web
|
25 |
+
content with utilities like ``curl`` or ``wget`` and run other commands.
|
26 |
+
The assistant must call this tool to search the internet whenever unsure
|
27 |
+
about any detail.
|
28 |
|
29 |
The command is executed with network access enabled. Output from both
|
30 |
``stdout`` and ``stderr`` is captured and returned. Commands are killed if
|