Every new function is defined inside the functions/ directory and is immediately made available for use during a conversation.
Inside the directory, when you create a file, Symphony automatically generates a base template depending on the language, for you to get started.
TypeScript
JSDOC comments are used to specify descriptions in natural language.
project-name
functions
kelvinToCelsius.ts
interfaces
symphony
.env
package.json
kelvinToCelsius.ts
1/**
2* value: Value in Kelvin
3*/4interfaceSymphonyRequest{5 value:number;6}78/**
9* value: Value in Celsius
10*/11interfaceSymphonyResponse{12 value:number;13}1415/**
16* Converts Kelvin to Celsius
17*/18exportconst handler =(request:SymphonyRequest):SymphonyResponse=>{19const{ value }= request;2021return{22 value:Math.round(value -273.15),23};24};25
Python
A combination of Pydantic and comments are used to specify descriptions in natural language.
project-name
functions
kelvinToCelsius.py
interfaces
symphony
.env
package.json
kelvinToCelsius.py
12from pydantic import BaseModel, Field
345classSymphonyRequest(BaseModel):6 name:str= Field(description="Name of person")789classSymphonyResponse(BaseModel):10 greeting:str= Field(description="Greeting")111213defhandler(request: SymphonyRequest)-> SymphonyResponse:14"""
15 Greet person by name
16 """1718return SymphonyResponse(19 greeting='Hello {name}'.format(name=request['name']))2021
Need Help?
Hop into our Discord community for some friendly chats and support around our projects. We would love to have you on board and hear your thoughts!