Metadata-Version: 2.2
Name: skill-framework
Version: 0.1.0
Summary: AnswerRocket skill framework
Requires-Python: >=3.10.7
Description-Content-Type: text/markdown
Requires-Dist: pydantic
Requires-Dist: pathspec
Requires-Dist: jinja2
Provides-Extra: ui
Requires-Dist: fastapi[standard]; extra == "ui"

This is a framework for creating AnswerRocket skills. It provides decorators
and utilities for turning your code into something that can be invoked by our platform.

There are three command line utilities installed along with this library:

`package-skill <your_entry_file>.py` - packages your skill for upload to your AnswerRocket environment. This will generate a
manifest file from the `@skill`-annotated function in the file and then combine everything into a zip archive. This
utility will honor a .gitignore file if one is present in the project root.

`preview-server` - runs a local preview server to view rendered layouts locally.

`init-skill <skill_name>` to bootstrap a new skill. This will create the following:
```
.
├── .gitignore
├── resources/
├── .previews/
└── <skill_name>.py
```

`resources/` can be used for static resources that may be referenced by your layouts. The preview server can serve content
from this directory

`.previews/` is where generated preview layouts will be stored for viewing with the preview server

The `.gitignore` file will be pre-populated with entries common to python projects, along with the .preview directory.
If you already have one, this script will not replace it.

A skill needs to have a `@skill` decorated entry point, like this:

```python
from skill_framework import skill, SkillParameters, SkillParameter, SkillOutput

@skill(
    name="my_skill",
    description="This is an example skill",
    parameters=[
        SkillParameter(
            name="dim",
            constrained_to="dimensions"
        )
    ]
)
def my_skill(parameters: SkillParameters):
    # you can access arguments to your parameters extracted from
    # natural language queries via the arguments field
    # other run-specific context will also be provided on this object
    # everything here is just a mocked up example, you can form the parts of the response
    # in any way that makes sense for your skill.
    data = get_some_data(parameters)
    visualization = create_visualization(data)
    narrative = create_narrative(data)
    prompt = create_chat_response_prompt(data, narrative)
    return SkillOutput(
      final_prompt=prompt,
      narrative=narrative,
      visualization=visualization
    )

def get_some_data(params):
    # use the client to get some data from a dataset
    pass

def create_visualization(data):
    # embed the data into a json layout payload
    pass

def create_narrative(data):
    # make some description of the data to appear as the narrative part of the response
    pass

def create_chat_response_prompt(data, narrative):
    # use the data and narrative to create a prompt for the model that will generate the response
    # in the chat window
    pass
```

You can generate a preview for viewing with the `preview-server` by passing your skill's output to `preview_skill`:

```python
from skill_framework import SkillParameters, preview_skill


if __name__ == '__main__':
    mock_params = SkillParameters(
        # mock values here
    )
    output = your_skill(mock_params)
    # this utility function will write the output to where the local preview server expects it
    preview_skill(your_skill, output)
```
