@ -0,0 +1,33 @@
|
||||
import { createAction } from '@typebot.io/forge'
|
||||
import { auth } from '../auth'
|
||||
import { parseChatCompletionOptions } from '@typebot.io/openai-block/shared/parseChatCompletionOptions'
|
||||
import { getChatCompletionSetVarIds } from '@typebot.io/openai-block/shared/getChatCompletionSetVarIds'
|
||||
import { getChatCompletionStreamVarId } from '@typebot.io/openai-block/shared/getChatCompletionStreamVarId'
|
||||
import { runChatCompletion } from '@typebot.io/openai-block/shared/runChatCompletion'
|
||||
import { runChatCompletionStream } from '@typebot.io/openai-block/shared/runChatCompletionStream'
|
||||
import { defaultTogetherOptions } from '../constants'
|
||||
|
||||
export const createChatCompletion = createAction({
|
||||
name: 'Create chat completion',
|
||||
auth,
|
||||
options: parseChatCompletionOptions({
|
||||
modelHelperText:
|
||||
'You can find the list of all the models available [here](https://docs.together.ai/docs/inference-models#chat-models). Copy the model string for API.',
|
||||
}),
|
||||
getSetVariableIds: getChatCompletionSetVarIds,
|
||||
run: {
|
||||
server: (params) =>
|
||||
runChatCompletion({
|
||||
...params,
|
||||
config: { baseUrl: defaultTogetherOptions.baseUrl },
|
||||
}),
|
||||
stream: {
|
||||
getStreamVariableId: getChatCompletionStreamVarId,
|
||||
run: (params) =>
|
||||
runChatCompletionStream({
|
||||
...params,
|
||||
config: { baseUrl: defaultTogetherOptions.baseUrl },
|
||||
}),
|
||||
},
|
||||
},
|
||||
})
|
15
packages/forge/blocks/togetherAi/auth.ts
Normal file
15
packages/forge/blocks/togetherAi/auth.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { option, AuthDefinition } from '@typebot.io/forge'
|
||||
|
||||
export const auth = {
|
||||
type: 'encryptedCredentials',
|
||||
name: 'Together account',
|
||||
schema: option.object({
|
||||
apiKey: option.string.layout({
|
||||
label: 'API key',
|
||||
isRequired: true,
|
||||
inputType: 'password',
|
||||
helperText:
|
||||
'You can get your API key [here](https://api.together.xyz/settings/api-keys).',
|
||||
}),
|
||||
}),
|
||||
} satisfies AuthDefinition
|
3
packages/forge/blocks/togetherAi/constants.ts
Normal file
3
packages/forge/blocks/togetherAi/constants.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export const defaultTogetherOptions = {
|
||||
baseUrl: 'https://api.together.xyz/v1',
|
||||
} as const
|
14
packages/forge/blocks/togetherAi/index.ts
Normal file
14
packages/forge/blocks/togetherAi/index.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { createBlock } from '@typebot.io/forge'
|
||||
import { TogetherAiLogo } from './logo'
|
||||
import { auth } from './auth'
|
||||
import { createChatCompletion } from './actions/createChatCompletion'
|
||||
|
||||
export const togetherAi = createBlock({
|
||||
id: 'together-ai',
|
||||
name: 'Together',
|
||||
fullName: 'Together AI',
|
||||
tags: ['ai', 'openai', 'chat', 'completion'],
|
||||
LightLogo: TogetherAiLogo,
|
||||
auth,
|
||||
actions: [createChatCompletion],
|
||||
})
|
18
packages/forge/blocks/togetherAi/logo.tsx
Normal file
18
packages/forge/blocks/togetherAi/logo.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import React from 'react'
|
||||
|
||||
export const TogetherAiLogo = (props: React.SVGProps<SVGSVGElement>) => (
|
||||
<svg viewBox="0 0 32 32" {...props}>
|
||||
<g clipPath="url(#clip0_542_18748)">
|
||||
<rect width="32" height="32" rx="5.64706" fill="#F1EFED" />
|
||||
<circle cx="22.8233" cy="9.64706" r="5.64706" fill="#D3D1D1" />
|
||||
<circle cx="22.8233" cy="22.8238" r="5.64706" fill="#D3D1D1" />
|
||||
<circle cx="9.64706" cy="22.8238" r="5.64706" fill="#D3D1D1" />
|
||||
<circle cx="9.64706" cy="9.64706" r="5.64706" fill="#0F6FFF" />
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_542_18748">
|
||||
<rect width="32" height="32" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
)
|
17
packages/forge/blocks/togetherAi/package.json
Normal file
17
packages/forge/blocks/togetherAi/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@typebot.io/together-ai-block",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.ts",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@typebot.io/forge": "workspace:*",
|
||||
"@typebot.io/lib": "workspace:*",
|
||||
"@typebot.io/tsconfig": "workspace:*",
|
||||
"@typebot.io/variables": "workspace:*",
|
||||
"@typebot.io/openai-block": "workspace:*",
|
||||
"@types/react": "18.2.15",
|
||||
"typescript": "5.3.2"
|
||||
}
|
||||
}
|
10
packages/forge/blocks/togetherAi/tsconfig.json
Normal file
10
packages/forge/blocks/togetherAi/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "@typebot.io/tsconfig/base.json",
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"],
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"noEmit": true,
|
||||
"jsx": "react"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user