rogerscuall's picture
Upload folder using huggingface_hub
f71ec9b verified
import os
import gradio as gr
from dotenv import load_dotenv
from smolagents import CodeAgent, HfApiModel
# Load environment variables
load_dotenv()
# Get API token and model settings from environment variables
hf_api_token = os.getenv("HF_API_TOKEN")
model_name = os.getenv("MODEL_NAME", "meta-llama/Llama-3.3-70B-Instruct")
max_new_tokens = int(os.getenv("MAX_NEW_TOKENS", 500))
temperature = float(os.getenv("TEMPERATURE", 0.7))
from chatbot import agent
# Chat history to maintain conversation context
def relavant_info(message, history):
"""
Relevant information for the user
Args:
message (str): The input text to search through
letter (str): The letter to search for
Returns:
str: The relevant information extracted from the message
"""
response = agent.run(message)
return response
# Create Gradio interface
# demo = gr.ChatInterface(
# fn=relavant_info,
# title="Smol-Agent Chatbot",
# description="Ask me anything!",
# examples=[
# "What is machine learning?",
# "How does a transformer model work?",
# "Explain quantum computing in simple terms"
# ],
# theme=gr.themes.Soft()
# )
with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as ui:
gr.Markdown("# Deep Research")
query_textbox = gr.Textbox(label="What topic would you like to research?")
run_button = gr.Button("Run", variant="primary")
report = gr.Markdown(label="Report")
run_button.click(fn=relavant_info, inputs=query_textbox, outputs=report)
query_textbox.submit(fn=relavant_info, inputs=query_textbox, outputs=report)
# Launch the app
if __name__ == "__main__":
ui.launch(mcp_server=True)