Skip to content
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

Merged
merged 10 commits into from
Aug 1, 2024

Conversation

Dam-Buty
Copy link
Contributor

@Dam-Buty Dam-Buty commented Jul 30, 2024

In preparation for the Great Open-Sourcening :

  • Re-generated the Typedoc
  • Re-organized the classes in types to their respective folders : evaluation, instrumentation, observability, prompt-engineering
  • Renamed types.ts to utils.ts
  • Added missing typedocs for all publicly exposed methods

Copy link

linear bot commented Jul 30, 2024

ENG-1713 Flatten history

  • check comments
  • write readme

docs/api.md Outdated

▪ **options.apiUrl?**: `string`

The URL of the Literal AI API. Defaults to the LITERAL_API_URL environment variable.
Copy link
Collaborator

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.
Copy link
Collaborator

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**
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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>;
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor

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'
Copy link
Collaborator

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.

Copy link
Contributor Author

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 😅

datasetExperimentItemId?: Maybe<string>;
name: string = 'user-feedback';
value: number = 0;
type: ScoreType = 'AI';
Copy link
Collaborator

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 :)

Copy link
Contributor Author

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>;
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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 ?

Copy link
Contributor

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

@Dam-Buty Dam-Buty requested a review from willydouhard August 1, 2024 12:22
@Dam-Buty Dam-Buty merged commit 7fc74d6 into main_old Aug 1, 2024
2 checks passed
@Dam-Buty Dam-Buty deleted the damien/eng-1713-flatten-history branch August 1, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants