-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move typescript SKD to use v2 of API
API v2 is the new version and from now on our typescript sdk will use it. This change is necessary to allow users call the gateway in a non-streaming way which in most cases is what they need
- Loading branch information
1 parent
3bf4389
commit 900bccc
Showing
78 changed files
with
4,752 additions
and
2,732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...pi/v2/projects/[projectId]/versions/[versionUuid]/documents/handlers/documentPresenter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
ChainStepObjectResponse, | ||
ChainStepTextResponse, | ||
RunSyncAPIResponse, | ||
} from '@latitude-data/core/browser' | ||
import { LatitudeError } from '@latitude-data/core/lib/errors' | ||
import { Result, TypedResult } from '@latitude-data/core/lib/Result' | ||
import { captureException } from '$/common/sentry' | ||
|
||
type DocumentResponse = ChainStepObjectResponse | ChainStepTextResponse | ||
export function documentRunPresenter( | ||
response: DocumentResponse, | ||
): TypedResult<RunSyncAPIResponse, LatitudeError> { | ||
const conversation = response.providerLog?.messages | ||
const uuid = response.documentLogUuid | ||
const errorMessage = !uuid | ||
? 'Document Log uuid not found in response' | ||
: !conversation | ||
? 'Conversation messages not found in response' | ||
: undefined | ||
|
||
const error = errorMessage ? new LatitudeError(errorMessage) : undefined | ||
|
||
if (error) { | ||
captureException(error) | ||
return Result.error(error) | ||
} | ||
|
||
const type = response.streamType | ||
return Result.ok({ | ||
uuid: uuid!, | ||
conversation: conversation!, | ||
response: { | ||
streamType: type, | ||
usage: response.usage!, | ||
text: response.text, | ||
object: type === 'object' ? response.object : undefined, | ||
toolCalls: type === 'text' ? response.toolCalls : [], | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.