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: use event.reason, remove parentEvent #681

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Apr 1, 2024

Use AsyncLocalStoarge to pass context through async function. You can track who trigger this event by using this

if (process.env.NODE_ENV === "development") {
  Settings.callbackManager.on("llm-end", (event) => {
    console.log("callers chain", event.reason?.computedCallers);
  });
}
callers chain [
  OpenAI {
    model: 'gpt-3.5-turbo',
    temperature: 0.1,
    topP: 1,
    maxTokens: 3072,
    additionalChatOptions: undefined,
    apiKey: undefined,
    maxRetries: 10,
    timeout: 60000,
    session: OpenAISession { openai: [OpenAI] },
    additionalSessionOptions: undefined,
    chat: [Function (anonymous)],
    streamChat: [Function (anonymous)]
  },
  SimpleChatEngine {
    chatHistory: SimpleChatHistory { messages: [], messagesBefore: 0 },
    llm: OpenAI {
      model: 'gpt-3.5-turbo',
      temperature: 0.1,
      topP: 1,
      maxTokens: 3072,
      additionalChatOptions: undefined,
      apiKey: undefined,
      maxRetries: 10,
      timeout: 60000,
      session: [OpenAISession],
      additionalSessionOptions: undefined,
      chat: [Function (anonymous)],
      streamChat: [Function (anonymous)]
    },
    chat: [Function (anonymous)]
  }
]

Copy link

changeset-bot bot commented Apr 1, 2024

⚠️ No Changeset found

Latest commit: caef936

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llama-index-ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 0:09am

@himself65 himself65 changed the title refactor: remove parentEvent refactor: use event.reason, remove parentEvent Apr 1, 2024
@himself65 himself65 marked this pull request as ready for review April 1, 2024 23:58
Copy link
Contributor

@yisding yisding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

@yisding yisding merged commit d256cbe into run-llama:main Apr 2, 2024
6 of 7 checks passed
});
return function (this: This, ...args: Args): Result {
const result = originalMethod.call(this, ...args);
// patch for iterators because AsyncLocalStorage doesn't work with them
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

2 participants