">
 

AIchain Skill: A Prompt as a Reusable Object

Iniciado por joomlamz, Hoje at 10:30

Respostas: 1   |   Visualizações: 1

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

**Automatizando a Revisão de Documentos com o Google Workspace Studio e o NotebookLM**

Bem-vindos a esta discussão sobre a automatização da revisão de documentos utilizando o Google Workspace Studio e o NotebookLM. Como especialista em tecnologia, vou abordar os pontos principais e fornecer uma análise técnica sobre esta ferramenta inovadora.

**O que é o Google Workspace Studio?**

O Google Workspace Studio é uma plataforma de desenvolvimento de aplicações que permite criar interfaces de usuário (UI) personalizadas para as aplicações do Google Workspace, incluindo o Google Drive, Google Docs e Google Sheets. Com o Studio, é possível criar aplicações que automatizem tarefas complexas, como a revisão de documentos, de forma eficiente e escalável.

**O que é o NotebookLM?**

O NotebookLM é uma ferramenta de machine learning que permite criar modelos de linguagem avançados para processamento de linguagem natural (NLP). Com o NotebookLM, é possível criar modelos que possam analisar e processar grandes volumes de texto, incluindo documentos, e fornecer insights valiosos.

**Como automatizar a revisão de documentos com o Google Workspace Studio e o NotebookLM?**

A combinação do Google Workspace Studio e o NotebookLM permite criar aplicações que automatizem a revisão de documentos de forma eficiente e escalável. Aqui estão os passos gerais para implementar esta solução:

1. **Crie uma aplicação com o Google Workspace Studio**: Utilize o Studio para criar uma aplicação que possa acessar e processar documentos do Google Drive.
2. **Integre o NotebookLM**: Integre o NotebookLM à aplicação criada com o Studio para analisar e processar os documentos.
3. **Crie um modelo de linguagem**: Crie um modelo de linguagem com o NotebookLM que possa analisar e processar os documentos de forma eficiente.
4. **Implemente a revisão automática**: Implemente a revisão automática dos documentos utilizando o modelo de linguagem criado com o NotebookLM.

**Vantagens e desvantagens**

A combinação do Google Workspace Studio e o NotebookLM apresenta várias vantagens, incluindo:

* **Automatização de tarefas complexas**: A aplicação pode automatizar tarefas complexas, como a revisão de documentos, de forma eficiente e escalável.
* **Melhoria da produtividade**: A aplicação pode melhorar a produtividade dos usuários, reduzindo o tempo necessário para revisar documentos.
* **Melhoria da qualidade**: A aplicação pode melhorar a qualidade dos documentos, reduzindo erros e inconsistências.

No entanto, há também algumas desvantagens a considerar:

* **Complexidade**: A implementação da aplicação pode ser complexa e requerer habilidades avançadas em tecnologia.
* **Custo**: A aplicação pode ser cara de implementar e manter.

**Conclusão**

A automatização da revisão de documentos com o Google Workspace Studio e o NotebookLM é uma ferramenta inovadora que pode melhorar a produtividade e a qualidade dos documentos. Embora apresente algumas desvantagens, a combinação do Studio e o NotebookLM é uma solução viável para organizações que buscam melhorar a eficiência e a qualidade de suas operações.

**Para garantir que os vossos projetos e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em https://aplichost.com**

AIchain Skill: A Prompt as a Reusable Object



Tópico: AIchain Skill: A Prompt as a Reusable Object
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
A prompt buried in an f-string is technical debt. You can't test it. You can't save it to a file. You can't hand it to a colleague and say "here's the extraction logic." The moment you hard-code a prompt into a string, you've welded your application logic to a single, frozen instruction — one that will rot as models improve and requirements shift.

Skill fixes that. It turns a prompt into a first-class object: something you can construct, parameterize, persist, reload, version-control, and swap models underneath — all without changing a single line of business logic.



The Problem with Naked Strings


Consider the typical approach:

response = client.chat(f"What is {topic} in one sentence?")

This line mixes three concerns: the prompt template, the runtime data, and the model that executes it. Change any one of those, and you're editing the same line. Want to test the prompt with different inputs? You rewrite the call. Want to try a cheaper model? You rewire the client. Want a non-developer on your team to review the prompt? You point them at application code.

SQL solved this exact problem decades ago. Write a parameterized query once, bind values at execution time, and the database engine is a separate concern entirely. Skill applies the same separation to prompts.



Skill in Practice


Install the library and its serialization dependency:

pip install yait-aichain pyyaml

Here's the simplest Skill — a one-sentence explainer with a {topic} variable:

import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill

skill = Skill(
model=Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
input={
"messages": [{
"role": "user",
"parts": ["What is {topic} in one sentence?"],
}]
},
)

result = skill.run(variables={"topic": "machine learning"})
print(result)

Two things to notice. First, {topic} is a placeholder inside the prompt template — not an f-string resolved at definition time. The value gets substituted only when you call .run(variables={...}). Second, the model is declared at construction, not at call time. The Skill knows which model it targets.

That separation matters. The same Skill instance can run with {"topic": "quantum computing"}, then {"topic": "gradient descent"}, without rebuilding anything. The template stays fixed; the data varies. Exactly like a prepared statement.



One Prompt, Three Models


The key differentiator of a Skill: it's built around the model most effective for a specific task — balancing quality, speed, and cost. What one model handled well six months ago, another can do dramatically better today. Skill lets you act on that without rewriting your logic.

Here's what that looks like in code:

import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill

PROMPT = {
"messages": [{
"role": "user",
"parts": ["What is {topic} in one sentence?"],
}]
}

models = [
Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
Model("gpt-4o-mini",       api_key=os.getenv("OPENAI_API_KEY")),
Model("gemini-2.5-flash",  api_key=os.getenv("GOOGLE_AI_API_KEY")),
]

for model in models:
skill  = Skill(model=model, input=PROMPT)
result = skill.run(variables={"topic": "machine learning"})
print(f"[{model.name}]\n{result}\n")

The prompt template is defined once. The loop swaps only the Model. You get three answers from three providers — Anthropic, OpenAI, Google — with zero changes to the prompt logic. (model.name is a string attribute on Model that returns the identifier you passed at construction, used here purely for labeling output.) When a newer model returns a better answer at a fraction of the cost, you change one string and move on.



Save, Version, Share


The moment a prompt lives in a Python file, it's coupled to that file's deployment cycle. Edit the prompt, redeploy the app. That's fine until you want a prompt engineer — or your future self at 11pm — to iterate on prompts independently.

Skill supports serialization to YAML. Same idea as versioning a migration script: track every change in Git, roll back when new wording degrades output quality.

import os
from yait_aichain.models import Model
from yait_aichain.skills import Skill

YAML_PATH = "validator_skill.yaml"

# Build and save
skill = Skill(
model=Model("claude-sonnet-4-6", api_key=os.getenv("ANTHROPIC_API_KEY")),
input={
"messages": [{
"role": "user",
"parts": ["Review the following text and return only corrected version: {text}"],
}]
},
)
skill.save(YAML_PATH)

# Later — reload and run
loaded_skill = Skill.load(YAML_PATH, api_key=os.getenv("ANTHROPIC_API_KEY"))
result = loaded_skill.run(variables={"text": "The quick brown fox jump over the lazy dog."})
print(result)

A few details worth highlighting:


API keys never hit disk. skill.save() serializes the model name, prompt template, and configuration — but intentionally strips the API key. You pass it from the environment when you call Skill.load(). No secrets in your repo.


YAML is human-readable. A teammate can open validator_skill.yaml, tweak the prompt wording, and commit it — without touching Python.


The file is an artifact. Store it in a prompts/ directory, tag it v1.2, run automated tests against it in CI. If new wording degrades output quality, git revert and you're done.



Why Objects Beat Strings


When a prompt becomes an object, workflows that strings simply can't support become straightforward:


Testing. Write a unit test that loads a Skill, runs it against five known inputs, and asserts output structure. Run that test on every PR.


Versioning. Store Skills as YAML files in a prompts/ directory. Git tracks every change, who made it, and when — just as it tracks schema migrations.


Model migration. When a newer, faster, or cheaper model appears, update the model name in the YAML file. The prompt template and your application code stay untouched.


Collaboration. A domain expert writes the prompt. A developer writes the pipeline. Neither blocks the other.


Independent deployment. Ship new prompt versions without redeploying application code. Load the latest YAML from a shared path or artifact store.



The API at a Glance


# Construct
Skill(model: Model, input: dict)

# Run with variable substitution
skill.run(variables: dict = {}) -> str

# Persist
skill.save(path: str) -> None

# Restore (api_key is a keyword argument)
Skill.load(path: str, *, api_key: str) -> Skill

Four operations. That's the entire surface area. A Skill does exactly one thing — execute a parameterized prompt against a specific model — and exposes exactly the controls you need to manage it over time.



From String to Strategy


The shift from f-string to Skill is small in code and large in practice. You go from a prompt that's invisible, untestable, and welded to one model — to one that's named, versioned, portable, and model-aware.

Next in this series: Chain — what happens when one Skill's output feeds into another. But it all starts here, with one prompt treated as a real artifact, not a throwaway string.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: