nolanzandi commited on
Commit
535f75c
·
verified ·
1 Parent(s): dd82d0a

updates for link generation

Browse files
functions/chart_functions.py CHANGED
@@ -33,7 +33,7 @@ def table_generation_func(data: List[str], session_hash):
33
  csv_path = f'{dir_path}/data.csv'
34
  df.to_csv(csv_path)
35
  download_path = f'gradio_api/file/temp/{session_hash}/data.csv'
36
- html_table = df.to_html() + f'<p>Download as a <a href="{download_path}">CSV</a></p>'
37
  print(html_table)
38
 
39
  return {"reply": html_table}
 
33
  csv_path = f'{dir_path}/data.csv'
34
  df.to_csv(csv_path)
35
  download_path = f'gradio_api/file/temp/{session_hash}/data.csv'
36
+ html_table = df.to_html() + f'<p>Download as a <a href="{download_path}">CSV file</a></p>'
37
  print(html_table)
38
 
39
  return {"reply": html_table}
functions/chat_functions.py CHANGED
@@ -61,7 +61,9 @@ def chatbot_with_fc(message, history, session_hash):
61
  else:
62
  messages = [
63
  ChatMessage.from_system(
64
- "You are a helpful and knowledgeable agent who has access to an SQLite database which has a table called 'data_source'. You also have access to a chart API that uses chart.js dictionaries formatted as a string to generate charts and graphs."
 
 
65
  )
66
  ]
67
  messages.append(ChatMessage.from_user(message))
 
61
  else:
62
  messages = [
63
  ChatMessage.from_system(
64
+ """You are a helpful and knowledgeable agent who has access to an SQLite database which has a table called 'data_source'.
65
+ You also have access to a chart API that uses chart.js dictionaries formatted as a string to generate charts and graphs.
66
+ You also have access to a function, called table_generation_func, that builds table formatted html and generates a link to download as CSV."""
67
  )
68
  ]
69
  messages.append(ChatMessage.from_user(message))
tools.py CHANGED
@@ -37,7 +37,10 @@ def tools_call(session_hash):
37
  "type": "function",
38
  "function": {
39
  "name": "chart_generation_func",
40
- "description": f"This a chart generation tool useful to generate charts and graphs from queried data from our SQL table called 'data_source with the following Columns: {columns}. Returns an iframe string which will be displayed inline in our chat window. Do not edit the string returned from the chart_generation_func function in any way and display it fully to the user in the chat window. You can add your own text supplementary to it for context if desired.",
 
 
 
41
  "parameters": {
42
  "type": "object",
43
  "properties": {
@@ -63,8 +66,7 @@ def tools_call(session_hash):
63
  'data_source with the following Columns: {columns}. Returns an html string generated from the pandas library and pandas.to_html()
64
  function which will be displayed inline in our chat window. There will also be a link to download the CSV included in the HTML string.
65
  Do not change or edit this link in any way. Do not edit the HTML returned by the function in any way.
66
- Do not edit the string returned from the table_generation_func function in any way and display it fully to the user in the chat window.
67
- You can add your own text next to the returned string for context if desired.""",
68
  "parameters": {
69
  "type": "object",
70
  "properties": {
 
37
  "type": "function",
38
  "function": {
39
  "name": "chart_generation_func",
40
+ "description": f"""This a chart generation tool useful to generate charts and graphs from queried data from our SQL table called 'data_source
41
+ with the following Columns: {columns}. Returns an iframe string which will be displayed inline in our chat window. Do not edit the string returned
42
+ from the chart_generation_func function in any way and display it fully to the user in the chat window. You can add your own text supplementary
43
+ to it for context if desired.""",
44
  "parameters": {
45
  "type": "object",
46
  "properties": {
 
66
  'data_source with the following Columns: {columns}. Returns an html string generated from the pandas library and pandas.to_html()
67
  function which will be displayed inline in our chat window. There will also be a link to download the CSV included in the HTML string.
68
  Do not change or edit this link in any way. Do not edit the HTML returned by the function in any way.
69
+ Do not edit the string returned from the table_generation_func function in any way and display it fully to the user in the chat window.""",
 
70
  "parameters": {
71
  "type": "object",
72
  "properties": {