Skip to content

Commit

Permalink
docs(free-apis): refactor and add documentation on Anthropic usage (#78)
Browse files Browse the repository at this point in the history
* docs(free-apis): refactor and add documentation on Anthropic usage

* chore(npm): add missing packages and updates

* feat(header): make header bar nicer

* fix(manim): resolve mdx compilation errors
  • Loading branch information
ElioDiNino authored Jul 10, 2024
1 parent 318909b commit 90de8a8
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 85 deletions.
39 changes: 29 additions & 10 deletions docs/labs/free-apis.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Free APIs Available in Skills Network Labs

While taking labs within Skills Network Labs, your learners will have free access to some APIs.
While taking labs within Skills Network Labs, your learners will have free access to some APIs.
This helps learners get started with the interesting stuff right away, without immediately worrying about registration.

## Learner Quotas
Expand All @@ -15,12 +15,12 @@ RateLimitError: Error code: 429 - {'error': 'You have exceeded your usage quota

## Limitations

These free Skills Network-provided APIs are available for learning and experimentation. They are not suitable when it comes to deploying an application.
These free Skills Network-provided APIs are available for learning and experimentation. They are not suitable when it comes to deploying an application.

Learners will have access to these APIs within their:
- Cloud IDE (from their terminal/shell, or when running an application from within Cloud IDE)
- JupyterLab IDE (from their notebook, or from the JupyterLab terminal/shell)
- Rstudio IDE
- RStudio IDE

Learners will _not_ have free access to these APIs within their:
- Code Engine projects
Expand All @@ -31,11 +31,9 @@ Learners will _not_ have free access to these APIs within their:

## Free APIs

### watsonx.ai
### Versioning

#### Versioning

It is recommended that authors follow the instructions below using the default `ibm-watsonx-ai` version installed with pip. However, after doing so, please pin the version you used for your learners. If you encounter an error with the latest package version and the following instructions, please let us know!
It is recommended that authors follow the instructions below using the default package version installed with pip. However, after doing so, please pin the version you used for your learners. If you encounter an error with the latest package version and the following instructions, please let us know!

For example:
```shell
Expand All @@ -54,6 +52,8 @@ pip install ibm-watsonx-ai==0.2.0

#### Usage

#### watsonx.ai

To use the free Skills Network-provided watsonx.ai project, specify the `"url"` and `project_id = "skills-network"` (make sure to **leave out** `"token"` and `"apikey"`). For example, you can modify [the example from the official documentation for the ibm_watsonx_ai library](https://www.ibm.com/docs/en/watsonx/saas?topic=library-inferencing-foundation-model) as follows:

```python
Expand Down Expand Up @@ -89,17 +89,17 @@ generated_response = model.generate(prompt=prompt_txt, params=gen_parms_override
print(json.dumps(generated_response, indent=2))
```

### OpenAI
#### OpenAI

To use the free Skills Network-provided OpenAI APIs, no additional configuration is necessary. You can use [the examples from the official documentation](https://platform.openai.com/docs/api-reference/chat/create) without modification.
To use the free Skills Network-provided OpenAI API, no additional configuration is necessary. You can use [the examples from the official documentation](https://platform.openai.com/docs/api-reference/chat/create?lang=python) without modification.

For example:
```python
from openai import OpenAI
client = OpenAI()

completion = client.chat.completions.create(
model="gpt-3.5-turbo",
model="gpt-4.0",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
Expand All @@ -108,3 +108,22 @@ completion = client.chat.completions.create(

print(completion.choices[0].message)
```

#### Anthropic

To use the free Skills Network-provided Anthropic API, make sure to **leave out** the `"apikey"` parameter in the Anthropic client. You can use [the example from the official documentation](https://docs.anthropic.com/en/api/client-sdks#python) as follows:

```python
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude"}
]
)
print(message.content)
```
121 changes: 68 additions & 53 deletions docs/labs/misc/manim.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,45 @@ Manim can be difficult to install so this tutorial will teach you how to run it
## Setup

<ol>
<li><p>The first thing you're going to need is Docker. If you don't already have docker, you can download it <a href="https://docs.docker.com/get-docker/">here</a>.</p></li>
<li><p>Pull the docker image for manim:</p>

```bash
docker pull manimcommunity/manim
```
<li>
<p>The first thing you're going to need is Docker. If you don't already have docker, you can download it <a href="https://docs.docker.com/get-docker/">here</a>.</p>
</li>
<li>
<p>Pull the docker image for manim:</p>

<p>For more information, check out <a href="https://hub.docker.com/r/manimcommunity/manim">mainimcommunity/manim</a></p>
```bash
docker pull manimcommunity/manim
```

<p>For more information, check out <a href="https://hub.docker.com/r/manimcommunity/manim">mainimcommunity/manim</a></p>
</li>
<li>
<p>There are several ways to interact with Manim. We're going to work with Jupyter Lab. For different methods check out <a href="https://hub.docker.com/r/manimcommunity/manim">this link</a>.</p>
</li>
<li><p>There are several ways to interact with Manim. We're going to work with Jupyter Lab. For different methods check out <a href="https://hub.docker.com/r/manimcommunity/manim">this link</a>.</p></li>
<li><p>First, make sure nothing is running on port 8888, then open a terminal window and run the following command to start up the manim docker container:</p>
<li>
<p>First, make sure nothing is running on port 8888, then open a terminal window and run the following command to start up the manim docker container:</p>

```bash
docker run -it -p 8888:8888 manimcommunity/manim jupyter lab --ip=0.0.0.0
```
```bash
docker run -it -p 8888:8888 manimcommunity/manim jupyter lab --ip=0.0.0.0
```

</li>
<li><p>You should see the following output:</p>
<li>
<p>You should see the following output:</p>

```
file:///manim/.local/share/jupyter/runtime/jpserver-1-open.html
```
file:///manim/.local/share/jupyter/runtime/jpserver-1-open.html

Or copy and paste one of these URLs:
Or copy and paste one of these URLs:

http://1a7fb2e74b32:8888/lab?token=542f72b2a4f0f8eb58089e3ab795f43c1ad3730b0500af58
http://1a7fb2e74b32:8888/lab?token=542f72b2a4f0f8eb58089e3ab795f43c1ad3730b0500af58

or http://127.0.0.1:8888/lab?token=542f72b2a4f0f8eb58089e3ab795f43c1ad3730b0500af58
```
or http://127.0.0.1:8888/lab?token=542f72b2a4f0f8eb58089e3ab795f43c1ad3730b0500af58
```

<p>Cut and Paste one of the above links in your browser. You should see the following:</p>
<p>Cut and Paste one of the above links in your browser. You should see the following:</p>

<img width="70%" src={require('@site/static/img/labs/misc/manim_browser.png').default} />
<img width="70%" src={require('@site/static/img/labs/misc/manim_browser.png').default} />

</li>
<li>Congratulations! You're now ready to use manim!</li>
Expand All @@ -54,17 +60,19 @@ Or copy and paste one of these URLs:
Let's start with a simple example:

<ol>
<li><p>Open a new JupyterLab notebook and import all the contents of the manim library in a cell:</p>
<li>
<p>Open a new JupyterLab notebook and import all the contents of the manim library in a cell:</p>

```python
from manim import *
```python
from manim import *

# To download image used in this example:
!wget https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/assets/logos/SN_favicon.png
```
# To download image used in this example:
!wget https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/assets/logos/SN_favicon.png
```
</li>

<li><p>Objects in manim are generally divided into three categories:</p>
<li>
<p>Objects in manim are generally divided into three categories:</p>
<ul>
<li><p>Scene</p></li>
<li><p>Mobject</p></li>
Expand All @@ -88,20 +96,22 @@ class SN(Scene):
```

</li>
<li><p>To run the scene, execute the following in the next code cell:</p>
<li>
<p>To run the scene, execute the following in the next code cell:</p>

```python
%manim SN
```
```python
%manim SN
```

<p>More generally, <code>%manim [name of class]</code> - where <code>[name of class]</code> is the name of the scene class you defined.</p>
<p>More generally, <code>%manim [name of class]</code> - where <code>[name of class]</code> is the name of the scene class you defined.</p>

</li>
<li><p>You should see a scene resembling the following:</p>
<li>
<p>You should see a scene resembling the following:</p>

<img width="70%" src={require('@site/static/img/labs/misc/manim_scene.png').default} />
<img width="70%" src={require('@site/static/img/labs/misc/manim_scene.png').default} />

<p>For more information, check out the <a href="https://docs.manim.community/en/stable/">Manim docs</a>.</p>
<p>For more information, check out the <a href="https://docs.manim.community/en/stable/">Manim docs</a>.</p>

</li>
</ol>
Expand All @@ -112,34 +122,39 @@ __If you shut down your Docker Container you will lose your work.__
So you're going to need to download the video and JupyterLab. The lab is straightforward; let's see how to download the video:

<ol>
<li><p>Go to the directory <code>./media/Jupiter/</code></p></li>
<li><p>Download the video, which is the name of the class followed by an <code>@</code> and the date:</p>
<li>
<p>Go to the directory <code>./media/Jupiter/</code></p>
</li>
<li>
<p>Download the video, which is the name of the class followed by an <code>@</code> and the date:</p>

<p>For example, <code>SN@[email protected] more generally [name of class]@[date].mp4</code> as seen in the image below:</p>
<p>For example, <code>SN@[email protected] more generally [name of class]@[date].mp4</code> as seen in the image below:</p>

<img width="30%" src={require('@site/static/img/labs/misc/manim_download_video.png').default} />
<img width="30%" src={require('@site/static/img/labs/misc/manim_download_video.png').default} />

</li>
<li><p>Finally, when you close your application you must make sure the container is closed, open a terminal window and type:</p>
<li>
<p>Finally, when you close your application you must make sure the container is closed, open a terminal window and type:</p>

```bash
docker ps
```
```bash
docker ps
```

<p>You should see a list of your running containers, for example:</p>
<p>You should see a list of your running containers, for example:</p>

```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

1a7fb2e74b32 manimcommunity/manim "jupyter lab --ip=0.…" 3 days ago Up 3 days 0.0.0.0:8888->8888/tcp peaceful_kowalevski
```
1a7fb2e74b32 manimcommunity/manim "jupyter lab --ip=0.…" 3 days ago Up 3 days 0.0.0.0:8888->8888/tcp peaceful_kowalevski
```

</li>
<li><p>stop the container by typing <code>docker stop [name of container]</code> for this case it would be </p>
<li>
<p>stop the container by typing <code>docker stop [name of container]</code> for this case it would be </p>

```bash
docker stop peaceful_kowalevski
```
```bash
docker stop peaceful_kowalevski
```

</li>

Expand Down
10 changes: 2 additions & 8 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Author Workbench Knowledge Base',
tagline: 'TODO',
tagline: 'Author Workbench Knowledge Base',
url: 'https://author.skills.network',
baseUrl: '/docs/',
onBrokenLinks: 'throw',
Expand Down Expand Up @@ -39,18 +39,12 @@ const config = {
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
navbar: {
title: 'Home',
title: 'Author Workbench Knowledge Base',
logo: {
alt: 'Skills Network Logo',
src: 'img/logo.svg',
},
items: [
{
type: 'doc',
docId: 'getting-started',
position: 'left',
label: 'Author Workbench Knowledge Base',
},
{
href: 'https://author.skills.network',
label: 'Author Workbench',
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^3.0.0",
"@mdx-js/react": "^1.6",
"@algolia/client-search": "^4.24.0",
"@docusaurus/core": "^3.4.0",
"@docusaurus/preset-classic": "^3.4.0",
"@mdx-js/react": "^3.0",
"@types/react": "^18.3.3",
"clsx": "^1.1.1",
"prism-react-renderer": "^1.3",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-loadable": "^5.5.0",
"search-insights": "^2.15.0",
"typescript": "^5.5.3"
},
"browserslist": {
"production": [
Expand Down
Loading

0 comments on commit 90de8a8

Please sign in to comment.