-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ➕ add docs dependencies * 🍱 add doc assets * 💄 add custom css * 🔧 add mkdocs.yml * 🍱 update assets * 📝 update README * 🔧 update mkdocs.yml * 📝 add home page * 🍱 add doc assets * 📝 remove documentation badge * 👷 add workflow to publish docs * 💄 update primary color * 🚧 test deployment * 🔧 add CNAME * 👷 update GA workflow * 📝 update README * ➕ add docs dependency * 🔧 update mkdocs.yml * 💄 update css * 📝 update home page * 📝 add getting started page * 🐛 fix callback handler bug * 📝 update code
- Loading branch information
Showing
17 changed files
with
725 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Docs | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
env: | ||
PYTHON_VERSION: 3.9 | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure Git Credentials | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Update Environment Variables | ||
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | ||
|
||
- name: Setup Cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: mkdocs-material-${{ env.cache_id }} | ||
path: .cache | ||
restore-keys: | | ||
mkdocs-material- | ||
- name: Deploy GitHub Pages | ||
run: | | ||
pip install mkdocs-material mdx-include termynal | ||
mkdocs gh-deploy --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lanarky.ajndkr.com |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
--- | ||
hide: | ||
- navigation | ||
--- | ||
|
||
This is a quick tutorial on getting started with Lanarky. | ||
|
||
We will use LangChain as the LLM tooling framework and OpenAI as the LLM provider to | ||
build our first LLM microservice. | ||
|
||
## Install Dependencies | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ pip install lanarky[langchain,openai] | ||
``` | ||
|
||
## Example | ||
|
||
We will use the `ConversationChain` from LangChain library to build our first LLM microservice. | ||
|
||
!!! info | ||
|
||
You need to set the `OPENAI_API_KEY` environment variable to use OpenAI. | ||
Visit [openai.com](https://openai.com) to get your API key. | ||
|
||
```python | ||
import os | ||
from fastapi import FastAPI | ||
from langchain.chains import ConversationChain | ||
from langchain.chat_models import ChatOpenAI | ||
from lanarky.adapters.langchain.routing import LangchainAPIRouter | ||
|
||
os.environ["OPENAI_API_KEY"] = "add-your-openai-api-key-here" | ||
|
||
app = FastAPI() | ||
langchain_router = LangchainAPIRouter() | ||
|
||
@langchain_router.post("/chat") | ||
def chat(streaming: bool = True) -> ConversationChain: | ||
return ConversationChain(llm=ChatOpenAI(streaming=streaming)) | ||
|
||
app.include_router(langchain_router) | ||
``` | ||
|
||
Run the application: | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ pip install uvicorn | ||
$ uvicorn app:app --reload | ||
``` | ||
|
||
View the Swagger docs at [http://localhost:8000/docs](http://localhost:8000/docs). | ||
|
||
## Testing | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ pip install httpx-sse | ||
``` | ||
|
||
Create `client.py` script: | ||
|
||
```python | ||
import click | ||
import httpx | ||
from httpx_sse import connect_sse | ||
|
||
|
||
@click.command() | ||
@click.option("--input", required=True) | ||
@click.option("--streaming", is_flag=True) | ||
def main(input: str, streaming: bool): | ||
url = f"http://localhost:8000/chat?streaming={str(streaming).lower()}" | ||
with httpx.Client() as client: | ||
with connect_sse( | ||
client, | ||
"POST", | ||
url, | ||
json={"input": input}, | ||
) as event_source: | ||
for sse in event_source.iter_sse(): | ||
print(sse.event, sse.data) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
``` | ||
|
||
Stream output: | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ python client.py --input hi --streaming | ||
``` | ||
|
||
Recieve all output at once: | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ python client.py --input hi | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
hide: | ||
- navigation | ||
- toc | ||
--- | ||
|
||
<style> | ||
.md-content .md-typeset h1 { display: none; } | ||
</style> | ||
|
||
<div align="center"> | ||
|
||
<img src="assets/logo-light-mode.png#only-light" alt="lanarky-logo-light-mode" width="500"> | ||
<img src="assets/logo-dark-mode.png#only-dark" alt="lanarky-logo-dark-mode" width="500"> | ||
|
||
<h4>The web framework for building LLM microservices.</h4> | ||
|
||
<a href="https://github.com/ajndkr/lanarky/blob/main/LICENSE"> | ||
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License"> | ||
</a> | ||
<a href="https://coveralls.io/github/ajndkr/lanarky?branch=main"> | ||
<img src="https://coveralls.io/repos/github/ajndkr/lanarky/badge.svg?branch=main" alt="Coverage"> | ||
</a> | ||
<a href="https://pypistats.org/packages/lanarky"> | ||
<img src="https://img.shields.io/pypi/dm/lanarky.svg" alt="Stats"> | ||
</a> | ||
|
||
</div> | ||
|
||
Lanarky is a **python (3.9+)** web framework for developers who want to build microservices using LLMs. | ||
Here are some of its key features: | ||
|
||
- **LLM-first**: Unlike other web frameworks, lanarky is built specifically for LLM developers. | ||
It's unopinionated in terms of how you build your microservices and guarantees zero vendor lock-in | ||
with any LLM tooling frameworks or cloud providers | ||
- **Fast & Modern**: Built on top of FastAPI, lanarky offers all the FastAPI features you know and love. | ||
If you are new to FastAPI, visit [fastapi.tiangolo.com](https://fastapi.tiangolo.com) to learn more | ||
- **Streaming**: Streaming a special requirement when building microservices for chatbot-like applications. | ||
Lanarky has got you covered with built-in streaming support over **HTTP** and **WebSockets**. | ||
- **Open-source**: Lanarky is open-source and free to use. Forever. | ||
|
||
<!-- termynal --> | ||
|
||
``` | ||
$ pip install lanarky | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[data-md-color-scheme="lanarky"] { | ||
--md-primary-fg-color: #4ce1b5; | ||
--md-primary-fg-color--light: #28f2b6; | ||
--md-primary-fg-color--dark: #0c9a78; | ||
|
||
--md-accent-fg-color: #f25353; | ||
--md-accent-fg-color--transparent: rgba(242, 83, 83, 0.1); | ||
} | ||
|
||
[data-md-color-scheme="slate"] { | ||
--md-primary-fg-color: #4ce1b5; | ||
--md-primary-fg-color--light: #28f2b6; | ||
--md-primary-fg-color--dark: #0c9a78; | ||
|
||
--md-accent-fg-color: #f25353; | ||
--md-accent-fg-color--transparent: rgba(242, 83, 83, 0.1); | ||
|
||
--md-hue: 210; | ||
} | ||
|
||
.md-header { | ||
color: #303841; | ||
} | ||
|
||
.md-tabs { | ||
color: #303841; | ||
} | ||
|
||
.md-typeset a { | ||
color: #0c9a78; | ||
} | ||
|
||
.md-header__topic:first-child { | ||
font-weight: 400; | ||
} | ||
|
||
.md-nav .md-nav__link { | ||
color: #0c9a78; | ||
} | ||
|
||
[data-md-color-scheme="lanarky"] img[src$="#only-dark"], | ||
[data-md-color-scheme="lanarky"] img[src$="#gh-dark-mode-only"] { | ||
display: none; | ||
} | ||
|
||
[data-md-color-scheme="slate"] img[src$="#only-light"], | ||
[data-md-color-scheme="slate"] img[src$="#gh-light-mode-only"] { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
site_name: Lanarky | ||
site_url: https://lanarky.ajndkr.com/ | ||
site_author: Ajinkya Indulkar | ||
site_description: The web framework for building LLM microservices | ||
repo_name: ajndkr/lanarky | ||
repo_url: https://github.com/ajndkr/lanarky | ||
copyright: Copyright © 2023 Ajinkya Indulkar | ||
|
||
edit_uri: "" | ||
|
||
theme: | ||
name: material | ||
palette: | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: lanarky | ||
toggle: | ||
icon: material/toggle-switch | ||
name: Switch to dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
toggle: | ||
icon: material/toggle-switch-off-outline | ||
name: Switch to light mode | ||
features: | ||
- search.suggest | ||
- search.highlight | ||
- content.tabs.link | ||
- navigation.indexes | ||
- content.tooltips | ||
- navigation.path | ||
- content.code.annotate | ||
- content.code.copy | ||
- content.code.select | ||
- navigation.tabs | ||
icon: | ||
repo: fontawesome/brands/github-alt | ||
logo: assets/icon.svg | ||
favicon: assets/favicon.png | ||
language: en | ||
font: | ||
text: Roboto | ||
code: Roboto Mono | ||
|
||
nav: | ||
- Lanarky: index.md | ||
- Getting Started: getting-started.md | ||
|
||
markdown_extensions: | ||
- attr_list | ||
- md_in_html | ||
- toc: | ||
permalink: true | ||
- markdown.extensions.codehilite: | ||
guess_lang: false | ||
- mdx_include: | ||
base_path: docs | ||
- admonition | ||
- codehilite | ||
- extra | ||
- pymdownx.superfences | ||
- pymdownx.tabbed: | ||
alternate_style: true | ||
|
||
extra: | ||
social: | ||
- icon: fontawesome/brands/github | ||
link: https://github.com/ajndkr | ||
- icon: fontawesome/brands/python | ||
link: https://pypi.org/project/lanarky/ | ||
- icon: fontawesome/brands/twitter | ||
link: https://twitter.com/LanarkyAPI | ||
|
||
extra_css: | ||
- stylesheets/extra.css | ||
|
||
plugins: | ||
- termynal |
Oops, something went wrong.