Improve reliability of AI questions (#48)
Browse files- Improve reliability of AI questions (86d8725c407e90b05749218da63c124a439ee008)
- functions/chat_functions.py +12 -5
functions/chat_functions.py
CHANGED
@@ -13,7 +13,7 @@ def example_question_message(data_source, name, titles, schema):
|
|
13 |
f"""We have a SQLite database with the following {titles}.
|
14 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
15 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
16 |
-
that we can suggest that you believe will be insightful or helpful to a data
|
17 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
18 |
to process your response. No other response type or data structure will work."""],
|
19 |
|
@@ -21,7 +21,7 @@ def example_question_message(data_source, name, titles, schema):
|
|
21 |
f"""We have a PostgreSQL database with the following tables: {titles}.
|
22 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
23 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
24 |
-
that we can suggest that you believe will be insightful or helpful to a data
|
25 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
26 |
to process your response. No other response type or data structure will work."""],
|
27 |
|
@@ -30,7 +30,7 @@ def example_question_message(data_source, name, titles, schema):
|
|
30 |
The schema of these collections is: {schema}.
|
31 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
32 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
33 |
-
that we can suggest that you believe will be insightful or helpful to a data
|
34 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
35 |
to process your response. No other response type or data structure will work."""],
|
36 |
|
@@ -38,7 +38,7 @@ def example_question_message(data_source, name, titles, schema):
|
|
38 |
f"""We have a GraphQL API endpoint with the following types: {titles}.
|
39 |
We also have an AI agent with access to the same GraphQL API endpoint that will be performing data analysis.
|
40 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
41 |
-
that we can suggest that you believe will be insightful or helpful to a data
|
42 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
43 |
to process your response. No other response type or data structure will work."""]
|
44 |
|
@@ -59,7 +59,14 @@ def example_question_generator(session_hash, data_source, name, titles, schema):
|
|
59 |
|
60 |
example_response = chat_generator.run(messages=example_messages)
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
def system_message(data_source, titles, schema=""):
|
65 |
print("TITLES")
|
|
|
13 |
f"""We have a SQLite database with the following {titles}.
|
14 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
15 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
16 |
+
that we can suggest that you believe will be insightful or helpful to a data analyst looking for
|
17 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
18 |
to process your response. No other response type or data structure will work."""],
|
19 |
|
|
|
21 |
f"""We have a PostgreSQL database with the following tables: {titles}.
|
22 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
23 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
24 |
+
that we can suggest that you believe will be insightful or helpful to a data analyst looking for
|
25 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
26 |
to process your response. No other response type or data structure will work."""],
|
27 |
|
|
|
30 |
The schema of these collections is: {schema}.
|
31 |
We also have an AI agent with access to the same database that will be performing data analysis.
|
32 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
33 |
+
that we can suggest that you believe will be insightful or helpful to a data analyst looking for
|
34 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
35 |
to process your response. No other response type or data structure will work."""],
|
36 |
|
|
|
38 |
f"""We have a GraphQL API endpoint with the following types: {titles}.
|
39 |
We also have an AI agent with access to the same GraphQL API endpoint that will be performing data analysis.
|
40 |
Please return an array of seven strings, each one being a question for our data analysis agent
|
41 |
+
that we can suggest that you believe will be insightful or helpful to a data analyst looking for
|
42 |
data insights. Return nothing more than the array of questions because I need that specific data structure
|
43 |
to process your response. No other response type or data structure will work."""]
|
44 |
|
|
|
59 |
|
60 |
example_response = chat_generator.run(messages=example_messages)
|
61 |
|
62 |
+
response_text = example_response["replies"][0].text
|
63 |
+
start = response_text.index("[") + 1
|
64 |
+
end = response_text.index("]")
|
65 |
+
response_content = response_text[start:end]
|
66 |
+
response_list = '[' + response_content + ']'
|
67 |
+
print(response_list)
|
68 |
+
|
69 |
+
return response_list
|
70 |
|
71 |
def system_message(data_source, titles, schema=""):
|
72 |
print("TITLES")
|