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

Why it can search in client (NextChat), but cannot search in python openai package invoke? #35

Open
liuxiaodong008008 opened this issue Jul 12, 2024 · 3 comments

Comments

@liuxiaodong008008
Copy link

I have deployed a search2ai instance. My api is moonshot. I tested it in NextChat client, it can support web page browsing. But when I use it in my python code, it does not browse at all. I have confirmed I have changed the endpoint to my search2ai instance endpoint.

Is there anything more to do to make it work in python code?

@liuxiaodong008008
Copy link
Author

I know now, maybe I need pass tools to code. What tools does search2ai support?

@fatwang2
Copy link
Owner

fatwang2 commented Aug 6, 2024

把你Python代码贴一下

@redstoneleo
Copy link

我就这么用,出错

from openai import OpenAI
 
client = OpenAI(
    api_key = "$MOONSHOT_API_KEY",
    base_url = "http://localhost:3014/v1",
)
 
completion = client.chat.completions.create(
    model = "moonshot-v1-8k",
    messages = [
        {"role": "system", "content": "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。"},
        {"role": "user", "content": "你好,我叫李雷,1+1等于多少?"}
    ],
    temperature = 0.3,
)
 
print(completion.choices[0].message.content)

Traceback (most recent call last):
  File "F:\BaiduNetdiskDownload\ConsumerSoftwareProject\CompanyCloudInfo\kimichat.py", line 106, in <module>
    ask(userInputContent)
  File "F:\BaiduNetdiskDownload\ConsumerSoftwareProject\CompanyCloudInfo\kimichat.py", line 78, in ask
    choice = chat(messages)
             ^^^^^^^^^^^^^^
  File "F:\BaiduNetdiskDownload\ConsumerSoftwareProject\CompanyCloudInfo\kimichat.py", line 30, in chat
    completion = client.chat.completions.create(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_utils\_utils.py", line 274, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\resources\chat\completions.py", line 815, in create
    return self._post(
           ^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1277, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 954, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1043, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1092, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1043, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1092, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "C:\Users\Orion\AppData\Local\Programs\Python\Python312\Lib\site-packages\openai\_base_client.py", line 1058, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants