dual_window / app_utils.py
Raymond
Added initial config
ea4ea4b
raw
history blame
7.06 kB
import gradio as gr
from backend import get_handler
import uuid
CUSTOM_CSS = """
/* Highlight the entire message box for the bot */
.bot-highlight {
background-color: yellow !important;
padding: 0px;
border-radius: 8px;
}
"""
MAPPINGS = {"GorillaFileSystem": "gorilla_file_system",
"MathAPI": "math_api",
"MessageAPI": "message_api",
"TwitterAPI": "posting_api",
"TicketAPI": "ticket_api",
"TradingBot": "trading_bot",
"TravelAPI": "travel_booking",
"VehicleControlAPI": "vehicle_control"}
MODELS = ["gpt-4o-mini-2024-07-18-FC", "gpt-4o-2024-08-06-FC", "gpt-4o-mini-2024-07-18-FC",
"gpt-4-turbo-2024-04-09-FC", "gpt-3.5-turbo-0125-FC"]
CATEGORIES = ["GorillaFileSystem", "MathAPI", "MessageAPI", "TwitterAPI",
"TicketAPI", "TradingBot", "TravelAPI", "VehicleControlAPI"]
DEFAULT_MODEL_1 = MODELS[0]
DEFAULT_MODEL_2 = MODELS[1]
DEFAULT_TEMPERATURE_1 = 0.7
DEFAULT_TEMPERATURE_2 = 0.4
INITIAL_CHAT_HISTORY = [
{"role": "user", "content": "Hi, can you help me with some tasks?"},
{"role": "assistant", "content": "Hello there! How can I assist you today?"},
]
EXAMPLE_1_CONFIG = {"GorillaFileSystem": {"root": {"workspace": {"type": "directory", "contents": {"document": {"type": "directory", "contents": {"final_report.pdf": {"type": "file", "content": "Year2024 This is the final report content including budget analysis and other sections."}, "previous_report.pdf": {"type": "file", "content": "Year203 This is the previous report content with different budget analysis."}}}, "archive": {"type": "directory", "contents": {}}}}}}, "TwitterAPI": {"tweet_counter": 3, "tweets": {"0": {"id": 0, "username": "analyst_pro", "content": "Just finished analyzing the reports!", "tags": ["#analysis", "#reports"], "mentions": []}, "1": {"id": 1, "username": "analyst_pro", "content": "Budget analysis insights coming soon!", "tags": ["#budget", "#analysis", "#insights"], "mentions": []}, "2": {"id": 2, "username": "analyst_pro", "content": "Stay tuned for more updates!", "tags": ["#updates", "#staytuned"], "mentions": []}}, "username": "analyst_pro", "password": "Kj8#mP9$vL2"}}
EXAMPLE_2_CONFIG = {"TradingBot": {"orders": {"12345": {"symbol": "AAPL", "price": 210.65, "num_shares": 10, "status": "Completed"}, "order_type": "Buy"}, "account_info": {"account_id": 12345, "balance": 10000.0, "binding_card": 1974202140965533}, "authenticated": True, "market_status": "Closed", "order_counter": 12446, "stocks": {"AAPL": {"price": 227.16, "percent_change": 0.17, "volume": 2.552, "MA(5)": 227.11, "MA(20)": 227.09}, "GOOG": {"price": 2840.34, "percent_change": 0.24, "volume": 1.123, "MA(5)": 2835.67, "MA(20)": 2842.15}, "TSLA": {"price": 667.92, "percent_change": -0.12, "volume": 1.654, "MA(5)": 671.15, "MA(20)": 668.2}, "MSFT": {"price": 310.23, "percent_change": 0.09, "volume": 3.234, "MA(5)": 309.88, "MA(20)": 310.11}, "NVDA": {"price": 220.34, "percent_change": 0.34, "volume": 1.234, "MA(5)": 220.45, "MA(20)": 220.67}, "ALPH": {"price": 1320.45, "percent_change": -0.08, "volume": 1.567, "MA(5)": 1321.12, "MA(20)": 1325.78}, "OMEG": {"price": 457.23, "percent_change": 0.12, "volume": 2.345, "MA(5)": 456.78, "MA(20)": 458.12}, "QUAS": {"price": 725.89, "percent_change": -0.03, "volume": 1.789, "MA(5)": 726.45, "MA(20)": 728.0}, "NEPT": {"price": 88.34, "percent_change": 0.19, "volume": 0.654, "MA(5)": 88.21, "MA(20)": 88.67}, "SYNX": {"price": 345.67, "percent_change": 0.11, "volume": 2.112, "MA(5)": 345.34, "MA(20)": 346.12}}, "watch_list": ["NVDA"], "transaction_history": []}}
EXAMPLE_3_CONFIG = None
SINGLE_MODEL_BOT_EXAMPLE_SETTING = {
"Example 1 - GFSFileSystem": (MODELS[0], 0.8, CATEGORIES[0], "Move final_report.pdf' within document directory to 'temp' directory in document. Make sure to create the directory", EXAMPLE_1_CONFIG),
"Example 2 - TradingBot": (MODELS[1], 0.9, CATEGORIES[5], "I'm contemplating enhancing my investment portfolio with some tech industry assets, and I've got my eye on Nvidia Corp. I'm keen to know its current stock price, and would appreciate if you could source this information for me.", EXAMPLE_2_CONFIG),
"Example 3 - TravelAPI": (MODELS[2], 0.7, CATEGORIES[6], "As I plan a getaway, I'm curious about all the airports available for my travel. Would you share that information with me?", EXAMPLE_3_CONFIG),
}
DUAL_MODEL_BOT_1_EXAMPLE_SETTING = {
"Example 1 - GFSFileSystem": (MODELS[0], 0.8, CATEGORIES[0], "Move final_report.pdf' within document directory to 'temp' directory in document. Make sure to create the directory", EXAMPLE_1_CONFIG),
"Example 2 - TradingBot": (MODELS[1], 0.9, CATEGORIES[5], "I'm contemplating enhancing my investment portfolio with some tech industry assets, and I've got my eye on Nvidia Corp. I'm keen to know its current stock price, and would appreciate if you could source this information for me.", EXAMPLE_2_CONFIG),
"Example 3 - TravelAPI": (MODELS[2], 0.7, CATEGORIES[6], "As I plan a getaway, I'm curious about all the airports available for my travel. Would you share that information with me?", EXAMPLE_3_CONFIG),
}
DUAL_MODEL_BOT_2_EXAMPLE_SETTING = {
"Example 1 - GFSFileSystem": (MODELS[3], 0.5, CATEGORIES[0], "Move final_report.pdf' within document directory to 'temp' directory in document. Make sure to create the directory", EXAMPLE_1_CONFIG),
"Example 2 - TradingBot": (MODELS[4], 0.6, CATEGORIES[5], "I'm contemplating enhancing my investment portfolio with some tech industry assets, and I've got my eye on Nvidia Corp. I'm keen to know its current stock price, and would appreciate if you could source this information for me.", EXAMPLE_2_CONFIG),
"Example 3 - TravelAPI": (MODELS[0], 0.4, CATEGORIES[6], "As I plan a getaway, I'm curious about all the airports available for my travel. Would you share that information with me?", EXAMPLE_3_CONFIG),
}
def get_initial_state():
return list(INITIAL_CHAT_HISTORY)
def print_like_dislike(x: gr.LikeData):
print(x.index, x.value, x.liked)
def equalize_and_zip(list1, list2):
if list1 == None:
list1 = []
if list2 == None:
list2 = []
if isinstance(list1, str):
list1 = [list1]
if isinstance(list2, str):
list2 = [list2]
max_len = max(len(list1), len(list2))
list1.extend([None] * (max_len - len(list1)))
list2.extend([None] * (max_len - len(list2)))
return list(zip(list1, list2))
def consume_data(shared_queue):
none_list = []
while True:
data = shared_queue.get()
if data is None:
if data in none_list:
print("[Consumer] No more data to consume. Exiting.")
break
else:
none_list.append(data)
yield data
def initialize_empty_test_entry():
return {
"initial_config": {},
"involved_classes": [],
"id": str(uuid.uuid4()),
"question": [],
"function": []
}