> For the complete documentation index, see [llms.txt](https://sully.gitbook.io/sully.ai-docs/FEM1tMOJsSSszbLOgKLA/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sully.gitbook.io/sully.ai-docs/FEM1tMOJsSSszbLOgKLA/focused-agentic-architecture/scribe-agent.md).

# Scribe Agent

## Note Style/Template Creation

### Objective

Enable users to easily create custom note styles or templates intuitively.

**Note:** "Style" and "template" are used interchangeably.

### Background

At present, Sully offers a simple method for creating note styles through a free-form text area. This can be overwhelming due to unclear starting points and the expertise required in prompt design.

### Solution

Introduce a user-friendly wizard to guide through template creation. This should be intuitive and support voice input. The design consists of three parts:

1. Frontend creation flow
2. Structured representation of the note template
3. Template creation and execution logic

#### Structured Representation

The template will be a JSON object stored in GCS:

```json
{
  "id": "<template-id>",
  "title": "Test Template",
  "sections": [
    {
      "id": "<section-id>",
      "title": "<section-title>",
      "descp": "<section description>",
      "templates": [
        {
          "voice_trigger": "<voice-trigger>",
          "text": "<template-text>",
          "text_file": "<gcs-path>"
        },
        {
          ...
        }
      ]
    },
    ...
  ]
}
```

Template metadata will be stored in Firebase, with JSON in GCS:

**Firebase Path:**`/copilot/trial/users/<user-email>/note_templates/<template-id>/…`

**Firebase Map:**

```json
{ "title": "<title>", "template_path": "<gcs-path>" }
```

**GCS JSON Path:**`<bucket>/<user-email>/note_templates/<template-id>.json`

Each section converts to an LLMChain for execution, integrating inputs like transcripts and patient charts. All chains execute in parallel, and the results are merged for the final note.

```python
finalNote = generateNote(noteTemplate, transcript, ph)
llmChain = getLLMChain(noteTemplate, transcript, ph)
llmChain.execute()
```

Sully-designed prompts are hosted and versioned on Autoblocks.

#### Frontend Wizard

An intuitive wizard will help create templates and define sections, saving the resulting JSON in Firebase and GCS.

#### Note Generation/Execution

Upon recording a visit, users select the note template via dropdown. Only the template ID is sent in requests, and the server constructs the template.

Server-side actions:

1. Retrieve the template JSON from Firebase using `templateId`.
2. Access the template JSON from GCS using `templateId` or `gcsPath`.
3. Process voice-triggered templates from their GCS paths, ready to be converted to an LLMChain.

**Template: LLMChain Structure**

```json
{
  "chainId": "template.id",
  "name": "template.title",
  "execution": "parallel",
  "tasks": [...] // tasks can be LLMChain or LLMTask
}
```

**Section: LLMTask/LLMChain Structure**

```json
{
  "chainId": "section.id",
  "name": "section.title",
  "execution": "sequential",
  "tasks": [...]
}
```

A section-level LLMChain identifies which template to trigger based on voice prompts and executes necessary tasks sequentially.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sully.gitbook.io/sully.ai-docs/FEM1tMOJsSSszbLOgKLA/focused-agentic-architecture/scribe-agent.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
