nolanzandi commited on
Commit
19b2962
·
verified ·
1 Parent(s): d9b72f5

Use Root URL

Browse files
Files changed (2) hide show
  1. functions/chart_functions.py +7 -1
  2. tools.py +2 -2
functions/chart_functions.py CHANGED
@@ -2,6 +2,12 @@ from typing import List
2
  from quickchart import QuickChart
3
  import pandas as pd
4
  from utils import TEMP_DIR
 
 
 
 
 
 
5
 
6
  def chart_generation_func(queries: List[str], session_hash):
7
  print("CHART GENERATION")
@@ -32,7 +38,7 @@ def table_generation_func(data: List[str], session_hash):
32
  df = pd.DataFrame(data)
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 target="_blank" href="{download_path}">CSV file</a></p>'
37
  print(html_table)
38
 
 
2
  from quickchart import QuickChart
3
  import pandas as pd
4
  from utils import TEMP_DIR
5
+ import os
6
+ from dotenv import load_dotenv
7
+
8
+ load_dotenv()
9
+
10
+ root_url = os.getenv("ROOT_URL")
11
 
12
  def chart_generation_func(queries: List[str], session_hash):
13
  print("CHART GENERATION")
 
38
  df = pd.DataFrame(data)
39
  csv_path = f'{dir_path}/data.csv'
40
  df.to_csv(csv_path)
41
+ download_path = f'{root_url}/gradio_api/file/temp/{session_hash}/data.csv'
42
  html_table = df.to_html() + f'<p>Download as a <a target="_blank" href="{download_path}">CSV file</a></p>'
43
  print(html_table)
44
 
tools.py CHANGED
@@ -65,8 +65,8 @@ def tools_call(session_hash):
65
  "description": f"""This an table generation tool useful to format data as a table from queried data from our SQL table called
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": {
 
65
  "description": f"""This an table generation tool useful to format data as a table from queried data from our SQL table called
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
+ This link should open in a new window. Do not edit the string returned by the function in any way when displaying to the user, as the user needs
69
+ all of the information returned by the function in it's exact state.""",
70
  "parameters": {
71
  "type": "object",
72
  "properties": {