{"id":20551685,"url":"https://github.com/do-community/do-function-openai","last_synced_at":"2025-04-14T11:32:31.950Z","repository":{"id":90797656,"uuid":"529329968","full_name":"do-community/do-function-openai","owner":"do-community","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-15T14:37:27.000Z","size":8,"stargazers_count":4,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T00:44:17.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/do-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-26T16:27:06.000Z","updated_at":"2025-03-26T02:46:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d002dde-dcd3-4b07-8e30-85b725c466cf","html_url":"https://github.com/do-community/do-function-openai","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-function-openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-function-openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-function-openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-function-openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/do-community","download_url":"https://codeload.github.com/do-community/do-function-openai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248872002,"owners_count":21175335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T02:33:04.895Z","updated_at":"2025-04-14T11:32:31.928Z","avatar_url":"https://github.com/do-community.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Function: OpenAI Text Completion\n\n## Introduction\n\nThis repository contains a DigitalOcean Function that integrates [OpenAI](https://openai.com/) and implements the Completion API that when given a prompt, returns a completion. The function requires a POST request and in the body at a minimum requires a `prompt` property sent as `json`. Additionally, in the body of the POST request you can pass a `max_tokens`, `temperature`, and `top_p` properties. Learn more about the OpenAI Completion API [here](https://beta.openai.com/docs/api-reference/completions).\n\n## Examples\n\nSample Input: \n\n```\n{\n    \"prompt\": \"My favorite thing to do on the weekend is\",\n    \"max_tokens\": 100\n}\n```\n\nSample Response:\n\n```\ngo on long walks with my dog. We usually go to the park or around the neighborhood. I love spending time with her and\ngetting some fresh air.\n```\n\n---\n\nSample Input:\n\n```\n{\n    \"prompt\": \"What is the sentiment of the following passage: I never knew serverless was so awesome\"\n}\n```\n\nSample Response:\n\n```\nThe sentiment of the passage is positive.\n```\n\n---\n\nSample Input:\n\n```\n{\n    \"prompt\": \"Tell me a programming joke\",\n    \"max_tokens\": 100\n}\n```\n\nSample Response:\n\n```\nWhy do programmers always have to write code? Because without code, there would be nothing to debug!\n```\n\n\n## Requirements\n\n- A DigitalOcean account. [Sign up for free and get a $100 credit](https://cloud.digitalocean.com/registrations/new).\n- An OpenAI account\n\n## Deployment\n\nYou can deploy this function either via DigitalOcean's doctl CLI or directly on the DigitalOcean App Platform.\n\n### 1-Click Quick Deploy to DigitalOcean App Platform\n\n[![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/do-community/do-function-openai/tree/main)\n\n### Deploy via doctl\n\n- *Optional* Fork the repo, so you can make changes and take ownership of the code\n- Clone the repo to your machine\n- Navigate to the repo on your machine, and rename `.env.example` to `.env`\n- Open the `.env` file and set your OpenAI API Key\n- Open up a terminal and execute the doctl command: `doctl serverless deploy do-function-openai`\n\n### Deploy via App Platform\n\n- Fork the repo, so you can make changes and take ownership of the code\n- Navigate to the App Platform section in your DigitalOcean Dashboard, and either create a new app or new resource in an existing app\n- Select the do-function-openai repo that you forked\n- In the Environment Variables section, add your OpenAI API Key to the pre-populated apiKey environment variable","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-community%2Fdo-function-openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdo-community%2Fdo-function-openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-community%2Fdo-function-openai/lists"}