-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: reorganize code structure #48
Conversation
docs/api.md
Outdated
|
||
▪ **options.apiUrl?**: `string` | ||
|
||
The URL of the Literal AI API. Defaults to the LITERAL_API_URL environment variable. |
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.
It defaults to https://cloud.getliteral.ai
if no env variable is specified too.
|
||
Instrument the OpenAI client to log all generations to the Literal AI API. | ||
Compatible with OpenAI's `chat.completions.create`, `completions.create` and `images.generate` functions. | ||
If you want to add tags or metadata at the call level, you should use the augmented client returned by this function. |
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.
Perfect, that's very clear that way.
|
||
The MIME type of the file. Defaults to 'application/octet-stream' if not provided. | ||
▪ **R** |
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 don't think I should read this doc as a diff, it makes it very hard to know what changed.
I'd remove very general generics like R
from the doc, I wouldn't know how to use that type.
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.
The thing is, this api.md
file is auto-generated by TypeDoc, and i'm not sure if you can configure it with that level of granularity. I'll try and add @ignore clauses where i can
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.
(it's not very configurable :/ should we keep it ?)
src/api.ts
Outdated
@@ -892,6 +868,7 @@ export class API { | |||
metadata?: Maybe<Record<string, any>>; | |||
participantId?: Maybe<string>; | |||
tags?: Maybe<string[]>; | |||
environment?: Maybe<Environment>; |
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.
We add environment
from Willy's developments last week?
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.
yes, turns out it wasn't taken into account in this case
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.
Hmm not sure we need this. The environment is passed as a HTTP header at the sdk level. it should not show in function signatures.
Furthermore, I don't think it is useful on attachments since the attachments are linked to steps and steps have an environment.
return ( | ||
this.type === 'user_message' || | ||
this.type === 'assistant_message' || | ||
this.type === 'system_message' |
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 didn't know we had this one, I never used it.
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.
same, i've learned a lot on the SDK by just trucking code around 😅
src/evaluation/score.ts
Outdated
datasetExperimentItemId?: Maybe<string>; | ||
name: string = 'user-feedback'; | ||
value: number = 0; | ||
type: ScoreType = 'AI'; |
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'd put HUMAN if the name is 'user-feedback'.
I'd also put value=1
by default for positivity :)
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.
good idea ;)
src/api.ts
Outdated
@@ -892,6 +868,7 @@ export class API { | |||
metadata?: Maybe<Record<string, any>>; | |||
participantId?: Maybe<string>; | |||
tags?: Maybe<string[]>; | |||
environment?: Maybe<Environment>; |
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.
Hmm not sure we need this. The environment is passed as a HTTP header at the sdk level. it should not show in function signatures.
Furthermore, I don't think it is useful on attachments since the attachments are linked to steps and steps have an environment.
src/api.ts
Outdated
|
||
const originalEnvironment = this.environment; | ||
|
||
if (environment && environment !== originalEnvironment) { |
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.
why are we adding this?
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 noticed that the environment
was part of ThreadConstructor
, like for example i can do client.thread({ environment: 'prod' }).wrap
but then it is completely ignored by the code.
This code in upsertThread
just updates the api.environment
for the time it takes to upsert the thread, then reverts the change.
I'm not sure what you mean about attachments though ?
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.
it is legacy, from now on environment is handled at the header level. We are just keeping the arg for backward compatiblity
In preparation for the Great Open-Sourcening :
types
to their respective folders : evaluation, instrumentation, observability, prompt-engineeringtypes.ts
toutils.ts