Skip to content

Commit

Permalink
Merge branch 'main' into display-markers-for-scheduled-events-distrib…
Browse files Browse the repository at this point in the history
…ution-anomaly-charts
  • Loading branch information
rbrtj authored Sep 16, 2024
2 parents 480fc65 + 1f673dc commit e60fc2a
Show file tree
Hide file tree
Showing 65 changed files with 1,254 additions and 410 deletions.
1 change: 1 addition & 0 deletions .buildkite/pull_requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["elastic-vault-github-plugin-prod[bot]"],
"set_commit_status": true,
"commit_status_context": "kibana-ci",
"build_on_commit": true,
Expand Down
17 changes: 15 additions & 2 deletions docs/playground/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ a|

|===

[[playground-local-llms]]
[TIP]
====
You can also use locally hosted LLMs that are compatible with the OpenAI SDK.
Once you've set up your LLM, you can connect to it using the OpenAI connector.
Refer to the following for examples:
* {security-guide}/connect-to-byo-llm.html[Using LM Studio]
* https://www.elastic.co/search-labs/blog/localai-for-text-embeddings[LocalAI with `docker-compose`]
====

[float]
[[playground-getting-started]]
== Getting started
Expand All @@ -101,13 +112,15 @@ image::get-started.png[width=600]
=== Connect to LLM provider

To get started with {x}, you need to create a <<action-types,connector>> for your LLM provider.
Follow these steps on the {x} landing page:
You can also connect to <<playground-local-llms,locally hosted LLMs>> which are compatible with the OpenAI API, by using the OpenAI connector.

To connect to an LLM provider, follow these steps on the {x} landing page:

. Under *Connect to an LLM*, click *Create connector*.
. Select your *LLM provider*.
. *Name* your connector.
. Select a *URL endpoint* (or use the default).
. Enter *access credentials* for your LLM provider.
. Enter *access credentials* for your LLM provider. (If you're running a locally hosted LLM using the OpenAI connector, you must input a value in the API key form, but the specific value doesn't matter.)

[TIP]
====
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/ast_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ export function createSource(
index,
name: text,
sourceType: type,
text,
location: getPosition(ctx.start, ctx.stop),
incomplete: Boolean(ctx.exception || text === ''),
text: ctx?.getText(),
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-utils/src/utils/query_parsing_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getIndexPatternFromESQLQuery(esql?: string) {
const sourceCommand = ast.find(({ name }) => ['from', 'metrics'].includes(name));
const args = (sourceCommand?.args ?? []) as ESQLSource[];
const indices = args.filter((arg) => arg.sourceType === 'index');
return indices?.map((index) => index.text).join(',');
return indices?.map((index) => index.name).join(',');
}

// For ES|QL we consider stats and keep transformational command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const visibleIndices = indexes
.map(({ name, suggestedAs }) => suggestedAs || name)
.sort();

const addTrailingSpace = (strings: string[], predicate: (s: string) => boolean = (_s) => true) =>
strings.map((string) => (predicate(string) ? `${string} ` : string));

const metadataFields = [...METADATA_FIELDS].sort();

describe('autocomplete.suggest', () => {
Expand All @@ -37,17 +34,17 @@ describe('autocomplete.suggest', () => {
test('suggests visible indices on space', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('from /', addTrailingSpace(visibleIndices));
await assertSuggestions('FROM /', addTrailingSpace(visibleIndices));
await assertSuggestions('from /index', addTrailingSpace(visibleIndices));
await assertSuggestions('from /', visibleIndices);
await assertSuggestions('FROM /', visibleIndices);
await assertSuggestions('from /index', visibleIndices);
});

test('suggests visible indices on comma', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('FROM a,/', addTrailingSpace(visibleIndices));
await assertSuggestions('FROM a, /', addTrailingSpace(visibleIndices));
await assertSuggestions('from *,/', addTrailingSpace(visibleIndices));
await assertSuggestions('FROM a,/', visibleIndices);
await assertSuggestions('FROM a, /', visibleIndices);
await assertSuggestions('from *,/', visibleIndices);
});

test('can suggest integration data sources', async () => {
Expand All @@ -56,10 +53,7 @@ describe('autocomplete.suggest', () => {
.filter(({ hidden }) => !hidden)
.map(({ name, suggestedAs }) => suggestedAs || name)
.sort();
const expectedSuggestions = addTrailingSpace(
visibleDataSources,
(s) => !integrations.find(({ name }) => name === s)
);
const expectedSuggestions = visibleDataSources;
const { assertSuggestions, callbacks } = await setup();
const cb = {
...callbacks,
Expand All @@ -75,7 +69,7 @@ describe('autocomplete.suggest', () => {
});

describe('... METADATA <fields>', () => {
const metadataFieldsSandIndex = metadataFields.filter((field) => field !== '_index');
const metadataFieldsAndIndex = metadataFields.filter((field) => field !== '_index');

test('on <kbd>SPACE</kbd> without comma ",", suggests adding metadata', async () => {
const { assertSuggestions } = await setup();
Expand Down Expand Up @@ -103,8 +97,8 @@ describe('autocomplete.suggest', () => {
test('filters out already used metadata fields', async () => {
const { assertSuggestions } = await setup();

await assertSuggestions('from a, b [metadata _index, /]', metadataFieldsSandIndex);
await assertSuggestions('from a, b metadata _index, /', metadataFieldsSandIndex);
await assertSuggestions('from a, b [metadata _index, /]', metadataFieldsAndIndex);
await assertSuggestions('from a, b metadata _index, /', metadataFieldsAndIndex);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { groupingFunctionDefinitions } from '../../definitions/grouping';
import * as autocomplete from '../autocomplete';
import type { ESQLCallbacks } from '../../shared/types';
import type { EditorContext, SuggestionRawDefinition } from '../types';
import { TIME_SYSTEM_PARAMS } from '../factories';
import { TIME_SYSTEM_PARAMS, getSafeInsertText } from '../factories';
import { getFunctionSignatures } from '../../definitions/helpers';
import { ESQLRealField } from '../../validation/types';
import {
Expand Down Expand Up @@ -280,10 +280,7 @@ export function createCompletionContext(triggerCharacter?: string) {
export function getPolicyFields(policyName: string) {
return policies
.filter(({ name }) => name === policyName)
.flatMap(({ enrichFields }) =>
// ok, this is a bit of cheating as it's using the same logic as in the helper
enrichFields.map((field) => (/[^a-zA-Z\d_\.@]/.test(field) ? `\`${field}\`` : field))
);
.flatMap(({ enrichFields }) => enrichFields.map((field) => getSafeInsertText(field)));
}

export interface SuggestOptions {
Expand Down
Loading

0 comments on commit e60fc2a

Please sign in to comment.