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

[Search] [Chat Playground] handle when the ActionLLM is not a ChatModel #183931

Merged
merged 1 commit into from
May 22, 2024

Conversation

joemcelroy
Copy link
Member

Summary

Two action based LLMs: ActionsClientChatOpenAI and ActionsClientLlm. ActionsClientChatOpenAI is based on the ChatModel LLM, ActionsClientLlm is a prompt based model. The callbacks are different when using a ChatModel vs LLMModel. Token count is done on the ChatModelStart callback. This meant the token count didn't happen for LLMModel based actions (Bedrock).

To fix i listen on both callbacks.

Checklist

Delete any items that are not applicable to this PR.

@joemcelroy joemcelroy added release_note:skip Skip the PR/issue when compiling release notes Team:EnterpriseSearch v8.15.0 labels May 21, 2024
@joemcelroy joemcelroy requested a review from a team as a code owner May 21, 2024 14:59
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan left a comment

Choose a reason for hiding this comment

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

LGTM, code review only

@@ -166,6 +167,15 @@ class ConversationalChainFn {
});
}
},
// callback for prompt based models (Bedrock uses ActionsClientLlm)
handleLLMStart(llm, input, runId, parentRunId, extraParams, tags, metadata) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same lint issue?

Comment on lines +68 to +72
const llm = isChatModel
? new FakeListChatModel({
responses,
})
: new FakeListLLM({ responses });
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if the lint is correct here? Looks like two different styles for two functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

i would say so otherwise CI would complain. Looks like its based on line width.

@joemcelroy joemcelroy merged commit 51f9eed into elastic:main May 22, 2024
25 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 22, 2024
@joemcelroy joemcelroy deleted the bedrock-nan-token-counter branch May 22, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:EnterpriseSearch v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants