Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
run:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- uses: actions/checkout@v4

- uses: taiki-e/install-action@v2
with:
tool: zola@0.19.2

- run: zola build

- uses: cloudflare/wrangler-action@v3
if: github.ref == 'refs/heads/main'
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: pages deploy _public --project-name=transformrs --branch=main
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_public/
**/tmp*
**/target/
**/Cargo.lock
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# transformrs.org
Website for the transformrs Rust crate

Website for the transformrs Rust crate (crate source at <https://github.com/rikhuijzer/transformrs>).

## Development

```bash
$ zola serve
```
13 changes: 13 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title = "transformrs"
description = "An interface for AI API providers"
default_language = "en"
base_url = "https://transformrs.org"

author = "transformrs project authors"
generate_sitemap = true
generate_robots_txt = false
minify_html = false
output_dir = "_public"

# Probably need to remove _css from .gitignore if enabling.
generate_feeds = false
61 changes: 61 additions & 0 deletions content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
+++
title = "Home"
+++

<div class="hero">
<div style="margin-left: auto; margin-right: auto; text-align: center; max-width: 55ch;">
<p style="margin-top: 5vh; line-height: 150%;">
transformrs is an <span class="emphasize">interface</span> to multiple <span class="emphasize">AI APIs</span> providers.
</p>
</div>
</div>

The examples below are based on the tests in the [repository](https://github.com/rikhuijzer/transformrs/tree/main/tests).
Many tests run repeatedly against the actual APIs to ensure that the library works as expected.

## Examples

First, set your API key either in an `.env` file or as an environment variable.
For example, for DeepInfra, set `DEEPINFRA_KEY` in `.env`:

```env
DEEPINFRA_KEY=<KEY>
```

Then, you can use the API as follows.

### Chat Completion

```rust
use transformrs::openai;
use transformrs::Message;
use transformrs::Provider;

fn main() {
let messages = vec![
Message {
role: "system".to_string(),
content: "You are a helpful assistant.".to_string(),
},
Message {
role: "user".to_string(),
content: "This is a test. Please respond with 'hello world'.".to_string(),
},
];
let keys = transformrs::load_keys(".env");
let key = keys.for_provider(&Provider::DeepInfra).unwrap();
let model = "meta-llama/Llama-3.3-70B-Instruct";
// Using the OpenAI-compatible API for chat completions.
let resp = openai::chat_completion(&key, model, &messages)
.await
.unwrap();
println!("{}", resp.choices[0].message.content);
}
```

This will print:

```
hello world
```

6 changes: 6 additions & 0 deletions content/blog/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "blog"
sort_by = "date"
template = "posts.html"
page_template = "post.html"
+++
6 changes: 6 additions & 0 deletions content/blog/why.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "Actually, Rust is great for AI"
date = 2025-02-04
description = "Python is the default choice for running AI locally, but Rust is a great fit too."
+++

33 changes: 33 additions & 0 deletions content/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
+++
title = "Contributing"
page_template = "page.html"
+++

Everyone is welcome to contribute to transformrs.

- Bugs can be reported via GitHub issues at [rikhuijzer/transformrs](https://github.com/rikhuijzer/transformrs/issues).
- Changes to the source code or documentation can be sent via GitHub pull requests to [rikhuijzer/transformrs](https://github.com/rikhuijzer/transformrs/pulls).
- Changes to this website can be sent via GitHub pull requests to [rikhuijzer/transformrs.org](https://github.com/rikhuijzer/transformrs.org/pulls).

<br>

## Contributing to the Source Code

As stated above, patches can be sent via GitHub PRs to [rikhuijzer/transformrs](https://github.com/rikhuijzer/transformrs/pulls).

To develop locally, you can clone the repository and run

```sh
$ cargo test
```

or if you have [`cargo-watch`](https://github.com/watchexec/cargo-watch) installed, you can run

```sh
$ cargo watch -x test
```

to automatically run the tests when you make changes.
This does require the right API keys to be set up.
Depending on what API keys you have, you can either run only the tests that you care about, or make the changes and send the patch in with a request to run the tests in CI.
The CI has access to many API keys, so feel free to ask for the test to be run there.
22 changes: 22 additions & 0 deletions content/theme.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "themes.html" %}

{% block title %}{{ page.title }} | Zola {% endblock title %}
{% block theme_content %}
<div class="theme-info">
<img src="{{page.permalink}}screenshot.png" class="thumb">
<div class="metadata">
<h1>{{ page.title }}</h1>
<p>{{ page.description }}</p>
<p><b>Author:</b> {{page.extra.author.name}}</p>
<p><b>License:</b> {{page.extra.license}}</p>
<p><b>Homepage:</b> <a href="{{page.extra.homepage}}">{{page.extra.homepage}}</a></p>
{% if page.extra.demo %}
<p><b>Live Demo:</b> <a href="{{page.extra.demo}}">{{page.extra.demo}}</a></p>
{% endif %}
<p><b>Last updated:</b> {{page.extra.updated }}</p>
</div>
</div>

<hr>
{{page.content | safe}}
{% endblock theme_content %}
Binary file added static/font/roboto-latin.woff2
Binary file not shown.
Binary file added static/font/source-code-pro-latin.woff2
Binary file not shown.
10 changes: 10 additions & 0 deletions static/highlight/github-dark.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions static/highlight/github.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading