Lucas ARRIESSE
commited on
Commit
·
2ba1434
1
Parent(s):
eb8cbe5
Misc changes
Browse files- api/docs.py +1 -2
- app.py +8 -8
- dependencies.py +0 -1
api/docs.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import asyncio
|
2 |
from pathlib import Path
|
3 |
import traceback
|
4 |
-
from typing import
|
5 |
from fastapi.routing import APIRouter
|
6 |
import logging
|
7 |
import io
|
@@ -9,7 +9,6 @@ import zipfile
|
|
9 |
import os
|
10 |
from httpx import AsyncClient
|
11 |
from pydantic import BaseModel
|
12 |
-
import requests
|
13 |
import subprocess
|
14 |
import pandas as pd
|
15 |
import re
|
|
|
1 |
import asyncio
|
2 |
from pathlib import Path
|
3 |
import traceback
|
4 |
+
from typing import Literal, Tuple
|
5 |
from fastapi.routing import APIRouter
|
6 |
import logging
|
7 |
import io
|
|
|
9 |
import os
|
10 |
from httpx import AsyncClient
|
11 |
from pydantic import BaseModel
|
|
|
12 |
import subprocess
|
13 |
import pandas as pd
|
14 |
import re
|
app.py
CHANGED
@@ -1,21 +1,16 @@
|
|
1 |
-
import asyncio
|
2 |
import logging
|
3 |
from dotenv import load_dotenv
|
4 |
-
from typing import Literal
|
5 |
from jinja2 import Environment, TemplateNotFound
|
6 |
import warnings
|
7 |
import os
|
8 |
-
from fastapi import Depends, FastAPI,
|
9 |
from fastapi.staticfiles import StaticFiles
|
10 |
import api.solutions
|
11 |
-
from dependencies import
|
12 |
import api.docs
|
13 |
import api.requirements
|
14 |
-
from api.docs import doc_to_txt
|
15 |
from schemas import *
|
16 |
from fastapi.middleware.cors import CORSMiddleware
|
17 |
-
from fastapi.responses import FileResponse, StreamingResponse
|
18 |
-
from litellm.router import Router
|
19 |
|
20 |
load_dotenv()
|
21 |
|
@@ -26,6 +21,8 @@ logging.basicConfig(
|
|
26 |
datefmt='%Y-%m-%d %H:%M:%S'
|
27 |
)
|
28 |
|
|
|
|
|
29 |
# Initialize global dependencies
|
30 |
init_dependencies()
|
31 |
|
@@ -41,11 +38,14 @@ app.include_router(api.requirements.router, prefix="/requirements")
|
|
41 |
app.include_router(api.solutions.router, prefix="/solutions")
|
42 |
|
43 |
# INTERNAL ROUTE TO RETRIEVE PROMPT TEMPLATES FOR PRIVATE COMPUTE
|
|
|
|
|
44 |
@app.get("/prompt/{task}", include_in_schema=True)
|
45 |
async def retrieve_prompt(task: str, prompt_env: Environment = Depends(get_prompt_templates)):
|
46 |
"""Retrieves a prompt for client-side private inference"""
|
47 |
try:
|
48 |
-
logging.debug(
|
|
|
49 |
prompt, filename, _ = prompt_env.loader.get_source(
|
50 |
prompt_env, f"private/{task}.txt")
|
51 |
return prompt
|
|
|
|
|
1 |
import logging
|
2 |
from dotenv import load_dotenv
|
|
|
3 |
from jinja2 import Environment, TemplateNotFound
|
4 |
import warnings
|
5 |
import os
|
6 |
+
from fastapi import Depends, FastAPI, Response
|
7 |
from fastapi.staticfiles import StaticFiles
|
8 |
import api.solutions
|
9 |
+
from dependencies import get_prompt_templates, init_dependencies
|
10 |
import api.docs
|
11 |
import api.requirements
|
|
|
12 |
from schemas import *
|
13 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
14 |
|
15 |
load_dotenv()
|
16 |
|
|
|
21 |
datefmt='%Y-%m-%d %H:%M:%S'
|
22 |
)
|
23 |
|
24 |
+
logging.info("DEBUG logging is disabled. Set `DEBUG_LOG` env var to 1 to enable debug logging.")
|
25 |
+
|
26 |
# Initialize global dependencies
|
27 |
init_dependencies()
|
28 |
|
|
|
38 |
app.include_router(api.solutions.router, prefix="/solutions")
|
39 |
|
40 |
# INTERNAL ROUTE TO RETRIEVE PROMPT TEMPLATES FOR PRIVATE COMPUTE
|
41 |
+
|
42 |
+
|
43 |
@app.get("/prompt/{task}", include_in_schema=True)
|
44 |
async def retrieve_prompt(task: str, prompt_env: Environment = Depends(get_prompt_templates)):
|
45 |
"""Retrieves a prompt for client-side private inference"""
|
46 |
try:
|
47 |
+
logging.debug(
|
48 |
+
f"Retrieving template for on device private task {task}.")
|
49 |
prompt, filename, _ = prompt_env.loader.get_source(
|
50 |
prompt_env, f"private/{task}.txt")
|
51 |
return prompt
|
dependencies.py
CHANGED
@@ -10,7 +10,6 @@ from jinja2 import Environment, StrictUndefined, FileSystemLoader
|
|
10 |
|
11 |
|
12 |
INSIGHT_FINDER_BASE_URL = "https://organizedprogrammers-insight-finder.hf.space/"
|
13 |
-
DOC_FINDER_BASE_URL = "https://organizedprogrammers-docfinder.hf.space/"
|
14 |
|
15 |
|
16 |
def init_dependencies():
|
|
|
10 |
|
11 |
|
12 |
INSIGHT_FINDER_BASE_URL = "https://organizedprogrammers-insight-finder.hf.space/"
|
|
|
13 |
|
14 |
|
15 |
def init_dependencies():
|