From 02169f3e605a1ba57ce3711e74f241614dc11ab1 Mon Sep 17 00:00:00 2001 From: Roy Han Date: Wed, 26 Jun 2024 14:30:28 -0700 Subject: [PATCH 1/4] Update docs --- docs/openai.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/docs/openai.md b/docs/openai.md index 59e7d6405..ca56f8aa3 100644 --- a/docs/openai.md +++ b/docs/openai.md @@ -27,6 +27,11 @@ chat_completion = client.chat.completions.create( ], model='llama3', ) + +completion = client.completions.create( + model="llama3", + prompt="Say this is a test" +) ``` ### OpenAI JavaScript library @@ -45,6 +50,11 @@ const chatCompletion = await openai.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'llama3', }) + +const completion = await openai.completions.create({ + model: "llama3", + prompt: "Say this is a test.", +}) ``` ### `curl` @@ -65,6 +75,13 @@ curl http://localhost:11434/v1/chat/completions \ } ] }' + +curl https://api.openai.com/v1/completions \ + -H "Content-Type: application/json" \ + -d '{ + "model": "llama3", + "prompt": "Say this is a test" + }' ``` ## Endpoints @@ -107,6 +124,40 @@ curl http://localhost:11434/v1/chat/completions \ - `finish_reason` will always be `stop` - `usage.prompt_tokens` will be 0 for completions where prompt evaluation is cached +### `/v1/completions` + +#### Supported features + +- [x] Completions +- [x] Streaming +- [x] JSON mode +- [x] Reproducible outputs +- [ ] Logprobs + +#### Supported request fields + +- [x] `model` +- [x] `prompt` +- [x] `frequency_penalty` +- [x] `presence_penalty` +- [x] `seed` +- [x] `stop` +- [x] `stream` +- [x] `temperature` +- [x] `top_p` +- [x] `max_tokens` +- [ ] `best_of` +- [ ] `echo` +- [ ] `suffix` +- [ ] `logit_bias` +- [ ] `user` +- [ ] `n` + +#### Notes + +- `prompt` currently only accepts a string +- `usage.prompt_tokens` will be 0 for completions where prompt evaluation is cached + ## Models Before using a model, pull it locally `ollama pull`: From 105e36765d2b56a4c6ad4901e9a56adb61b7f0ac Mon Sep 17 00:00:00 2001 From: Roy Han Date: Wed, 3 Jul 2024 15:03:54 -0700 Subject: [PATCH 2/4] token bug corrected --- docs/openai.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/openai.md b/docs/openai.md index 318ed71be..11e10e4c7 100644 --- a/docs/openai.md +++ b/docs/openai.md @@ -119,10 +119,6 @@ curl https://api.openai.com/v1/completions \ - [ ] `user` - [ ] `n` -#### Notes - -- `usage.prompt_tokens` will be 0 for completions where prompt evaluation is cached - ### `/v1/completions` #### Supported features @@ -155,7 +151,6 @@ curl https://api.openai.com/v1/completions \ #### Notes - `prompt` currently only accepts a string -- `usage.prompt_tokens` will be 0 for completions where prompt evaluation is cached ## Models From 04cde43b2a1bfab26d3543981bb58318dac3a72e Mon Sep 17 00:00:00 2001 From: royjhan <65097070+royjhan@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:44:16 -0700 Subject: [PATCH 3/4] Update docs/openai.md --- docs/openai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/openai.md b/docs/openai.md index 11e10e4c7..0dd835f14 100644 --- a/docs/openai.md +++ b/docs/openai.md @@ -76,7 +76,7 @@ curl http://localhost:11434/v1/chat/completions \ ] }' -curl https://api.openai.com/v1/completions \ +curl https://localhost:11434/v1/completions \ -H "Content-Type: application/json" \ -d '{ "model": "llama3", From 2644c4e682978be7731fd4528a1eba018c3bff6b Mon Sep 17 00:00:00 2001 From: royjhan <65097070+royjhan@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:46:05 -0700 Subject: [PATCH 4/4] Update docs/openai.md --- docs/openai.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/openai.md b/docs/openai.md index 0dd835f14..d9265c6b3 100644 --- a/docs/openai.md +++ b/docs/openai.md @@ -76,7 +76,7 @@ curl http://localhost:11434/v1/chat/completions \ ] }' -curl https://localhost:11434/v1/completions \ +curl http://localhost:11434/v1/completions \ -H "Content-Type: application/json" \ -d '{ "model": "llama3",