fetcher = ProxyFetcher(loop=loop)
Browse files- .vscode/settings.json +6 -0
- App/Chat/PoeChatrouter.py +2 -2
- App/Chat/utils/PoeBot.py +3 -2
- App/Music_1.json +0 -0
- App/TTS/text.py +17 -0
- App/TTS/text2sql.py +277 -0
- App/TTS/utils/HeyGen.py +38 -1
- App/TTS/utils/Initialize.py +1 -0
- App/app.py +4 -4
- App/voices.json +299 -0
- gradio-app.py +96 -0
- litellm_uuid.txt +1 -0
- queries.csv +185 -0
- sample.py +77 -0
.vscode/settings.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"[python]": {
|
| 3 |
+
"editor.defaultFormatter": "ms-python.black-formatter"
|
| 4 |
+
},
|
| 5 |
+
"python.formatting.provider": "none"
|
| 6 |
+
}
|
App/Chat/PoeChatrouter.py
CHANGED
|
@@ -31,10 +31,10 @@ async def fetch_predictions(data):
|
|
| 31 |
else:
|
| 32 |
# If an event loop is already running, use the current one
|
| 33 |
loop = asyncio.get_event_loop()
|
| 34 |
-
|
| 35 |
if not proxy_set:
|
| 36 |
try:
|
| 37 |
-
|
| 38 |
proxies = fetcher.get(
|
| 39 |
limit=10,
|
| 40 |
protocols=[Protocols.HTTP],
|
|
|
|
| 31 |
else:
|
| 32 |
# If an event loop is already running, use the current one
|
| 33 |
loop = asyncio.get_event_loop()
|
| 34 |
+
|
| 35 |
if not proxy_set:
|
| 36 |
try:
|
| 37 |
+
fetcher = ProxyFetcher(loop=loop)
|
| 38 |
proxies = fetcher.get(
|
| 39 |
limit=10,
|
| 40 |
protocols=[Protocols.HTTP],
|
App/Chat/utils/PoeBot.py
CHANGED
|
@@ -8,7 +8,7 @@ pattern = r"\!\[.*?\]\((.*?)\)"
|
|
| 8 |
|
| 9 |
client = PoeApi("sXvCnfYy8CHnXNTRlxhmVg==")
|
| 10 |
CHAT_CODE = ""
|
| 11 |
-
print(client.get_chat_history()["data"])
|
| 12 |
GEN_CODE = ""
|
| 13 |
|
| 14 |
|
|
@@ -63,4 +63,5 @@ async def GenerateImage(req: BotRequest):
|
|
| 63 |
client = PoeApi("sXvCnfYy8CHnXNTRlxhmVg==")
|
| 64 |
GEN_CODE = ""
|
| 65 |
counter += 1
|
| 66 |
-
|
|
|
|
|
|
| 8 |
|
| 9 |
client = PoeApi("sXvCnfYy8CHnXNTRlxhmVg==")
|
| 10 |
CHAT_CODE = ""
|
| 11 |
+
# print(client.get_chat_history()["data"])
|
| 12 |
GEN_CODE = ""
|
| 13 |
|
| 14 |
|
|
|
|
| 63 |
client = PoeApi("sXvCnfYy8CHnXNTRlxhmVg==")
|
| 64 |
GEN_CODE = ""
|
| 65 |
counter += 1
|
| 66 |
+
client.get_chat_history()
|
| 67 |
+
# print(client.get_chat_history()["data"])
|
App/Music_1.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
App/TTS/text.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
x={
|
| 3 |
+
"name": "execute_sql",
|
| 4 |
+
"description": "Executes the sql query, the schema of the table is CREATE TABLE fund_data (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, scheme_id BIGINT UNSIGNED DEFAULT 0, net_asset_value DECIMAL(20, 4), outstanding_number_of_units DECIMAL(20, 4), nav_per_unit DECIMAL(20, 4), sale_price_per_unit DECIMAL(20, 4), repurchase_price_per_unit DECIMAL(20, 4), date_valued DATE, scheme_name VARCHAR(255)); all calculations should end in the current date and nothing more, for the lastest price of any fund use the last recorded price, using sale_price_per_unit create a sql query to pass to the execute_sql. There is Liquid Fund, Umoja Fund, Bond Fund, Jikimu Fund Wekeza Maisha Fund and Watoto Fund. Make sure that the syntax is valid!",
|
| 5 |
+
"parameters": {
|
| 6 |
+
"type": "object",
|
| 7 |
+
"properties": {
|
| 8 |
+
"query": {
|
| 9 |
+
"type": "string",
|
| 10 |
+
"description": "SQL query passed to the "
|
| 11 |
+
}
|
| 12 |
+
},
|
| 13 |
+
"required": ["query"]
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
#sql query to
|
App/TTS/text2sql.py
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
|
| 3 |
+
queries = [
|
| 4 |
+
{
|
| 5 |
+
"description": "Get all records from fund_data",
|
| 6 |
+
"query": "SELECT * FROM fund_data;",
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"description": "Get all records from fund_data",
|
| 10 |
+
"query": "SELECT * FROM fund_data;",
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"description": "Get all unique fund names",
|
| 14 |
+
"query": "SELECT DISTINCT scheme_name FROM fund_data;",
|
| 15 |
+
},
|
| 16 |
+
{
|
| 17 |
+
"description": "Get the latest price for each fund",
|
| 18 |
+
"query": """
|
| 19 |
+
SELECT scheme_name, sale_price_per_unit
|
| 20 |
+
FROM fund_data
|
| 21 |
+
WHERE (scheme_name, date_valued) IN (
|
| 22 |
+
SELECT scheme_name, MAX(date_valued)
|
| 23 |
+
FROM fund_data
|
| 24 |
+
GROUP BY scheme_name
|
| 25 |
+
);
|
| 26 |
+
""",
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"description": "Get the total sale_price_per_unit for each fund",
|
| 30 |
+
"query": "SELECT scheme_name, SUM(sale_price_per_unit) FROM fund_data GROUP BY scheme_name;",
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"description": "Get the number of records for each fund",
|
| 34 |
+
"query": "SELECT scheme_name, COUNT(*) FROM fund_data GROUP BY scheme_name;",
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"description": "Get the earliest and latest date_valued for each fund",
|
| 38 |
+
"query": "SELECT scheme_name, MIN(date_valued), MAX(date_valued) FROM fund_data GROUP BY scheme_name;",
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"description": "Get the sale_price_per_unit for the latest date_valued for each fund",
|
| 42 |
+
"query": """
|
| 43 |
+
SELECT scheme_name, sale_price_per_unit
|
| 44 |
+
FROM fund_data
|
| 45 |
+
WHERE date_valued = (
|
| 46 |
+
SELECT MAX(date_valued)
|
| 47 |
+
FROM fund_data AS fd
|
| 48 |
+
WHERE fd.scheme_name = fund_data.scheme_name
|
| 49 |
+
);
|
| 50 |
+
""",
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"description": "Get the fund with the highest average sale_price_per_unit for each year",
|
| 54 |
+
"query": """
|
| 55 |
+
SELECT YEAR(date_valued) AS year, scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 56 |
+
FROM fund_data
|
| 57 |
+
GROUP BY year, scheme_name
|
| 58 |
+
ORDER BY avg_price DESC;
|
| 59 |
+
""",
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"description": "Get the fund with the highest total sale_price_per_unit for each month in 2020",
|
| 63 |
+
"query": """
|
| 64 |
+
SELECT MONTH(date_valued) AS month, scheme_name, SUM(sale_price_per_unit) AS total_price
|
| 65 |
+
FROM fund_data
|
| 66 |
+
WHERE YEAR(date_valued) = 2020
|
| 67 |
+
GROUP BY month, scheme_name
|
| 68 |
+
ORDER BY total_price DESC;
|
| 69 |
+
""",
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"description": "Get the top 3 funds with the highest average sale_price_per_unit for each quarter in 2020",
|
| 73 |
+
"query": """
|
| 74 |
+
SELECT QUARTER(date_valued) AS quarter, scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 75 |
+
FROM fund_data
|
| 76 |
+
WHERE YEAR(date_valued) = 2020
|
| 77 |
+
GROUP BY quarter, scheme_name
|
| 78 |
+
ORDER BY avg_price DESC
|
| 79 |
+
LIMIT 3;
|
| 80 |
+
""",
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"description": "Get the fund with the highest sale_price_per_unit for the last date_valued of each month in 2020",
|
| 84 |
+
"query": """
|
| 85 |
+
SELECT scheme_name, sale_price_per_unit
|
| 86 |
+
FROM fund_data
|
| 87 |
+
WHERE date_valued IN (
|
| 88 |
+
SELECT MAX(date_valued)
|
| 89 |
+
FROM fund_data
|
| 90 |
+
WHERE YEAR(date_valued) = 2020
|
| 91 |
+
GROUP BY MONTH(date_valued)
|
| 92 |
+
)
|
| 93 |
+
ORDER BY sale_price_per_unit DESC;
|
| 94 |
+
""",
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"description": "Get the fund with the lowest average sale_price_per_unit",
|
| 98 |
+
"query": """
|
| 99 |
+
SELECT scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 100 |
+
FROM fund_data
|
| 101 |
+
GROUP BY scheme_name
|
| 102 |
+
ORDER BY avg_price ASC
|
| 103 |
+
LIMIT 1;
|
| 104 |
+
""",
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"description": "Get the date with the highest total sale_price_per_unit for all funds",
|
| 108 |
+
"query": """
|
| 109 |
+
SELECT date_valued, SUM(sale_price_per_unit) AS total_price
|
| 110 |
+
FROM fund_data
|
| 111 |
+
GROUP BY date_valued
|
| 112 |
+
ORDER BY total_price DESC
|
| 113 |
+
LIMIT 1;
|
| 114 |
+
""",
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"description": "Get the fund with the most records in the database",
|
| 118 |
+
"query": """
|
| 119 |
+
SELECT scheme_name, COUNT(*) AS count
|
| 120 |
+
FROM fund_data
|
| 121 |
+
GROUP BY scheme_name
|
| 122 |
+
ORDER BY count DESC
|
| 123 |
+
LIMIT 1;
|
| 124 |
+
""",
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"description": "Get the date with the most records in the database",
|
| 128 |
+
"query": """
|
| 129 |
+
SELECT date_valued, COUNT(*) AS count
|
| 130 |
+
FROM fund_data
|
| 131 |
+
GROUP BY date_valued
|
| 132 |
+
ORDER BY count DESC
|
| 133 |
+
LIMIT 1;
|
| 134 |
+
""",
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"description": "Get the fund with the highest sale_price_per_unit on the latest date_valued",
|
| 138 |
+
"query": """
|
| 139 |
+
SELECT scheme_name, sale_price_per_unit
|
| 140 |
+
FROM fund_data
|
| 141 |
+
WHERE date_valued = (
|
| 142 |
+
SELECT MAX(date_valued)
|
| 143 |
+
FROM fund_data
|
| 144 |
+
)
|
| 145 |
+
ORDER BY sale_price_per_unit DESC
|
| 146 |
+
LIMIT 1;
|
| 147 |
+
""",
|
| 148 |
+
},
|
| 149 |
+
{
|
| 150 |
+
"description": "Get the percentage change in average sale_price_per_unit from the previous month for each fund in 2020",
|
| 151 |
+
"query": """
|
| 152 |
+
SELECT scheme_name, MONTH(date_valued) AS month,
|
| 153 |
+
((AVG(sale_price_per_unit) - LAG(AVG(sale_price_per_unit)) OVER (PARTITION BY scheme_name ORDER BY month)) / LAG(AVG(sale_price_per_unit)) OVER (PARTITION BY scheme_name ORDER BY month)) * 100 AS pct_change
|
| 154 |
+
FROM fund_data
|
| 155 |
+
WHERE YEAR(date_valued) = 2020
|
| 156 |
+
GROUP BY scheme_name, month;
|
| 157 |
+
""",
|
| 158 |
+
},
|
| 159 |
+
{
|
| 160 |
+
"description": "Get the top 5 funds with the highest average sale_price_per_unit",
|
| 161 |
+
"query": """
|
| 162 |
+
SELECT scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 163 |
+
FROM fund_data
|
| 164 |
+
GROUP BY scheme_name
|
| 165 |
+
ORDER BY avg_price DESC
|
| 166 |
+
LIMIT 5;
|
| 167 |
+
""",
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"description": "Calculate percentage return of funds in 2020",
|
| 171 |
+
"query": """
|
| 172 |
+
SELECT
|
| 173 |
+
start_price.scheme_name,
|
| 174 |
+
((end_price.sale_price_per_unit - start_price.sale_price_per_unit) / start_price.sale_price_per_unit) * 100 AS percentage_return
|
| 175 |
+
FROM
|
| 176 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 177 |
+
FROM fund_data
|
| 178 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MIN(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 179 |
+
GROUP BY scheme_name) AS start_price,
|
| 180 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 181 |
+
FROM fund_data
|
| 182 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MAX(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 183 |
+
GROUP BY scheme_name) AS end_price
|
| 184 |
+
WHERE start_price.scheme_name = end_price.scheme_name;
|
| 185 |
+
""",
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"description": "Calculate Sharpe Ratio of Liquid Fund in 2020",
|
| 189 |
+
"query": """
|
| 190 |
+
SELECT
|
| 191 |
+
scheme_name,
|
| 192 |
+
AVG(daily_return) AS avg_return,
|
| 193 |
+
STDDEV_POP(daily_return) AS std_dev,
|
| 194 |
+
(AVG(daily_return) - 12) / STDDEV_POP(daily_return) AS sharpe_ratio
|
| 195 |
+
FROM
|
| 196 |
+
(SELECT
|
| 197 |
+
scheme_name,
|
| 198 |
+
((sale_price_per_unit - LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) / LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) * 100 AS daily_return
|
| 199 |
+
FROM
|
| 200 |
+
fund_data
|
| 201 |
+
WHERE
|
| 202 |
+
scheme_name = 'Liquid Fund' AND YEAR(date_valued) = 2020) AS daily_returns
|
| 203 |
+
GROUP BY
|
| 204 |
+
scheme_name;
|
| 205 |
+
""",
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"description": "Get the total number of records in fund_data",
|
| 209 |
+
"query": "SELECT COUNT(*) FROM fund_data;",
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"description": "Get the average sale_price_per_unit for each fund",
|
| 213 |
+
"query": "SELECT scheme_name, AVG(sale_price_per_unit) FROM fund_data GROUP BY scheme_name;",
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"description": "Get all unique fund names",
|
| 217 |
+
"query": "SELECT DISTINCT scheme_name FROM fund_data;",
|
| 218 |
+
},
|
| 219 |
+
{
|
| 220 |
+
"description": "Get the latest price for each fund",
|
| 221 |
+
"query": """
|
| 222 |
+
SELECT scheme_name, sale_price_per_unit
|
| 223 |
+
FROM fund_data
|
| 224 |
+
WHERE (scheme_name, date_valued) IN (
|
| 225 |
+
SELECT scheme_name, MAX(date_valued)
|
| 226 |
+
FROM fund_data
|
| 227 |
+
GROUP BY scheme_name
|
| 228 |
+
);
|
| 229 |
+
""",
|
| 230 |
+
},
|
| 231 |
+
{
|
| 232 |
+
"description": "Calculate percentage return of funds in 2020",
|
| 233 |
+
"query": """
|
| 234 |
+
SELECT
|
| 235 |
+
start_price.scheme_name,
|
| 236 |
+
((end_price.sale_price_per_unit - start_price.sale_price_per_unit) / start_price.sale_price_per_unit) * 100 AS percentage_return
|
| 237 |
+
FROM
|
| 238 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 239 |
+
FROM fund_data
|
| 240 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MIN(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 241 |
+
GROUP BY scheme_name) AS start_price,
|
| 242 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 243 |
+
FROM fund_data
|
| 244 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MAX(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 245 |
+
GROUP BY scheme_name) AS end_price
|
| 246 |
+
WHERE start_price.scheme_name = end_price.scheme_name;
|
| 247 |
+
""",
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"description": "Calculate Sharpe Ratio of Liquid Fund in 2020",
|
| 251 |
+
"query": """
|
| 252 |
+
SELECT
|
| 253 |
+
scheme_name,
|
| 254 |
+
AVG(daily_return) AS avg_return,
|
| 255 |
+
STDDEV_POP(daily_return) AS std_dev,
|
| 256 |
+
(AVG(daily_return) - 12) / STDDEV_POP(daily_return) AS sharpe_ratio
|
| 257 |
+
FROM
|
| 258 |
+
(SELECT
|
| 259 |
+
scheme_name,
|
| 260 |
+
((sale_price_per_unit - LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) / LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) * 100 AS daily_return
|
| 261 |
+
FROM
|
| 262 |
+
fund_data
|
| 263 |
+
WHERE
|
| 264 |
+
scheme_name = 'Liquid Fund' AND YEAR(date_valued) = 2020) AS daily_returns
|
| 265 |
+
GROUP BY
|
| 266 |
+
scheme_name;
|
| 267 |
+
""",
|
| 268 |
+
},
|
| 269 |
+
]
|
| 270 |
+
|
| 271 |
+
with open("queries.csv", "w", newline="") as csvfile:
|
| 272 |
+
fieldnames = ["description", "query"]
|
| 273 |
+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
| 274 |
+
|
| 275 |
+
writer.writeheader()
|
| 276 |
+
for query in queries:
|
| 277 |
+
writer.writerow(query)
|
App/TTS/utils/HeyGen.py
CHANGED
|
@@ -1,5 +1,22 @@
|
|
| 1 |
import aiohttp
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
class HeygenAPI:
|
|
@@ -82,3 +99,23 @@ class HeygenAPI:
|
|
| 82 |
|
| 83 |
async def __aexit__(self, exc_type, exc_value, traceback):
|
| 84 |
await self.close_session()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import aiohttp
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
from pydantic import BaseModel, Field, validator
|
| 6 |
+
from typing import List, Optional
|
| 7 |
+
import uuid
|
| 8 |
+
class HeyGenTTSRequest(BaseModel):
|
| 9 |
+
voice_id: str = Field(default="d7bbcdd6964c47bdaae26decade4a933")
|
| 10 |
+
rate: str = Field(default="1")
|
| 11 |
+
pitch: str = Field(default="-3%")
|
| 12 |
+
text: str = "Sample"
|
| 13 |
+
|
| 14 |
+
@validator("text")
|
| 15 |
+
def validate_age(cls, value, values):
|
| 16 |
+
if not "speak" in value:
|
| 17 |
+
return f'<speak> <voice name="{values.get("voice_id")}"><prosody rate="{values.get("rate")}" pitch="{values.get("pitch")}">{value}</prosody></voice></speak>'
|
| 18 |
+
else:
|
| 19 |
+
return value
|
| 20 |
|
| 21 |
|
| 22 |
class HeygenAPI:
|
|
|
|
| 99 |
|
| 100 |
async def __aexit__(self, exc_type, exc_value, traceback):
|
| 101 |
await self.close_session()
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
async def main():
|
| 105 |
+
data = {
|
| 106 |
+
"account": "[email protected]",
|
| 107 |
+
"password": "HBBHN4RPs_rA$%R",
|
| 108 |
+
"token":'+DTX2g=='
|
| 109 |
+
}
|
| 110 |
+
async with HeygenAPI(**data) as heygen:
|
| 111 |
+
req = HeyGenTTSRequest(
|
| 112 |
+
text="Hello, this is a test",
|
| 113 |
+
# voice_id="1",
|
| 114 |
+
)
|
| 115 |
+
response = await heygen.tts_request(req)
|
| 116 |
+
print(response)
|
| 117 |
+
|
| 118 |
+
if __name__ == "__main__":
|
| 119 |
+
import asyncio
|
| 120 |
+
|
| 121 |
+
asyncio.run(main())
|
App/TTS/utils/Initialize.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
App/app.py
CHANGED
|
@@ -3,8 +3,8 @@ from fastapi import FastAPI
|
|
| 3 |
from fastapi.middleware.gzip import GZipMiddleware
|
| 4 |
|
| 5 |
from .TTS.TTSRoutes import tts_router
|
| 6 |
-
from .Embedding.EmbeddingRoutes import embeddigs_router
|
| 7 |
-
from .Chat.PoeChatrouter import chat_router
|
| 8 |
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
|
|
@@ -45,6 +45,6 @@ async def landing_page():
|
|
| 45 |
return {"code": 200, "message": "we are back!"}
|
| 46 |
|
| 47 |
|
| 48 |
-
app.include_router(embeddigs_router)
|
| 49 |
app.include_router(tts_router)
|
| 50 |
-
app.include_router(chat_router)
|
|
|
|
| 3 |
from fastapi.middleware.gzip import GZipMiddleware
|
| 4 |
|
| 5 |
from .TTS.TTSRoutes import tts_router
|
| 6 |
+
# from .Embedding.EmbeddingRoutes import embeddigs_router
|
| 7 |
+
# from .Chat.PoeChatrouter import chat_router
|
| 8 |
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
|
|
|
|
| 45 |
return {"code": 200, "message": "we are back!"}
|
| 46 |
|
| 47 |
|
| 48 |
+
# app.include_router(embeddigs_router)
|
| 49 |
app.include_router(tts_router)
|
| 50 |
+
# app.include_router(chat_router)
|
App/voices.json
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"voiceId": "5436957b7d364ce79bc8d37e",
|
| 4 |
+
"name": "Lucy",
|
| 5 |
+
"color": "#266DD3",
|
| 6 |
+
"displayName": "Kylie",
|
| 7 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Lucy.wav",
|
| 8 |
+
"upgradePlan": null,
|
| 9 |
+
"myVoice": null
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"voiceId": "2ade011b9fa4443c9af3acd5",
|
| 13 |
+
"name": "Emma",
|
| 14 |
+
"color": "#9B4AB8",
|
| 15 |
+
"displayName": "Emma",
|
| 16 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/2ade011b9fa4443c9af3acd5.wav",
|
| 17 |
+
"upgradePlan": "FREE",
|
| 18 |
+
"myVoice": null
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"voiceId": "ece80d8188fa4778ab549fd0",
|
| 22 |
+
"name": "Jennifer",
|
| 23 |
+
"color": "#FAB400",
|
| 24 |
+
"displayName": "Jennifer",
|
| 25 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/ece80d8188fa4778ab549fd0.wav",
|
| 26 |
+
"upgradePlan": "FREE",
|
| 27 |
+
"myVoice": null
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"voiceId": "826cbf58fb1245369a1f5d9b",
|
| 31 |
+
"name": "Anthony",
|
| 32 |
+
"color": "#403DBF",
|
| 33 |
+
"displayName": "Anthony",
|
| 34 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/826cbf58fb1245369a1f5d9b.wav",
|
| 35 |
+
"upgradePlan": "FREE",
|
| 36 |
+
"myVoice": null
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"voiceId": "9ea55391f75a48edb13e5630",
|
| 40 |
+
"name": "Sophia",
|
| 41 |
+
"color": "#FE810E",
|
| 42 |
+
"displayName": "Sophia",
|
| 43 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/9ea55391f75a48edb13e5630.wav",
|
| 44 |
+
"upgradePlan": "FREE",
|
| 45 |
+
"myVoice": null
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"voiceId": "5f9b7eb2d2794cb1b85ec8da",
|
| 49 |
+
"name": "Samantha",
|
| 50 |
+
"color": "#FAB400",
|
| 51 |
+
"displayName": "Samantha",
|
| 52 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/5f9b7eb2d2794cb1b85ec8da.wav",
|
| 53 |
+
"upgradePlan": "FREE",
|
| 54 |
+
"myVoice": null
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"voiceId": "c60166365edf46589657770d",
|
| 58 |
+
"name": "Ben",
|
| 59 |
+
"color": "#31A93D",
|
| 60 |
+
"displayName": "Ben",
|
| 61 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/c60166365edf46589657770d.wav",
|
| 62 |
+
"upgradePlan": "FREE",
|
| 63 |
+
"myVoice": null
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"voiceId": "d323529cbc79441abc65c0af",
|
| 67 |
+
"name": "Charlotte",
|
| 68 |
+
"color": "#358E64",
|
| 69 |
+
"displayName": "Charlotte",
|
| 70 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/d323529cbc79441abc65c0af.wav",
|
| 71 |
+
"upgradePlan": "FREE",
|
| 72 |
+
"myVoice": null
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"voiceId": "0ecfaf9c48a24b1da871f20a",
|
| 76 |
+
"name": "Frank",
|
| 77 |
+
"color": "#5DB1EE",
|
| 78 |
+
"displayName": "Frank",
|
| 79 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/0ecfaf9c48a24b1da871f20a.wav",
|
| 80 |
+
"upgradePlan": "FREE",
|
| 81 |
+
"myVoice": null
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"voiceId": "359adc49dbaa4de0b4a19c49",
|
| 85 |
+
"name": "Logan",
|
| 86 |
+
"color": "#BA324F",
|
| 87 |
+
"displayName": "Logan",
|
| 88 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/359adc49dbaa4de0b4a19c49.wav",
|
| 89 |
+
"upgradePlan": "FREE",
|
| 90 |
+
"myVoice": null
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"voiceId": "2e7c549a1fcf4efba133f73e",
|
| 94 |
+
"name": "Matthew",
|
| 95 |
+
"color": "#18BCB2",
|
| 96 |
+
"displayName": "Matthew",
|
| 97 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/2e7c549a1fcf4efba133f73e.wav",
|
| 98 |
+
"upgradePlan": "FREE",
|
| 99 |
+
"myVoice": null
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"voiceId": "6a1b284fdf8f43658e0d962c",
|
| 103 |
+
"name": "Michael",
|
| 104 |
+
"color": "#FF5B5B",
|
| 105 |
+
"displayName": "Michael",
|
| 106 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/6a1b284fdf8f43658e0d962c.wav",
|
| 107 |
+
"upgradePlan": "FREE",
|
| 108 |
+
"myVoice": null
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"voiceId": "d4d49ad195fd4877a9b40b2d",
|
| 112 |
+
"name": "Robert",
|
| 113 |
+
"color": "#A8C012",
|
| 114 |
+
"displayName": "Robert",
|
| 115 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/d4d49ad195fd4877a9b40b2d.wav",
|
| 116 |
+
"upgradePlan": "FREE",
|
| 117 |
+
"myVoice": null
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"voiceId": "2a55f0fcdca345cda94c262a",
|
| 121 |
+
"name": "Victoria",
|
| 122 |
+
"color": "#653BBE",
|
| 123 |
+
"displayName": "Victoria",
|
| 124 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/2a55f0fcdca345cda94c262a.wav",
|
| 125 |
+
"upgradePlan": "FREE",
|
| 126 |
+
"myVoice": null
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"voiceId": "44580aaacdc64fa6a0e3c3fe",
|
| 130 |
+
"name": "Lucas",
|
| 131 |
+
"color": "#CD42B7",
|
| 132 |
+
"displayName": "Lucas",
|
| 133 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/44580aaacdc64fa6a0e3c3fe.wav",
|
| 134 |
+
"upgradePlan": "FREE",
|
| 135 |
+
"myVoice": null
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"voiceId": "9785244c974b4c70a259ef93",
|
| 139 |
+
"name": "John",
|
| 140 |
+
"color": "#5DB1EE",
|
| 141 |
+
"displayName": "John",
|
| 142 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/9785244c974b4c70a259ef93.wav",
|
| 143 |
+
"upgradePlan": "FREE",
|
| 144 |
+
"myVoice": null
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"voiceId": "2b14a70f78c248e28200d7a6",
|
| 148 |
+
"name": "Olivia",
|
| 149 |
+
"color": "#2596BE",
|
| 150 |
+
"displayName": "Olivia",
|
| 151 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/2b14a70f78c248e28200d7a6.WAV",
|
| 152 |
+
"upgradePlan": "FREE",
|
| 153 |
+
"myVoice": null
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"voiceId": "38de550f4c9b46ea816579d9",
|
| 157 |
+
"name": "William",
|
| 158 |
+
"color": "#D62839",
|
| 159 |
+
"displayName": "Daniel",
|
| 160 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/William.wav",
|
| 161 |
+
"upgradePlan": null,
|
| 162 |
+
"myVoice": null
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"voiceId": "f96e2bf4fea54decaf7d1ab1",
|
| 166 |
+
"name": "Nadia",
|
| 167 |
+
"color": "#E16036",
|
| 168 |
+
"displayName": "Maria",
|
| 169 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Nadia.wav",
|
| 170 |
+
"upgradePlan": null,
|
| 171 |
+
"myVoice": null
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"voiceId": "348743483218608",
|
| 175 |
+
"name": "en-US-Wavenet-G",
|
| 176 |
+
"color": "#008080",
|
| 177 |
+
"displayName": "Sunshine",
|
| 178 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Sunshine.wav",
|
| 179 |
+
"upgradePlan": null,
|
| 180 |
+
"myVoice": null
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"voiceId": "348743483218605",
|
| 184 |
+
"name": "en-US-Wavenet-D",
|
| 185 |
+
"color": "#FF5722",
|
| 186 |
+
"displayName": "Kenny",
|
| 187 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Kenny.wav",
|
| 188 |
+
"upgradePlan": null,
|
| 189 |
+
"myVoice": null
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"voiceId": "348743483218600",
|
| 193 |
+
"name": "en-US-Standard-D",
|
| 194 |
+
"color": "#673AB7",
|
| 195 |
+
"displayName": "Andrew",
|
| 196 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Andrew.wav",
|
| 197 |
+
"upgradePlan": null,
|
| 198 |
+
"myVoice": null
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"voiceId": "348743483218601",
|
| 202 |
+
"name": "en-US-Standard-H",
|
| 203 |
+
"color": "#3F51B5",
|
| 204 |
+
"displayName": "Melissa",
|
| 205 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Melissa.wav",
|
| 206 |
+
"upgradePlan": null,
|
| 207 |
+
"myVoice": null
|
| 208 |
+
},
|
| 209 |
+
{
|
| 210 |
+
"voiceId": "348743483218602",
|
| 211 |
+
"name": "en-US-Wavenet-A",
|
| 212 |
+
"color": "#AB47BC",
|
| 213 |
+
"displayName": "Martin",
|
| 214 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Martin.wav",
|
| 215 |
+
"upgradePlan": null,
|
| 216 |
+
"myVoice": null
|
| 217 |
+
},
|
| 218 |
+
{
|
| 219 |
+
"voiceId": "348743483218603",
|
| 220 |
+
"name": "en-US-Wavenet-B",
|
| 221 |
+
"color": "#A167A5",
|
| 222 |
+
"displayName": "James",
|
| 223 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/James.wav",
|
| 224 |
+
"upgradePlan": null,
|
| 225 |
+
"myVoice": null
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"voiceId": "348743483218604",
|
| 229 |
+
"name": "en-US-Wavenet-C",
|
| 230 |
+
"color": "#E91E63",
|
| 231 |
+
"displayName": "Caitlyn",
|
| 232 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Caitlyn.wav",
|
| 233 |
+
"upgradePlan": null,
|
| 234 |
+
"myVoice": null
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"voiceId": "348743483218612",
|
| 238 |
+
"name": "en-AU-Wavenet-B",
|
| 239 |
+
"color": "#867AE9",
|
| 240 |
+
"displayName": "Russel",
|
| 241 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Russel.wav",
|
| 242 |
+
"upgradePlan": null,
|
| 243 |
+
"myVoice": null
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"voiceId": "348743483218606",
|
| 247 |
+
"name": "en-US-Wavenet-E",
|
| 248 |
+
"color": "#F08700",
|
| 249 |
+
"displayName": "Arianna",
|
| 250 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Arianna.wav",
|
| 251 |
+
"upgradePlan": null,
|
| 252 |
+
"myVoice": null
|
| 253 |
+
},
|
| 254 |
+
{
|
| 255 |
+
"voiceId": "348743483218607",
|
| 256 |
+
"name": "en-US-Wavenet-F",
|
| 257 |
+
"color": "#FFC107",
|
| 258 |
+
"displayName": "Sisilia",
|
| 259 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Sisilia.wav",
|
| 260 |
+
"upgradePlan": null,
|
| 261 |
+
"myVoice": null
|
| 262 |
+
},
|
| 263 |
+
{
|
| 264 |
+
"voiceId": "348743483218613",
|
| 265 |
+
"name": "en-GB-Wavenet-F",
|
| 266 |
+
"color": "#C449C2",
|
| 267 |
+
"displayName": "Diana",
|
| 268 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Diana.wav",
|
| 269 |
+
"upgradePlan": null,
|
| 270 |
+
"myVoice": null
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"voiceId": "348743483218609",
|
| 274 |
+
"name": "en-US-Wavenet-H",
|
| 275 |
+
"color": "#53BB8D",
|
| 276 |
+
"displayName": "Mia",
|
| 277 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Mia.wav",
|
| 278 |
+
"upgradePlan": null,
|
| 279 |
+
"myVoice": null
|
| 280 |
+
},
|
| 281 |
+
{
|
| 282 |
+
"voiceId": "348743483218610",
|
| 283 |
+
"name": "en-US-Wavenet-I",
|
| 284 |
+
"color": "#1092F9",
|
| 285 |
+
"displayName": "Fred",
|
| 286 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Fred.wav",
|
| 287 |
+
"upgradePlan": null,
|
| 288 |
+
"myVoice": null
|
| 289 |
+
},
|
| 290 |
+
{
|
| 291 |
+
"voiceId": "348743483218611",
|
| 292 |
+
"name": "en-US-Wavenet-J",
|
| 293 |
+
"color": "#00BCD4",
|
| 294 |
+
"displayName": "Vincent",
|
| 295 |
+
"fileUrl": "https://storage.googleapis.com/podcastle-prod-public/Voices%20preview/Vincent.wav",
|
| 296 |
+
"upgradePlan": null,
|
| 297 |
+
"myVoice": null
|
| 298 |
+
}
|
| 299 |
+
]
|
gradio-app.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import asyncio
|
| 3 |
+
import copy
|
| 4 |
+
import json
|
| 5 |
+
import base64
|
| 6 |
+
from io import BytesIO
|
| 7 |
+
import IPython.display as ipd
|
| 8 |
+
from watchgod import awatch
|
| 9 |
+
from Complete import (
|
| 10 |
+
Speak,
|
| 11 |
+
Transcriber,
|
| 12 |
+
MovieDescriptionProcessor,
|
| 13 |
+
) # Replace 'your_script' with your actual module name
|
| 14 |
+
|
| 15 |
+
tts_client = Speak()
|
| 16 |
+
movie_processor = MovieDescriptionProcessor()
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Gradio app function
|
| 20 |
+
def gradio_app(movie_name, year, media_type, original_language, go_button):
|
| 21 |
+
if go_button:
|
| 22 |
+
print("here")
|
| 23 |
+
# Construct the message for movie description
|
| 24 |
+
message = movie_processor.prompt_fetcher()
|
| 25 |
+
message = message.format(
|
| 26 |
+
media_type=media_type,
|
| 27 |
+
movie_name=movie_name,
|
| 28 |
+
original_language=original_language,
|
| 29 |
+
movie_year=year,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Process movie description
|
| 33 |
+
script = asyncio.run(movie_processor.process_movie_description(message))
|
| 34 |
+
|
| 35 |
+
# Generate image descriptions
|
| 36 |
+
message, result = movie_processor.prompt_fetcher("images").split("{format}")
|
| 37 |
+
message = message.format(script=script) + result
|
| 38 |
+
images_descriptions = asyncio.run(
|
| 39 |
+
movie_processor.process_movie_description(message, "Assistant")
|
| 40 |
+
)
|
| 41 |
+
image_json = movie_processor.extract_json_from_markdown(images_descriptions)
|
| 42 |
+
|
| 43 |
+
# Generate audio file
|
| 44 |
+
audio_file_path = asyncio.run(tts_client.say(script))
|
| 45 |
+
|
| 46 |
+
# Create an instance of the Transcriber class
|
| 47 |
+
transcriber = Transcriber(audio_file_path)
|
| 48 |
+
|
| 49 |
+
# Perform the transcription task
|
| 50 |
+
asyncio.run(transcriber.transcribe())
|
| 51 |
+
|
| 52 |
+
# Download the JSON transcription to a file
|
| 53 |
+
output_json_path = "./output.json" # Replace with the desired output path
|
| 54 |
+
asyncio.run(transcriber.download_transcription(output_json_path))
|
| 55 |
+
|
| 56 |
+
# Return the outputs
|
| 57 |
+
return {
|
| 58 |
+
"image_json": image_json,
|
| 59 |
+
"audio_file": {"name": "audio_file.wav", "file_path": audio_file_path},
|
| 60 |
+
"tts_json": {"name": "tts_output.json", "file_path": output_json_path},
|
| 61 |
+
}
|
| 62 |
+
return None
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Define Gradio inputs
|
| 66 |
+
inputs = [
|
| 67 |
+
gr.Textbox(placeholder="Avatar", label="Movie Name"),
|
| 68 |
+
gr.Textbox(placeholder="2023", label="Year"),
|
| 69 |
+
gr.Radio(choices=["movie", "tv series"], label="Media Type"),
|
| 70 |
+
gr.Dropdown(choices=["English", "Spanish"], label="Original Language"),
|
| 71 |
+
gr.Button("go_button"),
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# Define Gradio outputs
|
| 76 |
+
outputs = [
|
| 77 |
+
gr.Textbox("image_json", label="Image JSON"),
|
| 78 |
+
# gr.File("audio_file", label="Audio File"),
|
| 79 |
+
# gr.File("tts_json", label="TTS JSON")
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
# Create the Gradio interface
|
| 83 |
+
iface = gr.Interface(fn=gradio_app, inputs=inputs, outputs=outputs, live=True)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
# Launch the Gradio app
|
| 87 |
+
async def restart_gradio():
|
| 88 |
+
async for changes in awatch(".", watcher_cls=watchgod.DefaultDirWatcher):
|
| 89 |
+
await iface.close()
|
| 90 |
+
iface.launch()
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# Run Gradio interface and hot-reloading
|
| 94 |
+
loop = asyncio.get_event_loop()
|
| 95 |
+
loop.create_task(restart_gradio())
|
| 96 |
+
iface.launch()
|
litellm_uuid.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
8eb83e0c-0450-4a95-95cb-2c9544c27526
|
queries.csv
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
description,query
|
| 2 |
+
Get all records from fund_data,SELECT * FROM fund_data;
|
| 3 |
+
Get all records from fund_data,SELECT * FROM fund_data;
|
| 4 |
+
Get all unique fund names,SELECT DISTINCT scheme_name FROM fund_data;
|
| 5 |
+
Get the latest price for each fund,"
|
| 6 |
+
SELECT scheme_name, sale_price_per_unit
|
| 7 |
+
FROM fund_data
|
| 8 |
+
WHERE (scheme_name, date_valued) IN (
|
| 9 |
+
SELECT scheme_name, MAX(date_valued)
|
| 10 |
+
FROM fund_data
|
| 11 |
+
GROUP BY scheme_name
|
| 12 |
+
);
|
| 13 |
+
"
|
| 14 |
+
Get the total sale_price_per_unit for each fund,"SELECT scheme_name, SUM(sale_price_per_unit) FROM fund_data GROUP BY scheme_name;"
|
| 15 |
+
Get the number of records for each fund,"SELECT scheme_name, COUNT(*) FROM fund_data GROUP BY scheme_name;"
|
| 16 |
+
Get the earliest and latest date_valued for each fund,"SELECT scheme_name, MIN(date_valued), MAX(date_valued) FROM fund_data GROUP BY scheme_name;"
|
| 17 |
+
Get the sale_price_per_unit for the latest date_valued for each fund,"
|
| 18 |
+
SELECT scheme_name, sale_price_per_unit
|
| 19 |
+
FROM fund_data
|
| 20 |
+
WHERE date_valued = (
|
| 21 |
+
SELECT MAX(date_valued)
|
| 22 |
+
FROM fund_data AS fd
|
| 23 |
+
WHERE fd.scheme_name = fund_data.scheme_name
|
| 24 |
+
);
|
| 25 |
+
"
|
| 26 |
+
Get the fund with the highest average sale_price_per_unit for each year,"
|
| 27 |
+
SELECT YEAR(date_valued) AS year, scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 28 |
+
FROM fund_data
|
| 29 |
+
GROUP BY year, scheme_name
|
| 30 |
+
ORDER BY avg_price DESC;
|
| 31 |
+
"
|
| 32 |
+
Get the fund with the highest total sale_price_per_unit for each month in 2020,"
|
| 33 |
+
SELECT MONTH(date_valued) AS month, scheme_name, SUM(sale_price_per_unit) AS total_price
|
| 34 |
+
FROM fund_data
|
| 35 |
+
WHERE YEAR(date_valued) = 2020
|
| 36 |
+
GROUP BY month, scheme_name
|
| 37 |
+
ORDER BY total_price DESC;
|
| 38 |
+
"
|
| 39 |
+
Get the top 3 funds with the highest average sale_price_per_unit for each quarter in 2020,"
|
| 40 |
+
SELECT QUARTER(date_valued) AS quarter, scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 41 |
+
FROM fund_data
|
| 42 |
+
WHERE YEAR(date_valued) = 2020
|
| 43 |
+
GROUP BY quarter, scheme_name
|
| 44 |
+
ORDER BY avg_price DESC
|
| 45 |
+
LIMIT 3;
|
| 46 |
+
"
|
| 47 |
+
Get the fund with the highest sale_price_per_unit for the last date_valued of each month in 2020,"
|
| 48 |
+
SELECT scheme_name, sale_price_per_unit
|
| 49 |
+
FROM fund_data
|
| 50 |
+
WHERE date_valued IN (
|
| 51 |
+
SELECT MAX(date_valued)
|
| 52 |
+
FROM fund_data
|
| 53 |
+
WHERE YEAR(date_valued) = 2020
|
| 54 |
+
GROUP BY MONTH(date_valued)
|
| 55 |
+
)
|
| 56 |
+
ORDER BY sale_price_per_unit DESC;
|
| 57 |
+
"
|
| 58 |
+
Get the fund with the lowest average sale_price_per_unit,"
|
| 59 |
+
SELECT scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 60 |
+
FROM fund_data
|
| 61 |
+
GROUP BY scheme_name
|
| 62 |
+
ORDER BY avg_price ASC
|
| 63 |
+
LIMIT 1;
|
| 64 |
+
"
|
| 65 |
+
Get the date with the highest total sale_price_per_unit for all funds,"
|
| 66 |
+
SELECT date_valued, SUM(sale_price_per_unit) AS total_price
|
| 67 |
+
FROM fund_data
|
| 68 |
+
GROUP BY date_valued
|
| 69 |
+
ORDER BY total_price DESC
|
| 70 |
+
LIMIT 1;
|
| 71 |
+
"
|
| 72 |
+
Get the fund with the most records in the database,"
|
| 73 |
+
SELECT scheme_name, COUNT(*) AS count
|
| 74 |
+
FROM fund_data
|
| 75 |
+
GROUP BY scheme_name
|
| 76 |
+
ORDER BY count DESC
|
| 77 |
+
LIMIT 1;
|
| 78 |
+
"
|
| 79 |
+
Get the date with the most records in the database,"
|
| 80 |
+
SELECT date_valued, COUNT(*) AS count
|
| 81 |
+
FROM fund_data
|
| 82 |
+
GROUP BY date_valued
|
| 83 |
+
ORDER BY count DESC
|
| 84 |
+
LIMIT 1;
|
| 85 |
+
"
|
| 86 |
+
Get the fund with the highest sale_price_per_unit on the latest date_valued,"
|
| 87 |
+
SELECT scheme_name, sale_price_per_unit
|
| 88 |
+
FROM fund_data
|
| 89 |
+
WHERE date_valued = (
|
| 90 |
+
SELECT MAX(date_valued)
|
| 91 |
+
FROM fund_data
|
| 92 |
+
)
|
| 93 |
+
ORDER BY sale_price_per_unit DESC
|
| 94 |
+
LIMIT 1;
|
| 95 |
+
"
|
| 96 |
+
Get the percentage change in average sale_price_per_unit from the previous month for each fund in 2020,"
|
| 97 |
+
SELECT scheme_name, MONTH(date_valued) AS month,
|
| 98 |
+
((AVG(sale_price_per_unit) - LAG(AVG(sale_price_per_unit)) OVER (PARTITION BY scheme_name ORDER BY month)) / LAG(AVG(sale_price_per_unit)) OVER (PARTITION BY scheme_name ORDER BY month)) * 100 AS pct_change
|
| 99 |
+
FROM fund_data
|
| 100 |
+
WHERE YEAR(date_valued) = 2020
|
| 101 |
+
GROUP BY scheme_name, month;
|
| 102 |
+
"
|
| 103 |
+
Get the top 5 funds with the highest average sale_price_per_unit,"
|
| 104 |
+
SELECT scheme_name, AVG(sale_price_per_unit) AS avg_price
|
| 105 |
+
FROM fund_data
|
| 106 |
+
GROUP BY scheme_name
|
| 107 |
+
ORDER BY avg_price DESC
|
| 108 |
+
LIMIT 5;
|
| 109 |
+
"
|
| 110 |
+
Calculate percentage return of funds in 2020,"
|
| 111 |
+
SELECT
|
| 112 |
+
start_price.scheme_name,
|
| 113 |
+
((end_price.sale_price_per_unit - start_price.sale_price_per_unit) / start_price.sale_price_per_unit) * 100 AS percentage_return
|
| 114 |
+
FROM
|
| 115 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 116 |
+
FROM fund_data
|
| 117 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MIN(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 118 |
+
GROUP BY scheme_name) AS start_price,
|
| 119 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 120 |
+
FROM fund_data
|
| 121 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MAX(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 122 |
+
GROUP BY scheme_name) AS end_price
|
| 123 |
+
WHERE start_price.scheme_name = end_price.scheme_name;
|
| 124 |
+
"
|
| 125 |
+
Calculate Sharpe Ratio of Liquid Fund in 2020,"
|
| 126 |
+
SELECT
|
| 127 |
+
scheme_name,
|
| 128 |
+
AVG(daily_return) AS avg_return,
|
| 129 |
+
STDDEV_POP(daily_return) AS std_dev,
|
| 130 |
+
(AVG(daily_return) - 12) / STDDEV_POP(daily_return) AS sharpe_ratio
|
| 131 |
+
FROM
|
| 132 |
+
(SELECT
|
| 133 |
+
scheme_name,
|
| 134 |
+
((sale_price_per_unit - LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) / LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) * 100 AS daily_return
|
| 135 |
+
FROM
|
| 136 |
+
fund_data
|
| 137 |
+
WHERE
|
| 138 |
+
scheme_name = 'Liquid Fund' AND YEAR(date_valued) = 2020) AS daily_returns
|
| 139 |
+
GROUP BY
|
| 140 |
+
scheme_name;
|
| 141 |
+
"
|
| 142 |
+
Get the total number of records in fund_data,SELECT COUNT(*) FROM fund_data;
|
| 143 |
+
Get the average sale_price_per_unit for each fund,"SELECT scheme_name, AVG(sale_price_per_unit) FROM fund_data GROUP BY scheme_name;"
|
| 144 |
+
Get all unique fund names,SELECT DISTINCT scheme_name FROM fund_data;
|
| 145 |
+
Get the latest price for each fund,"
|
| 146 |
+
SELECT scheme_name, sale_price_per_unit
|
| 147 |
+
FROM fund_data
|
| 148 |
+
WHERE (scheme_name, date_valued) IN (
|
| 149 |
+
SELECT scheme_name, MAX(date_valued)
|
| 150 |
+
FROM fund_data
|
| 151 |
+
GROUP BY scheme_name
|
| 152 |
+
);
|
| 153 |
+
"
|
| 154 |
+
Calculate percentage return of funds in 2020,"
|
| 155 |
+
SELECT
|
| 156 |
+
start_price.scheme_name,
|
| 157 |
+
((end_price.sale_price_per_unit - start_price.sale_price_per_unit) / start_price.sale_price_per_unit) * 100 AS percentage_return
|
| 158 |
+
FROM
|
| 159 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 160 |
+
FROM fund_data
|
| 161 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MIN(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 162 |
+
GROUP BY scheme_name) AS start_price,
|
| 163 |
+
(SELECT scheme_name, sale_price_per_unit
|
| 164 |
+
FROM fund_data
|
| 165 |
+
WHERE scheme_name IN ('Liquid Fund', 'Bond Fund') AND date_valued = (SELECT MAX(date_valued) FROM fund_data WHERE scheme_name = fund_data.scheme_name)
|
| 166 |
+
GROUP BY scheme_name) AS end_price
|
| 167 |
+
WHERE start_price.scheme_name = end_price.scheme_name;
|
| 168 |
+
"
|
| 169 |
+
Calculate Sharpe Ratio of Liquid Fund in 2020,"
|
| 170 |
+
SELECT
|
| 171 |
+
scheme_name,
|
| 172 |
+
AVG(daily_return) AS avg_return,
|
| 173 |
+
STDDEV_POP(daily_return) AS std_dev,
|
| 174 |
+
(AVG(daily_return) - 12) / STDDEV_POP(daily_return) AS sharpe_ratio
|
| 175 |
+
FROM
|
| 176 |
+
(SELECT
|
| 177 |
+
scheme_name,
|
| 178 |
+
((sale_price_per_unit - LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) / LAG(sale_price_per_unit) OVER (PARTITION BY scheme_name ORDER BY date_valued)) * 100 AS daily_return
|
| 179 |
+
FROM
|
| 180 |
+
fund_data
|
| 181 |
+
WHERE
|
| 182 |
+
scheme_name = 'Liquid Fund' AND YEAR(date_valued) = 2020) AS daily_returns
|
| 183 |
+
GROUP BY
|
| 184 |
+
scheme_name;
|
| 185 |
+
"
|
sample.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---
|
| 2 |
+
# lambda-test: false
|
| 3 |
+
# ---
|
| 4 |
+
# # Stable Diffusion (A1111)
|
| 5 |
+
#
|
| 6 |
+
# This example runs the popular [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
|
| 7 |
+
# project on Modal, without modification. We start a Modal container with an A10G GPU, run the server as a
|
| 8 |
+
# subprocess, and forward the port using a [tunnel](/docs/guide/tunnels).
|
| 9 |
+
|
| 10 |
+
import socket
|
| 11 |
+
import subprocess
|
| 12 |
+
import time
|
| 13 |
+
import webbrowser
|
| 14 |
+
|
| 15 |
+
from modal import Image, Queue, Stub, forward
|
| 16 |
+
|
| 17 |
+
stub = Stub("fooocus")
|
| 18 |
+
stub.urls = Queue.new() # TODO: FunctionCall.get() doesn't support generators.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def wait_for_port(port: int):
|
| 22 |
+
while True:
|
| 23 |
+
try:
|
| 24 |
+
with socket.create_connection(("127.0.0.1", port), timeout=5.0):
|
| 25 |
+
break
|
| 26 |
+
except OSError:
|
| 27 |
+
time.sleep(0.1)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# The following function starts the web UI container. Notice that it requires a few steps to
|
| 31 |
+
# install dependencies, since `stable-diffusion-webui` doesn't come with a prepackaged script
|
| 32 |
+
# to do this. (It usually installs dependencies on first launch.)
|
| 33 |
+
#
|
| 34 |
+
# After defining the custom container image, we start the server with `accelerate launch`. This
|
| 35 |
+
# function is also where you would configure hardware resources, CPU/memory, and timeouts.
|
| 36 |
+
#
|
| 37 |
+
# If you want to run it with an A100 GPU, just change `gpu="a10g"` to `gpu="a100"`.
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@stub.function(
|
| 41 |
+
image=Image.debian_slim()
|
| 42 |
+
.apt_install("wget", "git")
|
| 43 |
+
.run_commands(
|
| 44 |
+
"pip install pygit2==1.12.2",
|
| 45 |
+
"git clone https://github.com/lllyasviel/Fooocus.git",
|
| 46 |
+
"pip install -r /Fooocus/requirements_versions.txt",
|
| 47 |
+
gpu="a10g",
|
| 48 |
+
),
|
| 49 |
+
gpu="a10g",
|
| 50 |
+
cpu=2,
|
| 51 |
+
memory=1024,
|
| 52 |
+
timeout=3600,
|
| 53 |
+
)
|
| 54 |
+
def start_web_ui():
|
| 55 |
+
START_COMMAND = r"""
|
| 56 |
+
python /Fooocus/entry_with_update.py --share
|
| 57 |
+
"""
|
| 58 |
+
with forward(7860) as tunnel:
|
| 59 |
+
p = subprocess.Popen(START_COMMAND, shell=True)
|
| 60 |
+
wait_for_port(7860)
|
| 61 |
+
print("[MODAL] ==> Accepting connections at", tunnel.url)
|
| 62 |
+
stub.urls.put(tunnel.url)
|
| 63 |
+
p.wait(3600)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# The first run may take a few minutes to build the image. When the container starts, it will open
|
| 67 |
+
# the page in your browser.
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
@stub.local_entrypoint()
|
| 71 |
+
def main(no_browser: bool = False):
|
| 72 |
+
start_web_ui.spawn()
|
| 73 |
+
url = stub.urls.get()
|
| 74 |
+
if not no_browser:
|
| 75 |
+
webbrowser.open(url)
|
| 76 |
+
while True: # TODO: FunctionCall.get() doesn't support generators.
|
| 77 |
+
time.sleep(1)
|