# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
