home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.95k stars 31.01k forks source link

Use OpenAI failed. #129730

Open Gcaufy opened 3 weeks ago

Gcaufy commented 3 weeks ago

The problem

I‘m using China AI model.

  1. try simple curl, it works well.

    curl https://ark.cn-beijing.volces.com/api/v3/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $ARK_API_KEY" \
    -d '{
    "model": "my model",
    "messages": [
      {"role": "system","content": "你是豆包,是由字节跳动开发的 AI 人工智能助手."},
      {"role": "user","content": "常见的十字花科植物有哪些?"}
    ]
    }'
  2. get everything ready, include then env varibles. and then try assistant. it failed.

logs shows:

$ docker logs -f homeassistant | grep openai
2024-11-03 22:41:04.696 ERROR (MainThread) [homeassistant.components.openai_conversation] Error talking to OpenAI: Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'One or more parameters specified in the request are not valid. Request id: 021730644864511f68c723bec92509a79c04d902daef5b94d121f', 'param': '', 'type': 'BadRequest'}}

and I change to http, and tried tcpdump, it seems all right.

image

image

What version of Home Assistant Core has the issue?

2024.10.4

What was the last working version of Home Assistant Core?

2024.10.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

OpenAI Conversation

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 weeks ago

Hey there @balloob, mind taking a look at this issue as it has been labeled with an integration (openai_conversation) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `openai_conversation` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign openai_conversation` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


openai_conversation documentation openai_conversation source (message by IssueLinks)

Gcaufy commented 2 weeks ago

figured it out.

When I remove the "tools" param, it works well

https://github.com/home-assistant/core/pull/117645

share32 commented 1 week ago

figured it out.

When I remove the "tools" param, it works well

117645

how to do in homeassistant?tks