functions
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.
kelvinToCelsius.ts
.env
package.json
kelvinToCelsius.ts
1/**
2* value: Value in Kelvin
3*/
4interface SymphonyRequest {
5  value: number;
6}
7
8/**
9* value: Value in Celsius
10*/
11interface SymphonyResponse {
12  value: number;
13}
14
15/**
16* Converts Kelvin to Celsius
17*/
18export const handler = (request: SymphonyRequest): SymphonyResponse => {
19  const { value } = request;
20
21  return {
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.
kelvinToCelsius.py
.env
package.json
kelvinToCelsius.py
1
2from pydantic import BaseModel, Field
3
4
5class SymphonyRequest(BaseModel):
6    name: str = Field(description="Name of person")
7
8
9class SymphonyResponse(BaseModel):
10    greeting: str = Field(description="Greeting")
11
12
13def handler(request: SymphonyRequest) -> SymphonyResponse:
14    """
15     Greet person by name
16    """
17
18    return SymphonyResponse(
19        greeting='Hello {name}'.format(name=request['name']))
20
21
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!
Join us on Discord