File size: 818 Bytes
c577353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
from tools import FreightAgent, EXAMPLE_QUERIES
from utils import initialize_database
from smolagents import CodeAgent, HfApiModel, GradioUI
import os
from dotenv import load_dotenv
from sql_data import sql_query, get_schema, get_csv_as_dataframe

# Load environment variables
load_dotenv()

# Initialize the database if it doesn't exist
if not os.path.exists("freights.db"):
    csv_url = "https://huggingface.co/datasets/sasu-SpidR/fretmaritime/resolve/main/freights.csv"
    initialize_database(csv_url)

# Create the main agent
model_id = "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
model = HfApiModel(model_id=model_id, token=os.environ["HF_API_KEY"])

agent = CodeAgent(tools=[sql_query, get_schema, get_csv_as_dataframe], model=model)

if __name__ == "__main__":
    GradioUI(agent).launch()