-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Typescript SDK to use our API v2 #500
Conversation
beforeAll(() => { | ||
sdk = new Latitude(FAKE_LATITUDE_SDK_KEY, { | ||
__internal: { | ||
retryMs: 10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faster test. We were spending 3 seconds in the retry test.
14e1d1f
to
591e040
Compare
@@ -0,0 +1,29 @@ | |||
import { Latitude } from '@latitude-data/sdk' | |||
|
|||
async function makeSdkRequest() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A playground to test in the development of the SDK. This makes our job easier
acc73cc
to
c21921e
Compare
errorCode: ApiResponseCode | ||
dbErrorRef?: DbErrorRef | ||
} | ||
export type ApiResponseCode = RunErrorCodes | ApiErrorCodes | LatitudeErrorCodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unified list of codes of all the things that can go wrong in an api call
@@ -52,6 +52,7 @@ | |||
"@faker-js/faker": "^8.4.1", | |||
"@latitude-data/compiler": "workspace:^", | |||
"@latitude-data/env": "workspace:*", | |||
"@latitude-data/constants": "workspace:*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * as AI from '@latitude-data/constants/ai'
Next step in another moment is to move all constants that are from
- Vercel AI
- Compiler
Into constants so sharing this types between gateway
and sdk
and core
is perfect and no one depends on the others
@@ -3,11 +3,12 @@ | |||
"compilerOptions": { | |||
"moduleResolution": "Bundler", | |||
"outDir": "./dist", | |||
"rootDir": ".", | |||
"rootDir": "../../", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes .d.ts
generated file not complain. It can find constants
packages/web-ui/src/example-file.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used, please confirm @geclos I think this was created by you
6eacf54
to
2beea93
Compare
return c.json(data) | ||
const response = await result.response.then((r) => r.unwrap()) | ||
const body = documentRunPresenter(response).unwrap() | ||
return c.json(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an important change. The meet is in documentRunPresenter
noExternal: [ | ||
'@latitude-data/env', | ||
'@latitude-data/core', | ||
'@latitude-data/constants', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added @latitude-data/constants
to all our apps. This package would be the common package without other dependencies where we put all the shared constants and types.
) | ||
}) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I covered all the new code here
2beea93
to
900bccc
Compare
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@latitude-data/sdk", | |||
"version": "0.0.18", | |||
"version": "1.0.0-beta.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed with this: pnpm version premajor --preid beta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
053c483
to
47f8b17
Compare
60384f1
to
aeeaab4
Compare
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
aeeaab4
to
cfa27cd
Compare
What?
This change is incremental and everyone in v1 should be able to work without any changes. If they opt-in to use API v2, they need to pass apiVersion: 'v2'. And if they want to run a prompt without streaming they need to pass
stream: false
TODO
Maybe test somehow v2 andI did anstreaming: false
./examples
playground in the monorepo to use our sdkv1
stream: boolean
in docsIMPORTANT
@latitude-data/constants
. In tired of not being able to have a unified source of truth for enums and types. This is the first stone