Skip to content

Commit 6e7973e

Browse files
committed
prompt engineering for system message and tools
1 parent fe4d889 commit 6e7973e

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/any_chatbot/agent.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616

1717

1818
def parse_args() -> argparse.Namespace:
19-
"""Parse command-line arguments for training and evaluation."""
2019
p = argparse.ArgumentParser()
2120

2221
p.add_argument(
2322
"--ask",
2423
type=str,
2524
default=(
26-
"What kinds (images, text docs, or excel sheets) are available in the documents I have provided to you? Use the functional call to retrieve information for each type first.\n\n"
27-
# "What colums does the excel have? once you found the answer, tell me there types too.\n\n"
28-
# "Once you have that answer, I want you to calculate the median for each column.\n\n"
29-
"When you don't know while files the user is talking about, use the functional call to retrieve what data is available with a general prompt.\n\n"
30-
"You can refine your semantic search queries and try multiple times with different queries until you resonably determine the data is not available on the given documents.\n\n"
31-
"Base your answers only on the retrieved information thorugh the functional call you have. You can retreive MULTIPLE TIMES"
25+
"What kinds (text docs, images, or excel sheets) are available in the documents I have provided to you?\n\n"
3226
),
33-
help="Your input to agent",
27+
help="Your input prompt to the agent.",
3428
)
3529
p.add_argument(
3630
"--load_data",
@@ -41,19 +35,19 @@ def parse_args() -> argparse.Namespace:
4135
"--thread_id",
4236
type=str,
4337
default=str(random.random()),
44-
help="Your conversation history ID. Different IDs save different chat histories with agent",
38+
help="Your conversation history ID. Different IDs save different chat histories with agent.",
4539
)
4640
p.add_argument(
4741
"--data_dir",
4842
type=Path,
4943
default=BASE / "data",
50-
help="Path to data dir where your files are uploaded",
44+
help="Path to data dir where your files are uploaded.",
5145
)
5246
p.add_argument(
5347
"--database_dir",
5448
type=Path,
5549
default=BASE / "data" / "generated_db" / "csv_excel_to_db.duckdb",
56-
help="Path to database dir where the sql version of CSV/EXCEL files are stored",
50+
help="Path to database dir where the sql version of CSV/EXCEL files are stored.",
5751
)
5852
return p.parse_args()
5953

src/any_chatbot/prompts.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
system_message = """
2-
You are an agent designed to interact with a SQL database.
3-
Given an input question, create a syntactically correct {dialect} query to run,
2+
You are a helpful and intelligent agent designed to conduct semantic search on the uploaded user documents
3+
and/or also interact with a SQL database. Your purpose is the answer the user's questions ACCURATELY and HONESTLY.
4+
5+
Whether you know or don't know what files the user is talking about,
6+
use the 'retrieve' functional call to retrieve what data is available to you with a prompt that best matches the user's inquiry.
7+
If you didn't find sufficient information, rewrite the query and try again
8+
until you can resonably determine that the needed data is simply not available.
9+
Base your answers ONLY on the retrieved information thorugh the functional calls you have.
10+
11+
If you think the user's prompt could be better answered through SQL querying,
12+
create a syntactically correct {dialect} query to run,
413
then look at the results of the query and return the answer. Unless the user
514
specifies a specific number of examples they wish to obtain, always limit your
615
query to at most {top_k} results.
@@ -12,6 +21,8 @@
1221
You MUST double check your query before executing it. If you get an error while
1322
executing a query, rewrite the query and try again.
1423
24+
Utilize {dialect} queries to do most, if not all, mathematical operations for user inquires related to SQL data.
25+
1526
DO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the
1627
database.
1728

0 commit comments

Comments
 (0)