Spaces:
Sleeping
Sleeping
Kacper Εukawski commited on
Commit Β·
e1233ed
1
Parent(s): 71e064c
Allow overriding the model with env var
Browse files- app/agent.py +4 -2
- app/api.py +6 -1
- app/static/index.html +5 -1
app/agent.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import asyncio
|
| 2 |
import logging
|
|
|
|
| 3 |
from collections.abc import AsyncIterable
|
| 4 |
|
| 5 |
from haystack.dataclasses import ChatMessage
|
|
@@ -14,6 +15,8 @@ from app.queue import StreamingQueue
|
|
| 14 |
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
|
|
|
|
|
|
| 17 |
_QUERY_ONLY_SCHEMA = {
|
| 18 |
"type": "object",
|
| 19 |
"properties": {
|
|
@@ -28,8 +31,7 @@ _QUERY_ONLY_SCHEMA = {
|
|
| 28 |
|
| 29 |
def make_generator() -> NvidiaChatGenerator:
|
| 30 |
return NvidiaChatGenerator(
|
| 31 |
-
|
| 32 |
-
model="nvidia/nemotron-3-super-120b-a12b",
|
| 33 |
generation_kwargs={
|
| 34 |
"stream": True,
|
| 35 |
"max_tokens": 96_000,
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import logging
|
| 3 |
+
import os
|
| 4 |
from collections.abc import AsyncIterable
|
| 5 |
|
| 6 |
from haystack.dataclasses import ChatMessage
|
|
|
|
| 15 |
|
| 16 |
logger = logging.getLogger(__name__)
|
| 17 |
|
| 18 |
+
MODEL = os.environ.get("MODEL", "nvidia/nemotron-3-super-120b-a12b")
|
| 19 |
+
|
| 20 |
_QUERY_ONLY_SCHEMA = {
|
| 21 |
"type": "object",
|
| 22 |
"properties": {
|
|
|
|
| 31 |
|
| 32 |
def make_generator() -> NvidiaChatGenerator:
|
| 33 |
return NvidiaChatGenerator(
|
| 34 |
+
model=MODEL,
|
|
|
|
| 35 |
generation_kwargs={
|
| 36 |
"stream": True,
|
| 37 |
"max_tokens": 96_000,
|
app/api.py
CHANGED
|
@@ -6,7 +6,7 @@ from fastapi import FastAPI
|
|
| 6 |
from fastapi.responses import FileResponse
|
| 7 |
from fastapi.staticfiles import StaticFiles
|
| 8 |
|
| 9 |
-
from app.agent import run_agent
|
| 10 |
from app.models import AgentRequest, TextChunk
|
| 11 |
|
| 12 |
logging.basicConfig(
|
|
@@ -22,6 +22,11 @@ _STATIC = Path(__file__).parent / "static"
|
|
| 22 |
app.mount("/static", StaticFiles(directory=_STATIC), name="static")
|
| 23 |
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
@app.get("/")
|
| 26 |
async def index() -> FileResponse:
|
| 27 |
return FileResponse(_STATIC / "index.html")
|
|
|
|
| 6 |
from fastapi.responses import FileResponse
|
| 7 |
from fastapi.staticfiles import StaticFiles
|
| 8 |
|
| 9 |
+
from app.agent import MODEL, run_agent
|
| 10 |
from app.models import AgentRequest, TextChunk
|
| 11 |
|
| 12 |
logging.basicConfig(
|
|
|
|
| 22 |
app.mount("/static", StaticFiles(directory=_STATIC), name="static")
|
| 23 |
|
| 24 |
|
| 25 |
+
@app.get("/config")
|
| 26 |
+
async def config():
|
| 27 |
+
return {"model": MODEL}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
@app.get("/")
|
| 31 |
async def index() -> FileResponse:
|
| 32 |
return FileResponse(_STATIC / "index.html")
|
app/static/index.html
CHANGED
|
@@ -41,7 +41,7 @@
|
|
| 41 |
the agent searches our Google Drive with conference materials and gets you up to speed in seconds.
|
| 42 |
</p>
|
| 43 |
<p class="hero-powered">
|
| 44 |
-
Powered by <code class="hero-model">
|
| 45 |
</p>
|
| 46 |
</div>
|
| 47 |
|
|
@@ -137,6 +137,10 @@
|
|
| 137 |
</div>
|
| 138 |
|
| 139 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
marked.use({ breaks: true });
|
| 141 |
|
| 142 |
// ββ DOM βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 41 |
the agent searches our Google Drive with conference materials and gets you up to speed in seconds.
|
| 42 |
</p>
|
| 43 |
<p class="hero-powered">
|
| 44 |
+
Powered by <code class="hero-model">β¦</code>
|
| 45 |
</p>
|
| 46 |
</div>
|
| 47 |
|
|
|
|
| 137 |
</div>
|
| 138 |
|
| 139 |
<script>
|
| 140 |
+
fetch('/config').then(r => r.json()).then(cfg => {
|
| 141 |
+
document.querySelector('.hero-model').textContent = cfg.model;
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
marked.use({ breaks: true });
|
| 145 |
|
| 146 |
// ββ DOM βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|