Remix.run Logo
convo-lang 5 days ago

Its both a library and a language. You can use it directly in TypeScript and Javascript using the `convo` tagged template literal function from the @convo-lang/convo-lang NPM package.

https://www.npmjs.com/package/@convo-lang/convo-lang

Here is an example of using in TypeScript: ``` ts import {convo} from "@convo-lang/convo-lang"

const categorizeMessage=convo`

    > define
    UserMessage = struct(
        sentiment: enum("happy" "sad" "mad" "neutral")
        type: enum("support-request" "complaint" "compliment" "other")
        # A an array of possible solutions for a support-request or complaint
        suggestedSolutions?: array(string)
        # The users message verbatim
        userMessage: string
    )

    @json UserMessage
    > user
    Categorize the following user message:

    <user-message>
    ${userMessage}
    </user-message>
`

console.log(categorizeMessage)

```

And for a userMessage that looks something like:

---- My Jackhawk 9000 broke in half when I was trying to cut the top of my 67 Hemi. This thing is a piece of crap. I want my money back!!! ----

The return JSON object would look like: ``` json

{

    "sentiment": "mad",

    "type": "complaint",

    "suggestedSolutions": [

        "Offer a full refund to the original payment method",

        "Provide a free replacement unit under warranty",

        "Issue a prepaid return shipping label to retrieve the broken item",

        "Offer store credit if a refund is not preferred",

        "Escalate to warranty/support team for expedited resolution"

    ],

    "userMessage": "My Jackhawk 9000 broke in half when I was trying to cut the top of my 67 Hemi. This thing is a piece of crap. I want my money back!!!"
}

```