Spaces:
Sleeping
Sleeping
File size: 2,573 Bytes
8eda9d9 e2f277d fabfaed 41afd18 e2f277d 41afd18 e2f277d 8eda9d9 41afd18 e2f277d 41afd18 fabfaed ff3fc07 eeaf028 41afd18 eeaf028 41afd18 eeaf028 41afd18 fabfaed eeaf028 41afd18 eeaf028 41afd18 eeaf028 fabfaed ff3fc07 fabfaed 41afd18 e2f277d 41afd18 fabfaed 8eda9d9 41afd18 fabfaed 6bff50c 8eda9d9 eeaf028 8eda9d9 fabfaed 41afd18 d7eb015 8eda9d9 41afd18 e2f277d | 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import streamlit as st
from smolagents import CodeAgent, HfHubModel, tool
# ##############################################################################
# 1. Configurando o modelo oficial usando a engrenagem correta
# ##############################################################################
# Usamos o HfHubModel com um token público temporário para liberar o acesso sem travar
modelo = HfHubModel(
model_id="Qwen/Qwen2.5-Coder-1.5B-Instruct"
)
# ##############################################################################
# 2. Ferramentas do Robô (Configuração exata em inglês)
# ##############################################################################
@tool
def mover_garra(item_id: str, coordenada_origem: list, coordenada_destino: list) -> str:
"""
Sends a command to the industrial arm to move an item in the warehouse.
Args:
item_id: The unique identifier or name of the item to be moved.
coordenada_origem: A list [x, y, z] indicating where the item currently is.
coordenada_destino: A list [x, y, z] indicating where the arm should move the item to.
"""
return f"Comando enviado com sucesso: {item_id} movido de {coordenada_origem} para {coordenada_destino}."
@tool
def analisar_estoque(imagem_camera_url: str) -> dict:
"""
Analyzes the warehouse image and returns the items found and their coordinates.
Args:
imagem_camera_url: The URL or identifier of the target camera.
"""
return {
"caixa_tipo_A": {"quantidade": 1, "coordenada": [10, 20, 5]},
"espaco_vazio_esteira": {"coordenada": [100, 50, 10]}
}
# ##############################################################################
# 3. Criando o Agente Oficial
# ##############################################################################
agente = CodeAgent(
tools=[analisar_estoque, mover_garra],
model=modelo
)
# Interface Visual do Streamlit
st.title("🤖 Agente de Organização de Estoque")
st.subheader("Executando a tarefa do robô...")
tarefa = """
1. Analise o estoque usando a câmera atual (URL: 'camera_estoque_1').
2. Se houver uma 'caixa_tipo_A', escolha as coordenadas dela.
3. Mande a garra mover a 'caixa_tipo_A' para o 'espaco_vazio_esteira'.
"""
with st.spinner("O agente está pensando e agindo..."):
try:
resultado = agente.run(tarefa)
st.success("Tarefa concluída com sucesso!")
st.write("**Resultado final do Agente:**")
st.info(resultado)
except Exception as e:
st.error(f"Nota de execução: {e}") |