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

Closed
neptunian opened this issue Dec 12, 2024 · 4 comments · Fixed by #206739
Closed

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

neptunian opened this issue Dec 12, 2024 · 4 comments · Fixed by #206739
Assignees
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"
/>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Jan 13, 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"
/>
@arturoliduena arturoliduena self-assigned this Jan 14, 2025
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Jan 18, 2025
)

Closes elastic#204116

## Summary

fix:
o11y assistant Error, when using the model (llama 3.2) the stream get
closed in the middle and fails with an error related to the title
generation

(cherry picked from commit d577177)
kibanamachine added a commit that referenced this issue Jan 18, 2025
…) (#207146)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Obs AI Assistant] Error when using ollama model locally
(#206739)](#206739)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Arturo
Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-01-18T09:06:17Z","message":"[Obs
AI Assistant] Error when using ollama model locally (#206739)\n\nCloses
#204116\r\n\r\n## Summary\r\n\r\nfix:\r\no11y assistant Error, when
using the model (llama 3.2) the stream get\r\nclosed in the middle and
fails with an error related to the
title\r\ngeneration","sha":"d577177198816af9e08ed79bfa65cf9f990432f2","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v8.18.0"],"title":"[Obs
AI Assistant] Error when using ollama model
locally","number":206739,"url":"https://github.com/elastic/kibana/pull/206739","mergeCommit":{"message":"[Obs
AI Assistant] Error when using ollama model locally (#206739)\n\nCloses
#204116\r\n\r\n## Summary\r\n\r\nfix:\r\no11y assistant Error, when
using the model (llama 3.2) the stream get\r\nclosed in the middle and
fails with an error related to the
title\r\ngeneration","sha":"d577177198816af9e08ed79bfa65cf9f990432f2"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/206739","number":206739,"mergeCommit":{"message":"[Obs
AI Assistant] Error when using ollama model locally (#206739)\n\nCloses
#204116\r\n\r\n## Summary\r\n\r\nfix:\r\no11y assistant Error, when
using the model (llama 3.2) the stream get\r\nclosed in the middle and
fails with an error related to the
title\r\ngeneration","sha":"d577177198816af9e08ed79bfa65cf9f990432f2"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
cqliu1 pushed a commit to cqliu1/kibana that referenced this issue Jan 21, 2025
)

Closes elastic#204116

## Summary

fix:
o11y assistant Error, when using the model (llama 3.2) the stream get
closed in the middle and fails with an error related to the title
generation
viduni94 pushed a commit to viduni94/kibana that referenced this issue Jan 23, 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"
/>
viduni94 pushed a commit to viduni94/kibana that referenced this issue Jan 23, 2025
)

Closes elastic#204116

## Summary

fix:
o11y assistant Error, when using the model (llama 3.2) the stream get
closed in the middle and fails with an error related to the title
generation
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

Successfully merging a pull request may close this issue.

4 participants