Open In Colab

In [1]:
!pip install runpod
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting runpod
  Downloading runpod-0.9.11-py3-none-any.whl (36 kB)
Collecting aiohttp>=3.8.3 (from runpod)
  Downloading aiohttp-3.8.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 15.3 MB/s eta 0:00:00
Collecting backoff>=2.2.1 (from runpod)
  Downloading backoff-2.2.1-py3-none-any.whl (15 kB)
Collecting boto3>=1.26.142 (from runpod)
  Downloading boto3-1.26.156-py3-none-any.whl (135 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 135.6/135.6 kB 14.3 MB/s eta 0:00:00
Collecting pillow>=9.3.0 (from runpod)
  Downloading Pillow-9.5.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 64.0 MB/s eta 0:00:00
Requirement already satisfied: py-cpuinfo>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from runpod) (9.0.0)
Collecting python-dotenv>=0.21.0 (from runpod)
  Downloading python_dotenv-1.0.0-py3-none-any.whl (19 kB)
Collecting requests>=2.31.0 (from runpod)
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 7.1 MB/s eta 0:00:00
Collecting tqdm-loggable>=0.1.3 (from runpod)
  Downloading tqdm_loggable-0.1.4-py3-none-any.whl (9.0 kB)
Collecting fastapi[all]>=0.95.2 (from runpod)
  Downloading fastapi-0.97.0-py3-none-any.whl (56 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.0/57.0 kB 7.0 MB/s eta 0:00:00
Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.8.3->runpod) (23.1.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp>=3.8.3->runpod) (2.0.12)
Collecting multidict<7.0,>=4.5 (from aiohttp>=3.8.3->runpod)
  Downloading multidict-6.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (114 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 114.5/114.5 kB 11.3 MB/s eta 0:00:00
Collecting async-timeout<5.0,>=4.0.0a3 (from aiohttp>=3.8.3->runpod)
  Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting yarl<2.0,>=1.0 (from aiohttp>=3.8.3->runpod)
  Downloading yarl-1.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (268 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 268.8/268.8 kB 20.8 MB/s eta 0:00:00
Collecting frozenlist>=1.1.1 (from aiohttp>=3.8.3->runpod)
  Downloading frozenlist-1.3.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 149.6/149.6 kB 18.1 MB/s eta 0:00:00
Collecting aiosignal>=1.1.2 (from aiohttp>=3.8.3->runpod)
  Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting botocore<1.30.0,>=1.29.156 (from boto3>=1.26.142->runpod)
  Downloading botocore-1.29.156-py3-none-any.whl (10.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 87.5 MB/s eta 0:00:00
Collecting jmespath<2.0.0,>=0.7.1 (from boto3>=1.26.142->runpod)
  Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
Collecting s3transfer<0.7.0,>=0.6.0 (from boto3>=1.26.142->runpod)
  Downloading s3transfer-0.6.1-py3-none-any.whl (79 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.8/79.8 kB 10.6 MB/s eta 0:00:00
Requirement already satisfied: pydantic!=1.8,!=1.8.1,<2.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from fastapi[all]>=0.95.2->runpod) (1.10.7)
Collecting starlette<0.28.0,>=0.27.0 (from fastapi[all]>=0.95.2->runpod)
  Downloading starlette-0.27.0-py3-none-any.whl (66 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.0/67.0 kB 5.1 MB/s eta 0:00:00
Collecting email-validator>=1.1.1 (from fastapi[all]>=0.95.2->runpod)
  Downloading email_validator-2.0.0.post2-py3-none-any.whl (31 kB)
Collecting httpx>=0.23.0 (from fastapi[all]>=0.95.2->runpod)
  Downloading httpx-0.24.1-py3-none-any.whl (75 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.4/75.4 kB 8.2 MB/s eta 0:00:00
Requirement already satisfied: itsdangerous>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from fastapi[all]>=0.95.2->runpod) (2.1.2)
Requirement already satisfied: jinja2>=2.11.2 in /usr/local/lib/python3.10/dist-packages (from fastapi[all]>=0.95.2->runpod) (3.1.2)
Collecting orjson>=3.2.1 (from fastapi[all]>=0.95.2->runpod)
  Downloading orjson-3.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (136 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 137.0/137.0 kB 15.1 MB/s eta 0:00:00
Collecting python-multipart>=0.0.5 (from fastapi[all]>=0.95.2->runpod)
  Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.7/45.7 kB 4.8 MB/s eta 0:00:00
Requirement already satisfied: pyyaml>=5.3.1 in /usr/local/lib/python3.10/dist-packages (from fastapi[all]>=0.95.2->runpod) (6.0)
Collecting ujson!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,>=4.0.1 (from fastapi[all]>=0.95.2->runpod)
  Downloading ujson-5.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (53 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.9/53.9 kB 6.5 MB/s eta 0:00:00
Collecting uvicorn[standard]>=0.12.0 (from fastapi[all]>=0.95.2->runpod)
  Downloading uvicorn-0.22.0-py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 7.9 MB/s eta 0:00:00
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->runpod) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->runpod) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->runpod) (2022.12.7)
Requirement already satisfied: tqdm<5.0.0,>=4.64.1 in /usr/local/lib/python3.10/dist-packages (from tqdm-loggable>=0.1.3->runpod) (4.65.0)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.10/dist-packages (from botocore<1.30.0,>=1.29.156->boto3>=1.26.142->runpod) (2.8.2)
Collecting dnspython>=2.0.0 (from email-validator>=1.1.1->fastapi[all]>=0.95.2->runpod)
  Downloading dnspython-2.3.0-py3-none-any.whl (283 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 283.7/283.7 kB 24.5 MB/s eta 0:00:00
Collecting httpcore<0.18.0,>=0.15.0 (from httpx>=0.23.0->fastapi[all]>=0.95.2->runpod)
  Downloading httpcore-0.17.2-py3-none-any.whl (72 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.5/72.5 kB 8.9 MB/s eta 0:00:00
Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx>=0.23.0->fastapi[all]>=0.95.2->runpod) (1.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2>=2.11.2->fastapi[all]>=0.95.2->runpod) (2.1.2)
Requirement already satisfied: typing-extensions>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<2.0.0,>=1.7.4->fastapi[all]>=0.95.2->runpod) (4.5.0)
Requirement already satisfied: anyio<5,>=3.4.0 in /usr/local/lib/python3.10/dist-packages (from starlette<0.28.0,>=0.27.0->fastapi[all]>=0.95.2->runpod) (3.6.2)
Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod) (8.1.3)
Collecting h11>=0.8 (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod)
  Downloading h11-0.14.0-py3-none-any.whl (58 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 6.8 MB/s eta 0:00:00
Collecting httptools>=0.5.0 (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod)
  Downloading httptools-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (414 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 414.1/414.1 kB 40.3 MB/s eta 0:00:00
Collecting uvloop!=0.15.0,!=0.15.1,>=0.14.0 (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod)
  Downloading uvloop-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 91.1 MB/s eta 0:00:00
Collecting watchfiles>=0.13 (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod)
  Downloading watchfiles-0.19.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 60.6 MB/s eta 0:00:00
Collecting websockets>=10.4 (from uvicorn[standard]>=0.12.0->fastapi[all]>=0.95.2->runpod)
  Downloading websockets-11.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 129.9/129.9 kB 15.7 MB/s eta 0:00:00
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.30.0,>=1.29.156->boto3>=1.26.142->runpod) (1.16.0)
Installing collected packages: websockets, uvloop, ujson, tqdm-loggable, requests, python-multipart, python-dotenv, pillow, orjson, multidict, jmespath, httptools, h11, frozenlist, dnspython, backoff, async-timeout, yarl, watchfiles, uvicorn, starlette, httpcore, email-validator, botocore, aiosignal, s3transfer, httpx, fastapi, aiohttp, boto3, runpod
  Attempting uninstall: requests
    Found existing installation: requests 2.27.1
    Uninstalling requests-2.27.1:
      Successfully uninstalled requests-2.27.1
  Attempting uninstall: pillow
    Found existing installation: Pillow 8.4.0
    Uninstalling Pillow-8.4.0:
      Successfully uninstalled Pillow-8.4.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
google-colab 1.0.0 requires requests==2.27.1, but you have requests 2.31.0 which is incompatible.
Successfully installed aiohttp-3.8.4 aiosignal-1.3.1 async-timeout-4.0.2 backoff-2.2.1 boto3-1.26.156 botocore-1.29.156 dnspython-2.3.0 email-validator-2.0.0.post2 fastapi-0.97.0 frozenlist-1.3.3 h11-0.14.0 httpcore-0.17.2 httptools-0.5.0 httpx-0.24.1 jmespath-1.0.1 multidict-6.0.4 orjson-3.9.1 pillow-9.5.0 python-dotenv-1.0.0 python-multipart-0.0.6 requests-2.31.0 runpod-0.9.11 s3transfer-0.6.1 starlette-0.27.0 tqdm-loggable-0.1.4 ujson-5.8.0 uvicorn-0.22.0 uvloop-0.17.0 watchfiles-0.19.0 websockets-11.0.3 yarl-1.9.2
In [1]:
import runpod

runpod.api_key = "api_key"
In [2]:
endpoint = runpod.Endpoint("endpoint")
Initialized endpoint: 9ugb6l9sqico22
In [10]:
run_request = endpoint.run({
  "prompt": "The following is a chat between a USER and a helpful ASSISTANT.\nUSER: Tell me about the stars. \nASSISTANT:",
  "stream": False
})
Started job: 80d80e34-0765-4fd4-888e-930d79e6205a
In [11]:
print(run_request.status())
IN_PROGRESS
In [12]:
print(run_request.output())
Stars are massive, luminous objects that emit light and radiation from nuclear fusion in their cores. They are formed when gas clouds collapse under gravity, resulting in an increase of temperature and pressure due to conservation of energy. This leads to the ignition of a star, which then begins to shine brightly.

Stars come in various shapes and sizes, ranging from small red dwarfs that make up most of our galaxy's stars to giants like Betelgeuse and Rigel, which are some of the largest known stars in our universe. They also vary greatly in their compositions, with many types of stars combining hydrogen fuel for fusion with heavier elements such as carbon or even iron.

Stars have a wide range of properties that make them unique among celestial bodies, including size (some stars are millions to billions of times larger than our Sun), mass (stars can contain thousands of times the mass of our own solar system), and temperature. Their radiation output is enormous and ranges from ultraviolet light for very hot stars to radio waves for more cooler ones.

Stars play an important role in shaping our universe, including affecting
In [22]:
instruction = "Write a simple rust program then translate it to go"
run_request = endpoint.run({
  "prompt": f"The following is a chat between a USER and a helpful ASSISTANT.\nUSER: {instruction} \nASSISTANT:",
  "stream": False
})
Started job: f6419435-f51b-435d-a946-0f4cc3fc2cc6
In [23]:
print(run_request.status())
IN_PROGRESS
In [24]:
print(run_request.output())
Sure, here's an example of a simple Rust program that calculates the factorial of a number using loops and conditionals:

```rust
fn main() {
    let num = 5; // define input value
    let fact = Factorial::new(num); // create Factorial struct

    println!("Factorial of {} is {}", num, fact.factorial()); // print factorial result
}

struct Factorial {
    n: u32,
}

impl Factorial {
    fn new(n: u32) -> Factorial {
        Factorial {
            n,
        }
    }

    fn factorial(&self) -> u32 {
        let mut fact = 1; // initialize result to 1

        for i in 1..=self.n {
            fact *= i; // calculate factorial using a loop with conditional
        }

        return fact;
    }
}
```

And here's the translated Go code:

```go
package main

import "fmt"

func main() {
    n := 5
    fact := Factorial(n)

    fmt.Println("Factorial of", n, "is", fact.factorial())
In [ ]:
 
In [25]:
instruction = "你好,请介绍万里长城"
run_request = endpoint.run({
  "prompt": f"The following is a chat between a USER and a helpful ASSISTANT.\nUSER: {instruction} \nASSISTANT:",
  "stream": False
})
Started job: 5ed4f7c6-661f-41e5-8cea-f3a742fa4821
In [26]:
print(run_request.status())
IN_PROGRESS
In [27]:
print(run_request.output())
Sure, I'd be happy to introduce you to the Great Wall of China! The wall was built as an extension of the Chinese Empire in the Ming Dynasty (1368-1644). It stretches over a distance of approximately 21,000 kilometers and is made up of several sections, including the Jinshanling section located in Hebei Province.

The Great Wall was constructed to protect China from invading nomadic tribes such as the Mongols. It consists of multiple layers of fortifications made with materials like stone, brick, and tamped earth. The wall is divided into watchtowers, guard posts, and other defensive structures along its length.

The construction of the Great Wall began in 7th century BC when Emperor Qin Shi Huang started building a series of walls to protect his new capital city from nomadic invaders. Over time, more sections were added as needed until it became the impressive structure that we see today.

The wall was built over several hundred years and took many lives in its construction. The cost of building the Great Wall is estimated to be around 23 billion