Skip to content

Commit

Permalink
Commit from m3o/m3o action
Browse files Browse the repository at this point in the history
  • Loading branch information
m3o-actions committed Sep 22, 2023
1 parent 472245a commit 95cf61b
Show file tree
Hide file tree
Showing 26 changed files with 1,190 additions and 1,190 deletions.
118 changes: 59 additions & 59 deletions examples/ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ai/api](https:

Endpoints:

## Chat

Make a request to ChatGPT


[https://m3o.com/ai/api#Chat](https://m3o.com/ai/api#Chat)

```js
const { AiService } = require('m3o/ai');

const aiService = new AiService(process.env.M3O_API_TOKEN)

// Make a request to ChatGPT
async function chatWithChatGpt() {
const rsp = await aiService.chat({
"context": [
{
"prompt": "who is leonardo davinci",
"reply": "Leonardo da Vinci was an Italian polymath during the Renaissance period. He was born in 1452 in Vinci, Italy, and is renowned for his contributions to various fields such as science, engineering, art, and anatomy. Da Vinci's most famous works include the Mona Lisa and The Last Supper. He is often considered one of the greatest artists and thinkers of all time."
},
{
"prompt": "where is he from?",
"reply": "Leonardo da Vinci was from Vinci, a town in Tuscany, Italy."
}
],
"model": "gpt-3.5-turbo",
"prompt": "when did he die?"
})
console.log(rsp)

}

chatWithChatGpt()
```
## Stream

Stream a response from chatgpt


[https://m3o.com/ai/api#Stream](https://m3o.com/ai/api#Stream)

```js
const { AiService } = require('m3o/ai');

const aiService = new AiService(process.env.M3O_API_TOKEN)

// Stream a response from chatgpt
async function streamResponseFromChatGpt() {
const rsp = await aiService.stream({
"model": "gpt-3.5-turbo",
"prompt": "write helloworld in node.js"
})
rsp.onMessage(msg => {
console.log(msg)
})
}

streamResponseFromChatGpt()
```
## Complete

Make a request to the AI
Expand Down Expand Up @@ -155,3 +96,62 @@ async function moderateHateSpeech() {

moderateHateSpeech()
```
## Chat

Make a request to ChatGPT


[https://m3o.com/ai/api#Chat](https://m3o.com/ai/api#Chat)

```js
const { AiService } = require('m3o/ai');

const aiService = new AiService(process.env.M3O_API_TOKEN)

// Make a request to ChatGPT
async function chatWithChatGpt() {
const rsp = await aiService.chat({
"context": [
{
"prompt": "who is leonardo davinci",
"reply": "Leonardo da Vinci was an Italian polymath during the Renaissance period. He was born in 1452 in Vinci, Italy, and is renowned for his contributions to various fields such as science, engineering, art, and anatomy. Da Vinci's most famous works include the Mona Lisa and The Last Supper. He is often considered one of the greatest artists and thinkers of all time."
},
{
"prompt": "where is he from?",
"reply": "Leonardo da Vinci was from Vinci, a town in Tuscany, Italy."
}
],
"model": "gpt-3.5-turbo",
"prompt": "when did he die?"
})
console.log(rsp)

}

chatWithChatGpt()
```
## Stream

Stream a response from chatgpt


[https://m3o.com/ai/api#Stream](https://m3o.com/ai/api#Stream)

```js
const { AiService } = require('m3o/ai');

const aiService = new AiService(process.env.M3O_API_TOKEN)

// Stream a response from chatgpt
async function streamResponseFromChatGpt() {
const rsp = await aiService.stream({
"model": "gpt-3.5-turbo",
"prompt": "write helloworld in node.js"
})
rsp.onMessage(msg => {
console.log(msg)
})
}

streamResponseFromChatGpt()
```
148 changes: 74 additions & 74 deletions examples/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/App/api](https

Endpoints:

## Regions

Return the support regions


[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Return the support regions
async function listRegions() {
const rsp = await appService.regions({})
console.log(rsp)

}

listRegions()
```
## Status

Get the status of an app
Expand All @@ -27,6 +48,52 @@ async function getTheStatusOfAnApp() {

getTheStatusOfAnApp()
```
## Update

Update the app. The latest source code will be downloaded, built and deployed.


[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Update the app. The latest source code will be downloaded, built and deployed.
async function updateAnApp() {
const rsp = await appService.update({
"name": "helloworld"
})
console.log(rsp)

}

updateAnApp()
```
## Reserve

Reserve app names


[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Reserve app names
async function reserveAppName() {
const rsp = await appService.reserve({
"name": "helloworld"
})
console.log(rsp)

}

reserveAppName()
```
## Get

Get an app by name
Expand All @@ -50,26 +117,26 @@ async function getAnApp() {

getAnApp()
```
## Regions
## List

Return the support regions
List all the apps


[https://m3o.com/app/api#Regions](https://m3o.com/app/api#Regions)
[https://m3o.com/app/api#List](https://m3o.com/app/api#List)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Return the support regions
async function listRegions() {
const rsp = await appService.regions({})
// List all the apps
async function listTheApps() {
const rsp = await appService.list({})
console.log(rsp)

}

listRegions()
listTheApps()
```
## Run

Expand Down Expand Up @@ -121,29 +188,6 @@ async function resolveAppById() {

resolveAppById()
```
## Update

Update the app. The latest source code will be downloaded, built and deployed.


[https://m3o.com/app/api#Update](https://m3o.com/app/api#Update)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Update the app. The latest source code will be downloaded, built and deployed.
async function updateAnApp() {
const rsp = await appService.update({
"name": "helloworld"
})
console.log(rsp)

}

updateAnApp()
```
## Delete

Delete an app
Expand Down Expand Up @@ -191,47 +235,3 @@ async function retrieveBuildLogsForAnApp() {

retrieveBuildLogsForAnApp()
```
## Reserve

Reserve app names


[https://m3o.com/app/api#Reserve](https://m3o.com/app/api#Reserve)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// Reserve app names
async function reserveAppName() {
const rsp = await appService.reserve({
"name": "helloworld"
})
console.log(rsp)

}

reserveAppName()
```
## List

List all the apps


[https://m3o.com/app/api#List](https://m3o.com/app/api#List)

```js
const { AppService } = require('m3o/app');

const appService = new AppService(process.env.M3O_API_TOKEN)

// List all the apps
async function listTheApps() {
const rsp = await appService.list({})
console.log(rsp)

}

listTheApps()
```
Loading

0 comments on commit 95cf61b

Please sign in to comment.