Spaces:
Sleeping
Sleeping
Deploy ReGraph LLM Gradio demo via ReGraph platform
Browse files- README.md +24 -8
- app.py +46 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,13 +1,29 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
-
pinned:
|
| 10 |
-
license:
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ReGraph LLM
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: "4.44.0"
|
| 8 |
app_file: app.py
|
| 9 |
+
pinned: true
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
short_description: Decentralized AI inference powered by the ReGraph network
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# ReGraph LLM
|
| 15 |
+
|
| 16 |
+
An interactive demo of **ReGraph LLM** — a continuously-trained language model powered by a decentralized network of GPU and NPU nodes worldwide.
|
| 17 |
+
|
| 18 |
+
## Features
|
| 19 |
+
|
| 20 |
+
- 🌐 **Decentralized compute** — inference routed across global hardware providers
|
| 21 |
+
- 🔄 **Continuous training** — model updated as new compute contributions arrive
|
| 22 |
+
- ⚡ **Low latency** — smart routing to nearest available nodes
|
| 23 |
+
- 💰 **10× cheaper** than GPT-4 comparable models
|
| 24 |
+
|
| 25 |
+
## Links
|
| 26 |
+
|
| 27 |
+
- [ReGraph Platform](https://regraph.tech)
|
| 28 |
+
- [Documentation](https://regraph.tech/docs)
|
| 29 |
+
- [GitHub](https://github.com/ildu00/ReGraph)
|
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
REGRAPH_API_KEY = os.getenv("REGRAPH_API_KEY", "")
|
| 6 |
+
REGRAPH_BASE_URL = "https://api.regraph.tech/v1"
|
| 7 |
+
|
| 8 |
+
def chat(message: str, history: list) -> str:
|
| 9 |
+
messages = [
|
| 10 |
+
{"role": "system", "content": "You are a helpful AI assistant powered by ReGraph LLM — a decentralized, continuously-trained language model running on distributed GPU/NPU nodes worldwide."}
|
| 11 |
+
]
|
| 12 |
+
for h in history:
|
| 13 |
+
messages.append({"role": "user", "content": h[0]})
|
| 14 |
+
messages.append({"role": "assistant", "content": h[1]})
|
| 15 |
+
messages.append({"role": "user", "content": message})
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
resp = requests.post(
|
| 19 |
+
f"{REGRAPH_BASE_URL}/chat/completions",
|
| 20 |
+
headers={"Authorization": f"Bearer {REGRAPH_API_KEY}", "Content-Type": "application/json"},
|
| 21 |
+
json={"model": "regraph-llm-latest", "messages": messages, "max_tokens": 1024},
|
| 22 |
+
timeout=60,
|
| 23 |
+
)
|
| 24 |
+
resp.raise_for_status()
|
| 25 |
+
return resp.json()["choices"][0]["message"]["content"]
|
| 26 |
+
except Exception as e:
|
| 27 |
+
return f"[Error] {e}"
|
| 28 |
+
|
| 29 |
+
demo = gr.ChatInterface(
|
| 30 |
+
fn=chat,
|
| 31 |
+
title="⚡ ReGraph LLM",
|
| 32 |
+
description="""Interact with **ReGraph LLM** — a continuously-trained language model powered by decentralized GPU/NPU nodes worldwide.
|
| 33 |
+
|
| 34 |
+
[Platform](https://regraph.tech) · [Docs](https://regraph.tech/docs) · [GitHub](https://github.com/ildu00/ReGraph)""",
|
| 35 |
+
examples=[
|
| 36 |
+
"What is decentralized AI compute?",
|
| 37 |
+
"Explain the ReGraph network in simple terms",
|
| 38 |
+
"Write a Python script to call the ReGraph API",
|
| 39 |
+
"Compare centralized vs decentralized AI inference",
|
| 40 |
+
],
|
| 41 |
+
theme=gr.themes.Soft(primary_hue="violet"),
|
| 42 |
+
chatbot=gr.Chatbot(height=480),
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.44.0
|
| 2 |
+
requests>=2.31.0
|