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 Jul 27, 2023
1 parent 5582cba commit c98b28b
Show file tree
Hide file tree
Showing 31 changed files with 1,219 additions and 1,181 deletions.
65 changes: 45 additions & 20 deletions examples/ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,30 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Ai/api](https:

Endpoints:

## Chat
## Stream

Make a request to ChatGPT
Stream a response from chatgpt


[https://m3o.com/ai/api#Chat](https://m3o.com/ai/api#Chat)
[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)

// 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."
}
],
// Stream a response from chatgpt
async function streamResponseFromChatGpt() {
const rsp = await aiService.stream({
"model": "gpt-3.5-turbo",
"prompt": "when did he die?"
"prompt": "write helloworld in node.js"
})
console.log(rsp)

rsp.onMessage(msg => {
console.log(msg)
})
}

chatWithChatGpt()
streamResponseFromChatGpt()
```
## Complete

Expand Down Expand Up @@ -130,3 +121,37 @@ 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()
```
13 changes: 13 additions & 0 deletions examples/ai/stream/streamResponseFromChatGpt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const m3o = require('m3o').default(process.env.M3O_API_TOKEN)

async function main() {
let rsp = await m3o.ai.stream({
model: 'gpt-3.5-turbo',
prompt: 'write helloworld in node.js'
})
rsp.onMessage((msg) => {
console.log(msg)
})
}

main()
42 changes: 21 additions & 21 deletions examples/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ async function getAnApp() {

getAnApp()
```
## 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()
```
## Regions

Return the support regions
Expand Down Expand Up @@ -117,27 +138,6 @@ async function reserveAppName() {

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()
```
## Run

Run an app from source
Expand Down
46 changes: 23 additions & 23 deletions examples/bitcoin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Bitcoin/api](h

Endpoints:

## Transaction

Get transaction details by hash


[https://m3o.com/bitcoin/api#Transaction](https://m3o.com/bitcoin/api#Transaction)

```js
const { BitcoinService } = require('m3o/bitcoin');

const bitcoinService = new BitcoinService(process.env.M3O_API_TOKEN)

// Get transaction details by hash
async function getAbitcoinTransaction() {
const rsp = await bitcoinService.transaction({
"hash": "f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449"
})
console.log(rsp)

}

getAbitcoinTransaction()
```
## Price

Get the price of bitcoin
Expand Down Expand Up @@ -96,3 +73,26 @@ async function lookupTransactionsByAddress() {

lookupTransactionsByAddress()
```
## Transaction

Get transaction details by hash


[https://m3o.com/bitcoin/api#Transaction](https://m3o.com/bitcoin/api#Transaction)

```js
const { BitcoinService } = require('m3o/bitcoin');

const bitcoinService = new BitcoinService(process.env.M3O_API_TOKEN)

// Get transaction details by hash
async function getAbitcoinTransaction() {
const rsp = await bitcoinService.transaction({
"hash": "f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449"
})
console.log(rsp)

}

getAbitcoinTransaction()
```
92 changes: 46 additions & 46 deletions examples/cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,6 @@ An [m3o.com](https://m3o.com) API. For example usage see [m3o.com/Cache/api](htt

Endpoints:

## Get

Get an item from the cache by key. If key is not found, an empty response is returned.


[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)

```js
const { CacheService } = require('m3o/cache');

const cacheService = new CacheService(process.env.M3O_API_TOKEN)

// Get an item from the cache by key. If key is not found, an empty response is returned.
async function getAvalue() {
const rsp = await cacheService.get({
"key": "foo"
})
console.log(rsp)

}

getAvalue()
```
## Delete

Delete a value from the cache. If key not found a success response is returned.


[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)

```js
const { CacheService } = require('m3o/cache');

const cacheService = new CacheService(process.env.M3O_API_TOKEN)

// Delete a value from the cache. If key not found a success response is returned.
async function deleteAvalue() {
const rsp = await cacheService.delete({
"key": "foo"
})
console.log(rsp)

}

deleteAvalue()
```
## Increment

Increment a value (if it's a number). If key not found it is equivalent to set.
Expand Down Expand Up @@ -143,3 +97,49 @@ async function setAvalue() {

setAvalue()
```
## Get

Get an item from the cache by key. If key is not found, an empty response is returned.


[https://m3o.com/cache/api#Get](https://m3o.com/cache/api#Get)

```js
const { CacheService } = require('m3o/cache');

const cacheService = new CacheService(process.env.M3O_API_TOKEN)

// Get an item from the cache by key. If key is not found, an empty response is returned.
async function getAvalue() {
const rsp = await cacheService.get({
"key": "foo"
})
console.log(rsp)

}

getAvalue()
```
## Delete

Delete a value from the cache. If key not found a success response is returned.


[https://m3o.com/cache/api#Delete](https://m3o.com/cache/api#Delete)

```js
const { CacheService } = require('m3o/cache');

const cacheService = new CacheService(process.env.M3O_API_TOKEN)

// Delete a value from the cache. If key not found a success response is returned.
async function deleteAvalue() {
const rsp = await cacheService.delete({
"key": "foo"
})
console.log(rsp)

}

deleteAvalue()
```
Loading

0 comments on commit c98b28b

Please sign in to comment.