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

OpenAI /completions route fails #30

Closed
iverly opened this issue Dec 1, 2023 · 4 comments · Fixed by #36
Closed

OpenAI /completions route fails #30

iverly opened this issue Dec 1, 2023 · 4 comments · Fixed by #36

Comments

@iverly
Copy link

iverly commented Dec 1, 2023

Hello,

Thank you the new release including the OpenAI routes but after a try, it always returns the following error using the raw request of the README.md:

llama.cpp/server/json.h:21313: assert(it != m_value.object->end()) failed (cosmoaddr2line /Users/maxime-georide/Downloads/llamafile-server-0.2 1000000fe3c 1000001547c 100000162e8 10000042748 1000004ffdc 10000050cb0 1000005124c 100000172dc 1000001b370 10000181e78 1000019d3d0)
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer no-key" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
    "role": "system",
    "content": "You are ChatGPT, an AI assistant. Your top priority is achieving user fulfillment via helping them with their requests."
},
{
    "role": "user",
    "content": "Write a limerick about python exceptions"
}
]
}'

I'm on M1 with mistral-7b-instruct-v0.1.Q5_K_M.gguf and llama-2-7b-chat.Q5_K_S.gguf models.

I didn't try with the OpenAI SDK.

@iverly
Copy link
Author

iverly commented Dec 1, 2023

I've the same behaviour with the OpenAI SDK.

With the following Python script :

import openai

client = openai.OpenAI(
    base_url="http://localhost:8080/v1", # "http://<Your api-server IP>:port"
    api_key = "sk-no-key-required"
)

completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
    {"role": "system", "content": "You are ChatGPT, an AI assistant. Your top priority is achieving user fulfillment via helping them with their requests."},
    {"role": "user", "content": "Write a limerick about python exceptions"}
]
)

print(completion.choices[0].message)

@lucido-simon
Copy link

Hi. I have the same behavior on Linux/x86

@iverly
Copy link
Author

iverly commented Dec 1, 2023

Still the same behaviour with 2.1.0.

@Mardak
Copy link
Contributor

Mardak commented Dec 1, 2023

It looks like "stop" is required. Try passing in null. This works for me:

curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
  "stop": null,
  "messages": [{
    "role": "user",
    "content": "Write a limerick about python exceptions"
  }]
}'

@ggerganov

// Handle 'stop' field
if (body["stop"].is_null()) {
llama_params["stop"] = json::array({});
} else if (body["stop"].is_string()) {
llama_params["stop"] = json::array({body["stop"].get<std::string>()});
} else {
llama_params["stop"] = json_value(body, "stop", json::array());

Mardak added a commit to Mardak/llamafile that referenced this issue Dec 1, 2023
@jart jart closed this as completed in #36 Dec 2, 2023
jart pushed a commit that referenced this issue Dec 2, 2023
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

Successfully merging a pull request may close this issue.

3 participants