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

[Obs AI Assistant] Error when using ollama model locally #204116

Open
neptunian opened this issue Dec 12, 2024 · 4 comments
Open

[Obs AI Assistant] Error when using ollama model locally #204116

neptunian opened this issue Dec 12, 2024 · 4 comments
Labels
bug Fixes for quality problems that affect the customer experience Team:AI Infra AppEx AI Infrastructure Team Team:Obs AI Assistant Observability AI Assistant

Comments

@neptunian
Copy link
Contributor

neptunian commented Dec 12, 2024

Similar to the bug described here, #204014, the model (llama 3.2) isn't being passed to chat completions and fails with an unexpected error

[2024-12-12T14:02:39.743-05:00][WARN ][plugins.actions.gen-ai] action execution failure: .gen-ai:8608ccb6-4e2a-4045-a729-ab4b556ea5ad: Llama: an error occurred while running the action: Status code: 400. Message: API Error: Bad Request - model is required; retry: true
[2024-12-12T14:02:39.744-05:00][ERROR][plugins.observabilityAIAssistant.service] Error: Unexpected error
at createInferenceInternalError (elastic/kibana/x-pack/platform/packages/shared/ai-infra/inference-common/src/errors.ts:49:10)
at elastic/kibana/x-pack/platform/plugins/shared/inference/server/chat_complete/adapters/openai/openai_adapter.ts:68:92

@neptunian neptunian added Team:AI Infra AppEx AI Infrastructure Team Team:Obs AI Assistant Observability AI Assistant labels Dec 12, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-ai-infra (Team:AI Infra)

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@neptunian neptunian added the bug Fixes for quality problems that affect the customer experience label Dec 12, 2024
@pgayvallet
Copy link
Contributor

pgayvallet commented Dec 19, 2024

the model isn't being passed to chat completions

So this part is working as expected. The model is not a parameter of the inference APIs, and it not sent to the stack connector.

The stack connector is in charge of passing the information from the config to the provider during the remote call:

const executeBody = getRequestWithStreamOption(
this.provider,
this.url,
body,
stream,
...('defaultModel' in this.config ? [this.config.defaultModel] : [])
);

However looking at the code forging the request, it seems that the defaultModel is only being passed for openAI provider type and not for other:

export function getRequestWithStreamOption(
provider: string,
url: string,
body: string,
stream: boolean,
defaultModel?: string
): string {
switch (provider) {
case OpenAiProviderType.OpenAi:
return openAiGetRequestWithStreamOption(url, body, stream, defaultModel!);
case OpenAiProviderType.AzureAi:
return azureAiGetRequestWithStreamOption(url, body, stream);
case OpenAiProviderType.Other:
return otherOpenAiGetRequestWithStreamOption(body, stream);
default:
return body;
}

The right approach for the fix seems to be to adapt getRequestWithStreamOption and otherOpenAiGetRequestWithStreamOption

@pgayvallet
Copy link
Contributor

So, I opened #204934 that will take care of the issue in the connector.

That fixes the general error and allows to properly communicates with ollama.

However, there seems to be something wrong with what the o11y assistant is doing, as the stream get closed in the middle and fails with something that seems related to the title generation:

Screen.Recording.2024-12-19.at.14.04.05.mov

The server error is, as always with RXJS, incredibly usable and totally shows where the issue is coming from:

[2024-12-19T14:04:13.554+01:00][ERROR][plugins.observabilityAIAssistant.service] Error
    at _super (/kibana/node_modules/rxjs/dist/cjs/internal/util/createErrorClass.js:7:26)
    at new EmptyErrorImpl (/kibana/node_modules/rxjs/dist/cjs/internal/util/EmptyError.js:6:5)
    at /kibana/node_modules/rxjs/dist/cjs/internal/operators/last.js:13:271
    at /kibana/node_modules/rxjs/dist/cjs/internal/operators/throwIfEmpty.js:14:86
    at OperatorSubscriber._this._complete (/kibana/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:56:21)
    at Subscriber.complete (/kibana/node_modules/rxjs/dist/cjs/internal/Subscriber.js:69:18)

After some debug logs, this is being thrown here:

return output$.pipe(
instrumentAndCountTokens('complete'),
withoutTokenCountEvents(),
catchError((error) => {
this.dependencies.logger.error(error);
return throwError(() => error);
}),

That observable is massive and we're getting out of my area of ownership though, so I'll let the @elastic/obs-ai-assistant team take a look if they so want.

pgayvallet added a commit that referenced this issue Dec 23, 2024
…4934)

## Summary

Part of #204116

When model is not present in the payload, use the default model as
specified in the connector configuration.

We were already doing that for OpenAI-OpenAI, but not for
"Other"-OpenAI.

### Some section because I downloaded ollama just for that issue

<img width="950" alt="Screenshot 2024-12-19 at 13 53 48"
src="https://github.com/user-attachments/assets/4a6e4b35-a0c5-46e5-9372-677e99d070f8"
/>

<img width="769" alt="Screenshot 2024-12-19 at 13 54 54"
src="https://github.com/user-attachments/assets/a0a5a12a-ea1e-42b7-8fa1-6531bef5ae6c"
/>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 23, 2024
…stic#204934)

## Summary

Part of elastic#204116

When model is not present in the payload, use the default model as
specified in the connector configuration.

We were already doing that for OpenAI-OpenAI, but not for
"Other"-OpenAI.

### Some section because I downloaded ollama just for that issue

<img width="950" alt="Screenshot 2024-12-19 at 13 53 48"
src="https://github.com/user-attachments/assets/4a6e4b35-a0c5-46e5-9372-677e99d070f8"
/>

<img width="769" alt="Screenshot 2024-12-19 at 13 54 54"
src="https://github.com/user-attachments/assets/a0a5a12a-ea1e-42b7-8fa1-6531bef5ae6c"
/>

(cherry picked from commit d4bc9be)
stratoula pushed a commit to stratoula/kibana that referenced this issue Jan 2, 2025
…stic#204934)

## Summary

Part of elastic#204116

When model is not present in the payload, use the default model as
specified in the connector configuration.

We were already doing that for OpenAI-OpenAI, but not for
"Other"-OpenAI.

### Some section because I downloaded ollama just for that issue

<img width="950" alt="Screenshot 2024-12-19 at 13 53 48"
src="https://github.com/user-attachments/assets/4a6e4b35-a0c5-46e5-9372-677e99d070f8"
/>

<img width="769" alt="Screenshot 2024-12-19 at 13 54 54"
src="https://github.com/user-attachments/assets/a0a5a12a-ea1e-42b7-8fa1-6531bef5ae6c"
/>
benakansara pushed a commit to benakansara/kibana that referenced this issue Jan 2, 2025
…stic#204934)

## Summary

Part of elastic#204116

When model is not present in the payload, use the default model as
specified in the connector configuration.

We were already doing that for OpenAI-OpenAI, but not for
"Other"-OpenAI.

### Some section because I downloaded ollama just for that issue

<img width="950" alt="Screenshot 2024-12-19 at 13 53 48"
src="https://github.com/user-attachments/assets/4a6e4b35-a0c5-46e5-9372-677e99d070f8"
/>

<img width="769" alt="Screenshot 2024-12-19 at 13 54 54"
src="https://github.com/user-attachments/assets/a0a5a12a-ea1e-42b7-8fa1-6531bef5ae6c"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:AI Infra AppEx AI Infrastructure Team Team:Obs AI Assistant Observability AI Assistant
Projects
None yet
Development

No branches or pull requests

3 participants