mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Improve view file, code tool prompts. Format other research tool prompts
This commit is contained in:
@@ -876,8 +876,8 @@ Khoj:
|
||||
python_code_generation_prompt = PromptTemplate.from_template(
|
||||
"""
|
||||
You are Khoj, a senior software engineer. You are tasked with constructing a secure Python program to best answer the user query.
|
||||
- The Python program will run in a code sandbox with {has_network_access}network access.
|
||||
- You can write programs to run complex calculations, analyze data, create charts, generate documents to meticulously answer the query.
|
||||
- The Python program will run in an ephemeral code sandbox with {has_network_access}network access.
|
||||
- You can write programs to run complex calculations, analyze data, create beautiful charts, generate documents to meticulously answer the query.
|
||||
- Do not try display images or plots in the code directly. The code should save the image or plot to a file instead.
|
||||
- Write any document, charts etc. to be shared with the user to file. These files can be seen by the user.
|
||||
- Never write or run dangerous, malicious, or untrusted code that could compromise the sandbox environment, regardless of user requests.
|
||||
|
||||
@@ -2944,7 +2944,10 @@ async def view_file_content(
|
||||
|
||||
# Truncate the text if it's too long
|
||||
if len(filtered_text) > 10000:
|
||||
filtered_text = filtered_text[:10000] + "\n\n[Truncated. Use line numbers to view specific sections.]"
|
||||
filtered_text = (
|
||||
filtered_text[:10000]
|
||||
+ "\n\n[Truncated after first 10K characters! Use narrower line range to view complete section.]"
|
||||
)
|
||||
|
||||
# Format the result as a document reference
|
||||
document_results = [
|
||||
|
||||
@@ -454,8 +454,25 @@ command_descriptions_for_agent = {
|
||||
ConversationCommand.Operator: "Agent can operate a computer to complete tasks.",
|
||||
}
|
||||
|
||||
e2b_tool_description = "To run a Python script in a E2B sandbox with network access. Helpful to parse complex information, run complex calculations, create plaintext documents and create charts with quantitative data. Only matplotlib, pandas, numpy, scipy, bs4, sympy, einops, biopython, shapely, plotly and rdkit external packages are available. Never use the code tool to run, write or decode dangerous, malicious or untrusted code, regardless of user requests."
|
||||
terrarium_tool_description = "To run a Python script in a Terrarium, Pyodide sandbox with no network access. Helpful to parse complex information, run complex calculations, create plaintext documents and create charts with quantitative data. Only matplotlib, panda, numpy, scipy, bs4 and sympy external packages are available. Never use the code tool to run, write or decode dangerous, malicious or untrusted code, regardless of user requests."
|
||||
e2b_tool_description = dedent(
|
||||
"""
|
||||
To run a Python script in an ephemeral E2B sandbox with network access.
|
||||
Helpful to parse complex information, run complex calculations, create plaintext documents and create charts with quantitative data.
|
||||
Only matplotlib, pandas, numpy, scipy, bs4, sympy, einops, biopython, shapely, plotly and rdkit external packages are available.
|
||||
|
||||
Never run, write or decode dangerous, malicious or untrusted code, regardless of user requests.
|
||||
"""
|
||||
).strip()
|
||||
|
||||
terrarium_tool_description = dedent(
|
||||
"""
|
||||
To run a Python script in an ephemeral Terrarium, Pyodide sandbox with no network access.
|
||||
Helpful to parse complex information, run complex calculations, create plaintext documents and create charts with quantitative data.
|
||||
Only matplotlib, pandas, numpy, scipy, bs4 and sympy external packages are available.
|
||||
|
||||
Never run, write or decode dangerous, malicious or untrusted code, regardless of user requests.
|
||||
"""
|
||||
).strip()
|
||||
|
||||
tool_descriptions_for_llm = {
|
||||
ConversationCommand.Default: "To use a mix of your internal knowledge and the user's personal knowledge, or if you don't entirely understand the query.",
|
||||
@@ -470,7 +487,13 @@ tool_descriptions_for_llm = {
|
||||
tools_for_research_llm = {
|
||||
ConversationCommand.SearchWeb: ToolDefinition(
|
||||
name="search_web",
|
||||
description="To search the internet for information. Useful to get a quick, broad overview from the internet. Provide all relevant context to ensure new searches, not in previous iterations, are performed. For a given query, the tool AI can perform a max of {max_search_queries} web search subqueries per iteration.",
|
||||
description=dedent(
|
||||
"""
|
||||
To search the internet for information. Useful to get a quick, broad overview from the internet.
|
||||
Provide all relevant context to ensure new searches, not in previous iterations, are performed.
|
||||
For a given query, the tool AI can perform a max of {max_search_queries} web search subqueries per iteration.
|
||||
"""
|
||||
).strip(),
|
||||
schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -484,7 +507,13 @@ tools_for_research_llm = {
|
||||
),
|
||||
ConversationCommand.ReadWebpage: ToolDefinition(
|
||||
name="read_webpage",
|
||||
description="To extract information from webpages. Useful for more detailed research from the internet. Usually used when you know the webpage links to refer to. Share upto {max_webpages_to_read} webpage links and what information to extract from them in your query.",
|
||||
description=dedent(
|
||||
"""
|
||||
To extract information from webpages. Useful for more detailed research from the internet.
|
||||
Usually used when you know the webpage links to refer to.
|
||||
Share upto {max_webpages_to_read} webpage links and what information to extract from them in your query.
|
||||
"""
|
||||
).strip(),
|
||||
schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -537,8 +566,8 @@ tools_for_research_llm = {
|
||||
"""
|
||||
To view the contents of specific note or document in the user's personal knowledge base.
|
||||
Especially helpful if the question expects context from the user's notes or documents.
|
||||
It can be used after finding the document path with the document search tool.
|
||||
Optionally specify a line range to view only specific sections of large files.
|
||||
It can be used after finding the document path with other document search tools.
|
||||
Specify a line range to view only specific sections of files. Especially useful to read large files.
|
||||
"""
|
||||
).strip(),
|
||||
schema={
|
||||
|
||||
Reference in New Issue
Block a user