diff --git a/docs/openai_api.md b/docs/chatgpt_api.md similarity index 98% rename from docs/openai_api.md rename to docs/chatgpt_api.md index 682c78f..b4f1645 100644 --- a/docs/openai_api.md +++ b/docs/chatgpt_api.md @@ -2,7 +2,13 @@ ## OpenAI -### cURL gpt-turbo +### Documentation + +https://platform.openai.com/docs/api-reference/chat/create + +### CURLS + +Request: ```shell curl --location --insecure --request POST 'https://api.openai.com/v1/chat/completions' \ @@ -15,7 +21,7 @@ curl --location --insecure --request POST 'https://api.openai.com/v1/chat/comple }' | jq . ``` -Output: +Response: ```json { @@ -284,6 +290,8 @@ Output: ## Azure +Request: + ```shell curl "https://[resource].openai.azure.com/openai/deployments/[deployment]/chat/completions?api-version=[model]" \ -H "Content-Type: application/json" \ @@ -300,7 +308,7 @@ curl "https://[resource].openai.azure.com/openai/deployments/[deployment]/chat/c }' ``` -Output: +Response: ```shell { diff --git a/docs/perplexity_api.md b/docs/perplexity_api.md new file mode 100644 index 0000000..3d4b26b --- /dev/null +++ b/docs/perplexity_api.md @@ -0,0 +1,106 @@ +# Perplexity API + +## Documentation + +https://docs.perplexity.ai/reference/post_chat_completions + +## CURLS + +Request: + +```shell +curl --request POST \ + --url https://api.perplexity.ai/chat/completions \ + --header "Authorization: Bearer ${PERPLEXITY_API_KEY}" \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --data ' +{ + "model": "llama-3.1-sonar-small-128k-online", + "messages": [ + { + "role": "system", + "content": "Be precise and concise." + }, + { + "role": "user", + "content": "How many stars are there in our galaxy?" + } + ] +}' | jq . +``` + +Response: + +```shell +{ + "id": "b525515f-8f9a-44b4-b0b1-cf867b4e96fd", + "model": "llama-3.1-sonar-small-128k-online", + "created": 1723902255, + "usage": { + "prompt_tokens": 14, + "completion_tokens": 23, + "total_tokens": 37 + }, + "object": "chat.completion", + "choices": [ + { + "index": 0, + "finish_reason": "stop", + "message": { + "role": "assistant", + "content": "Our galaxy, the Milky Way, is estimated to contain approximately 100 billion stars." + }, + "delta": { + "role": "assistant", + "content": "" + } + } + ] +} +``` + +Request (enabling stream): + +```shell +curl --request POST \ + --url https://api.perplexity.ai/chat/completions \ + --header "Authorization: Bearer ${PERPLEXITY_API_KEY}" \ + --header 'accept: application/json' \ + --header 'content-type: application/json' \ + --data ' +{ + "model": "llama-3.1-sonar-small-128k-online", + "stream": true, + "messages": [ + { + "role": "system", + "content": "Be precise and concise." + }, + { + "role": "user", + "content": "How many stars are there in our galaxy?" + } + ] +}' +``` + +Response: + +```shell +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 1, "total_tokens": 15}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There"}, "delta": {"role": "assistant", "content": "There"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 3, "total_tokens": 17}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately"}, "delta": {"role": "assistant", "content": " are approximately"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 5, "total_tokens": 19}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately 100"}, "delta": {"role": "assistant", "content": " 100"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 7, "total_tokens": 21}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately 100 billion stars"}, "delta": {"role": "assistant", "content": " billion stars"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 9, "total_tokens": 23}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately 100 billion stars in the"}, "delta": {"role": "assistant", "content": " in the"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 11, "total_tokens": 25}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately 100 billion stars in the Milky Way"}, "delta": {"role": "assistant", "content": " Milky Way"}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 19, "total_tokens": 33}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": null, "message": {"role": "assistant", "content": "There are approximately 100 billion stars in the Milky Way galaxy."}, "delta": {"role": "assistant", "content": " galaxy."}}]} + +data: {"id": "21899d42-c7fc-40e3-88a2-1780bf30c357", "model": "llama-3.1-sonar-small-128k-online", "created": 1723902901, "usage": {"prompt_tokens": 14, "completion_tokens": 19, "total_tokens": 33}, "object": "chat.completion", "choices": [{"index": 0, "finish_reason": "stop", "message": {"role": "assistant", "content": "There are approximately 100 billion stars in the Milky Way galaxy."}, "delta": {"role": "assistant", "content": ""}}]} +``` \ No newline at end of file diff --git a/docs/release_procedures.md b/docs/release_procedures.md index 6c3dd71..d61ad64 100644 --- a/docs/release_procedures.md +++ b/docs/release_procedures.md @@ -52,7 +52,7 @@ system and architecture. ## 5. Bump the version -Bump the version in the Homebrew formulae (`kardolus/homebrew-chatgpt-cli/HomebrewFormula/chatgpt-cli.rb`). Update the +Change the URL in the Homebrew formulae (`kardolus/homebrew-chatgpt-cli/HomebrewFormula/chatgpt-cli.rb`). Update the sha256 of the tar file using: ```shell