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

Add Chat Message Handling #1218

Merged
merged 1 commit into from
May 11, 2023
Merged

Add Chat Message Handling #1218

merged 1 commit into from
May 11, 2023

Conversation

vowelparrot
Copy link
Contributor

@vowelparrot vowelparrot commented May 11, 2023

  • Add handleChatModelStart to callback handler and manager
  • Fallback to handleLLMStart if not implemented

Still needs tests - will add tomorrow

@vercel
Copy link

vercel bot commented May 11, 2023

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

Name Status Preview Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview May 11, 2023 4:45pm

const execution_order = this._getExecutionOrder(parentRunId);
const session = this.session as TracerSession;
const convertedMessages = messages.map((batch) =>
batch.map((message) => ({
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 python message format looks like

{
                        "_type": "human|ai|system",
                        "content": "the text",
                        "example": false, // only used for PALM currently?
                        "additional_kwargs": {} // not sure when this is ever used either
                    }

if (!handler.ignoreLLM) {
try {
if (handler.handleChatModelStart)
await handler.handleChatModelStart?.(
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'm sure we could make this more concise with some ternary ops or better use of conditional chaining...

@vowelparrot vowelparrot merged commit ac991b2 into main May 11, 2023
9 checks passed
@vowelparrot vowelparrot deleted the vwp/chat_model_start branch May 11, 2023 17:29
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.

None yet

2 participants