feat(celular): rosto e app usam SSE e token; remove telas legadas
- carinha.html assina /eventos (expressao, app_config, conversa, reacao, recarregar) e volta ao polling de /fila sozinho se o SSE cair; foto dos ajustes a cada (re)conexao; token (?t=) vai em todo fetch ao servidor - APK 0.8-token: token nas preferencias e no menu de toque longo, enviado na pagina, no HTTP do Java e ao llama-server (--api-key); trocar servidor por Intent exige o token salvo; camera/microfone so para o servidor configurado ou a copia local - cerebro/conversa mandam a chave ao llama-server do S10 - servidor: evento SSE 'recarregar'; remove /camera/frame e /app/connect; enderecos antigos redirecionam para a secao do painel novo - remove dashboard, painel, conversa, emojis, treinamento, braco, servos, api, scripts e CSS antigos, audio-robot.js e servir-local.bat - logica pura do painel em web/src/lib/nucleo.ts com testes node --test (substitui test_movimentos.js e test_rastreamento.js) - testes de navegador portados para o painel novo (rtc, rosto, rastreamento) - README, docs/PAINEL.md e docs/SEGURANCA.md reescritos; versao 0.8.0; carinha-pc.service le /etc/carinha.env Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -18,6 +18,8 @@ class Cerebro:
|
||||
def __init__(self,path,controle,enviar):
|
||||
self.path=Path(path);self.controle=controle;self.enviar=enviar
|
||||
self.endpoint=os.environ.get('CARINHA_IA_URL','http://127.0.0.1:8101')
|
||||
# O llama-server do S10 fica na rede: com token, ele exige a mesma chave (--api-key).
|
||||
self.chave=os.environ.get('CARINHA_IA_CHAVE') or os.environ.get('CARINHA_TOKEN','')
|
||||
self.executor='S10' if '192.168.1.16' in self.endpoint else 'Orange Pi'
|
||||
self.lock=threading.Lock();self.ativo=False;self.pending=None;self.busy=False
|
||||
self.conversando=False;self.history=[];self.result=None;self.error='';self.last=0;self.generation=0
|
||||
@@ -25,6 +27,10 @@ class Cerebro:
|
||||
try:self.ativo=json.loads(self.path.read_text())['ativo'] is True
|
||||
except (OSError,ValueError,KeyError,TypeError):pass
|
||||
threading.Thread(target=self.loop,daemon=True).start()
|
||||
def cabecalhos(self):
|
||||
h={'Content-Type':'application/json'}
|
||||
if self.chave:h['Authorization']='Bearer '+self.chave
|
||||
return h
|
||||
def config(self,ativo):
|
||||
if type(ativo) is not bool:raise ValueError('ativo deve ser booleano')
|
||||
with self.lock:
|
||||
@@ -43,7 +49,7 @@ class Cerebro:
|
||||
return dict(ok=True)
|
||||
def decide(self,event):
|
||||
payload=dict(model='local',messages=[dict(role='system',content='Você é Carinha, um pequeno robô curioso, gentil e expressivo, inspirado em WALL-E. Escolha uma expressão adequada ao evento. Varie os gestos recentes. Responda somente JSON.'),dict(role='user',content=json.dumps(dict(evento=event,recentes=self.history[-3:]),ensure_ascii=False)+' /no_think')],max_tokens=32,temperature=.7,chat_template_kwargs=dict(enable_thinking=False),response_format=dict(type='json_schema',json_schema=dict(name='intencao',strict=True,schema=dict(type='object',properties=dict(gesto=dict(type='string',enum=list(GESTOS))),required=['gesto'],additionalProperties=False))))
|
||||
request=Request(self.endpoint+'/v1/chat/completions',data=json.dumps(payload).encode(),headers={'Content-Type':'application/json'})
|
||||
request=Request(self.endpoint+'/v1/chat/completions',data=json.dumps(payload).encode(),headers=self.cabecalhos())
|
||||
start=time.monotonic()
|
||||
with urlopen(request,timeout=90) as response:data=json.load(response)
|
||||
content=data['choices'][0]['message']['content']
|
||||
|
||||
Reference in New Issue
Block a user