Skip to content

Commit

Permalink
✨ Add usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jan 28, 2024
1 parent 36a7a3e commit 164bc0a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/getting-started/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Usage

To write your cognitive architectures with the funcchain syntax you need to import the `chain` function from the `funcchain` package.

```python
from funcchain import chain
```

This chain function it the core component of funcchain.
It takes the docstring, input arguments and return type of the function and compiles everything into a langchain prompt.
It then executes the prompt with your input arguments if you call the function and returns the parsed result.

```python
def hello(lang1: str, lang2: str, lang3: str) -> list[str]:
"""
Say hello in these 3 languages.
"""
return chain()

hello("German", "French", "Spanish")
```

The underlying chat in the background will look like this:

```html
<HumanMessage>
LANG1: German
LANG2: French
LANG3: Spanish

Say hello in these 3 languages.
</HumanMessage>

<AIMessage>
{
"value": ["Hallo", "Bonjour", "Hola"]
}
</AIMessage>
```

Funcchain is handling all the redundant and complicated structuring of your prompts so you can focus on the important parts of your code.

All input arguments are automatically added to the prompt so the model has context about what you insert.
The return type is used to force the model using a json-schema to always return a json object in the desired shape.

0 comments on commit 164bc0a

Please sign in to comment.