Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f0d0aef
autogen models in flow
TudorCRL Jun 11, 2025
9362093
get rid of as many anys as possible
TudorCRL Jun 11, 2025
36efccd
Update packages/flow-client/src/events.ts
TudorCRL Jun 12, 2025
6896b49
Update packages/flow-client/src/events.ts
TudorCRL Jun 12, 2025
6982b34
add yarn
TudorCRL Jun 12, 2025
bb25479
Update packages/flow-client/scripts/generate-models.ts
TudorCRL Jun 12, 2025
9c6d2b8
some fixes
TudorCRL Jun 12, 2025
e8a8d05
minor changes
TudorCRL Jun 12, 2025
1974d2f
replace bad code
TudorCRL Jun 12, 2025
13f848a
add send message client method
TudorCRL Jun 12, 2025
2969a08
next
TudorCRL Jun 12, 2025
c8692c8
update packages
TudorCRL Jun 12, 2025
686bd1f
add alpha tag
TudorCRL Jun 12, 2025
481d961
add new methods
TudorCRL Jun 13, 2025
15107ac
format
TudorCRL Jun 13, 2025
73c661f
update generator
TudorCRL Jun 13, 2025
913fe48
update send input
TudorCRL Jun 13, 2025
4aa57ce
add llm_error
TudorCRL Jun 16, 2025
3b79545
update enums
TudorCRL Jun 16, 2025
cc3c977
update autogen
TudorCRL Jun 18, 2025
6256184
update examples
TudorCRL Jun 18, 2025
c03378d
Format
mnemitz Jun 18, 2025
1ac677d
bump rc versions
TudorCRL Jun 20, 2025
ccedf13
update types
TudorCRL Jun 26, 2025
1d2eb7b
yet another spec alteration
TudorCRL Jun 26, 2025
6b1ec77
bump version
TudorCRL Jun 26, 2025
fffcd39
update consts
TudorCRL Jun 26, 2025
ebb3d38
bump version to rc.7
TudorCRL Jun 26, 2025
9126144
fix rebase
TudorCRL Jun 27, 2025
ee10bc8
bump versions
TudorCRL Jun 27, 2025
6574758
Update packages/flow-client/scripts/generate-models.ts
TudorCRL Jun 27, 2025
26d3e10
remove dupe
TudorCRL Jun 27, 2025
f7adf26
update react
TudorCRL Jun 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/nextjs-flow/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
2 changes: 1 addition & 1 deletion examples/react-native-flow/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
useFlow,
useFlowEventListener,
} from '@speechmatics/flow-client-react';
import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useSharedValue } from 'react-native-reanimated';
import getFlowAPIJwt from '@/app/auth';
import VolumeDisplay from '@/app/volume-display';
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-client-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@speechmatics/flow-client-react",
"version": "0.2.1",
"version": "1.0.0-rc.7.1",
"description": "React hooks for interacting with the Speechmatics Flow API",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-client-react/src/flow-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function FlowProvider({
if (data.message === 'Error') {
console.error(data);
} else if (data.message === 'ConversationStarted') {
setSessionId(data.asr_session_id);
setSessionId(data.id);
}
});

Expand Down
21 changes: 17 additions & 4 deletions packages/flow-client-react/src/use-flow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StartConversationMessage } from '@speechmatics/flow-client';
import type { AddInput, StartConversation, ToolResult } from '@speechmatics/flow-client';
import { useCallback, useContext, useMemo } from 'react';
import { FlowContext } from './flow-context';

Expand All @@ -18,8 +18,8 @@ export function useFlow() {
config,
audioFormat,
}: {
config: StartConversationMessage['conversation_config'];
audioFormat?: StartConversationMessage['audio_format'];
config: StartConversation['conversation_config'];
audioFormat?: StartConversation['audio_format'];
},
) => client.startConversation(jwt, { config, audioFormat }),
[client],
Expand All @@ -32,14 +32,27 @@ export function useFlow() {
[client],
);

const sendToolResult = useCallback(
(toolResult: Exclude<ToolResult, 'message'>) =>
client.sendToolResult(toolResult),
[client],
);

const sendInput = useCallback(
(input: Exclude<AddInput, 'message'>) => client.sendInput(input),
[client],
);

return useMemo(
() => ({
startConversation,
endConversation,
sendAudio,
socketState,
sessionId,
sendToolResult,
sendInput,
}),
[startConversation, endConversation, sendAudio, socketState, sessionId],
[startConversation, endConversation, sendAudio, socketState, sessionId, sendToolResult, sendInput],
);
}
7 changes: 7 additions & 0 deletions packages/flow-client/models/AddInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface AddInput {
message: 'AddInput';
input: string;
interrupt_response?: boolean;
immediate?: boolean;
}
export type { AddInput };
9 changes: 9 additions & 0 deletions packages/flow-client/models/AddPartialTranscript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { RecognitionMetadata } from './RecognitionMetadata';
import type { RecognitionResult } from './RecognitionResult';
interface AddPartialTranscript {
message: 'AddPartialTranscript';
format?: string;
metadata: RecognitionMetadata;
results: RecognitionResult[];
}
export type { AddPartialTranscript };
9 changes: 9 additions & 0 deletions packages/flow-client/models/AddTranscript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { RecognitionMetadata } from './RecognitionMetadata';
import type { RecognitionResult } from './RecognitionResult';
interface AddTranscript {
message: 'AddTranscript';
format?: string;
metadata: RecognitionMetadata;
results: RecognitionResult[];
}
export type { AddTranscript };
2 changes: 2 additions & 0 deletions packages/flow-client/models/AttachesToEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type AttachesToEnum = 'next' | 'previous' | 'none' | 'both';
export type { AttachesToEnum };
5 changes: 5 additions & 0 deletions packages/flow-client/models/AudioAdded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface AudioAdded {
message: 'AudioAdded';
seq_no: number;
}
export type { AudioAdded };
5 changes: 5 additions & 0 deletions packages/flow-client/models/AudioEnded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface AudioEnded {
message: 'AudioEnded';
last_seq_no: number;
}
export type { AudioEnded };
7 changes: 7 additions & 0 deletions packages/flow-client/models/AudioFormat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { AudioFormatRawEncodingEnum } from './AudioFormatRawEncodingEnum';
interface AudioFormat {
type: 'raw';
encoding?: AudioFormatRawEncodingEnum;
sample_rate?: number;
}
export type { AudioFormat };
2 changes: 2 additions & 0 deletions packages/flow-client/models/AudioFormatRawEncodingEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type AudioFormatRawEncodingEnum = 'pcm_f32le' | 'pcm_s16le' | 'mulaw';
export type { AudioFormatRawEncodingEnum };
5 changes: 5 additions & 0 deletions packages/flow-client/models/AudioReceived.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface AudioReceived {
message: 'AudioReceived';
seq_no: number;
}
export type { AudioReceived };
9 changes: 9 additions & 0 deletions packages/flow-client/models/ConcurrentSessionUsageInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface ConcurrentSessionUsageInfo {
reason: string;
message: 'Info';
usage: number;
quota: number;
last_udpated?: string;
type: 'concurrent_session_usage';
}
export type { ConcurrentSessionUsageInfo };
5 changes: 5 additions & 0 deletions packages/flow-client/models/ConversationConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface ConversationConfig {
template_id: string;
template_variables?: { [name: string]: string };
}
export type { ConversationConfig };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ConversationDurationLimitInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ConversationDurationLimitInfo {
reason: string;
message: 'Info';
conversation_duration_limit: number;
type: 'conversation_duration_limit';
}
export type { ConversationDurationLimitInfo };
4 changes: 4 additions & 0 deletions packages/flow-client/models/ConversationEnded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface ConversationEnded {
message: 'ConversationEnded';
}
export type { ConversationEnded };
4 changes: 4 additions & 0 deletions packages/flow-client/models/ConversationEnding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface ConversationEnding {
message: 'ConversationEnding';
}
export type { ConversationEnding };
8 changes: 8 additions & 0 deletions packages/flow-client/models/ConversationStarted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { LanguagePackInfo } from './LanguagePackInfo';
interface ConversationStarted {
message: 'ConversationStarted';
id?: string;
asr_session_id?: string;
language_pack_info?: LanguagePackInfo;
}
export type { ConversationStarted };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ConversationTerminationWarning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ConversationTerminationWarning {
reason: string;
message: 'Warning';
conversation_termination: number;
type: 'conversation_termination';
}
export type { ConversationTerminationWarning };
5 changes: 5 additions & 0 deletions packages/flow-client/models/DebugObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface DebugObject {
llm?: boolean;
additionalProperties?: { [name: string]: unknown };
}
export type { DebugObject };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ErrorType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ErrorTypeEnum } from './ErrorTypeEnum';
interface ErrorType {
message: 'Error';
type: ErrorTypeEnum;
reason: string;
}
export type { ErrorType };
14 changes: 14 additions & 0 deletions packages/flow-client/models/ErrorTypeEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type ErrorTypeEnum =
| 'asr_error'
| 'protocol_error'
| 'config_error'
| 'idle_timeout'
| 'session_timeout'
| 'not_allowed'
| 'not_authorised'
| 'quota_exceeded'
| 'timelimit_exceeded'
| 'job_error'
| 'internal_error'
| 'unknown_error';
export type { ErrorTypeEnum };
12 changes: 12 additions & 0 deletions packages/flow-client/models/FlowClientMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { StartConversation } from './StartConversation';
import type { AudioReceived } from './AudioReceived';
import type { AudioEnded } from './AudioEnded';
import type { AddInput } from './AddInput';
import type { ToolResult } from './ToolResult';
type FlowClientMessage =
| StartConversation
| AudioReceived
| AudioEnded
| AddInput
| ToolResult;
export type { FlowClientMessage };
36 changes: 36 additions & 0 deletions packages/flow-client/models/FlowServerMessage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { ConversationStarted } from './ConversationStarted';
import type { AudioAdded } from './AudioAdded';
import type { AddPartialTranscript } from './AddPartialTranscript';
import type { AddTranscript } from './AddTranscript';
import type { ResponseStarted } from './ResponseStarted';
import type { ResponseCompleted } from './ResponseCompleted';
import type { ResponseInterrupted } from './ResponseInterrupted';
import type { ToolInvoke } from './ToolInvoke';
import type { ErrorType } from './ErrorType';
import type { Warning } from './Warning';
import type { ConversationTerminationWarning } from './ConversationTerminationWarning';
import type { Info } from './Info';
import type { StatusUpdateInfo } from './StatusUpdateInfo';
import type { ConversationDurationLimitInfo } from './ConversationDurationLimitInfo';
import type { ConcurrentSessionUsageInfo } from './ConcurrentSessionUsageInfo';
import type { ConversationEnding } from './ConversationEnding';
import type { ConversationEnded } from './ConversationEnded';
type FlowServerMessage =
| ConversationStarted
| AudioAdded
| AddPartialTranscript
| AddTranscript
| ResponseStarted
| ResponseCompleted
| ResponseInterrupted
| ToolInvoke
| ErrorType
| Warning
| ConversationTerminationWarning
| Info
| StatusUpdateInfo
| ConversationDurationLimitInfo
| ConcurrentSessionUsageInfo
| ConversationEnding
| ConversationEnded;
export type { FlowServerMessage };
6 changes: 6 additions & 0 deletions packages/flow-client/models/Info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface Info {
reason: string;
message: 'Info';
type: string;
}
export type { Info };
9 changes: 9 additions & 0 deletions packages/flow-client/models/LanguagePackInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { WritingDirectionEnum } from './WritingDirectionEnum';
interface LanguagePackInfo {
language_description?: string;
word_delimiter: string;
writing_direction?: WritingDirectionEnum;
itn?: boolean;
adapted?: boolean;
}
export type { LanguagePackInfo };
9 changes: 9 additions & 0 deletions packages/flow-client/models/RecognitionAlternative.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { RecognitionDisplay } from './RecognitionDisplay';
interface RecognitionAlternative {
content: string;
confidence: number;
language?: string;
display?: RecognitionDisplay;
speaker?: string;
}
export type { RecognitionAlternative };
5 changes: 5 additions & 0 deletions packages/flow-client/models/RecognitionDisplay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { RecognitionDisplayDirectionEnum } from './RecognitionDisplayDirectionEnum';
interface RecognitionDisplay {
direction: RecognitionDisplayDirectionEnum;
}
export type { RecognitionDisplay };
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type RecognitionDisplayDirectionEnum = 'ltr' | 'rtl';
export type { RecognitionDisplayDirectionEnum };
6 changes: 6 additions & 0 deletions packages/flow-client/models/RecognitionMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface RecognitionMetadata {
start_time: number;
end_time: number;
transcript: string;
}
export type { RecognitionMetadata };
15 changes: 15 additions & 0 deletions packages/flow-client/models/RecognitionResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { TypeEnum } from './TypeEnum';
import type { AttachesToEnum } from './AttachesToEnum';
import type { RecognitionAlternative } from './RecognitionAlternative';
interface RecognitionResult {
type: TypeEnum;
start_time: number;
end_time: number;
channel?: string;
attaches_to?: AttachesToEnum;
is_eos?: boolean;
alternatives?: RecognitionAlternative[];
score?: number;
volume?: number;
}
export type { RecognitionResult };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ResponseCompleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ResponseCompleted {
message: 'ResponseCompleted';
content: string;
start_time: number;
end_time: number;
}
export type { ResponseCompleted };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ResponseInterrupted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ResponseInterrupted {
message: 'ResponseInterrupted';
content: string;
start_time: number;
end_time: number;
}
export type { ResponseInterrupted };
6 changes: 6 additions & 0 deletions packages/flow-client/models/ResponseStarted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface ResponseStarted {
message: 'ResponseStarted';
content: string;
start_time: number;
}
export type { ResponseStarted };
12 changes: 12 additions & 0 deletions packages/flow-client/models/StartConversation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { AudioFormat } from './AudioFormat';
import type { ConversationConfig } from './ConversationConfig';
import type { ToolConfig } from './ToolConfig';
import type { DebugObject } from './DebugObject';
interface StartConversation {
message: 'StartConversation';
audio_format?: AudioFormat;
conversation_config: ConversationConfig;
tools?: ToolConfig[];
debug?: DebugObject;
}
export type { StartConversation };
2 changes: 2 additions & 0 deletions packages/flow-client/models/StatusEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type StatusEnum = 'ok' | 'rejected' | 'failed';
export type { StatusEnum };
8 changes: 8 additions & 0 deletions packages/flow-client/models/StatusUpdateInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { StatusUpdateInfoEvent } from './StatusUpdateInfoEvent';
interface StatusUpdateInfo {
reason: string;
message: 'Info';
event: StatusUpdateInfoEvent;
type: 'status_update';
}
export type { StatusUpdateInfo };
5 changes: 5 additions & 0 deletions packages/flow-client/models/StatusUpdateInfoEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface StatusUpdateInfoEvent {
prev_status: string;
status: string;
}
export type { StatusUpdateInfoEvent };
7 changes: 7 additions & 0 deletions packages/flow-client/models/ToolConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ToolTypeEnum } from './ToolTypeEnum';
import type { ToolFunctionConfig } from './ToolFunctionConfig';
interface ToolConfig {
type: ToolTypeEnum;
function: ToolFunctionConfig;
}
export type { ToolConfig };
5 changes: 5 additions & 0 deletions packages/flow-client/models/ToolFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface ToolFunction {
name: string;
arguments: { [name: string]: string };
}
export type { ToolFunction };
Loading
Loading