Spaces:
Runtime error
Runtime error
Commit
·
2fbfd97
1
Parent(s):
6ac8f07
Update router
Browse files- backend/__init__.py +19 -31
- backend/router.py +9 -9
backend/__init__.py
CHANGED
@@ -23,37 +23,25 @@ try:
|
|
23 |
test_conn = DBConnection.get_client().get_server_info()
|
24 |
|
25 |
# send prompt wizardcoderLM-70b-instruct-GGUF model
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
# user_id = config.USER_ID,
|
46 |
-
# app_id = config.APP_ID,
|
47 |
-
# model_id = config.MODEL_ID,
|
48 |
-
# model_version_id=config.MODEL_VERSION_ID,
|
49 |
-
# )
|
50 |
-
|
51 |
-
# llmchain = LLMChain(
|
52 |
-
# prompt=prompt,
|
53 |
-
# llm=llm
|
54 |
-
# )
|
55 |
-
|
56 |
-
# app.state.llmchain = llmchain
|
57 |
|
58 |
except mysql.connector.Error as err:
|
59 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
|
|
23 |
test_conn = DBConnection.get_client().get_server_info()
|
24 |
|
25 |
# send prompt wizardcoderLM-70b-instruct-GGUF model
|
26 |
+
with open("backend/utils/prompt.txt",'r') as f:
|
27 |
+
prompt = f.read()
|
28 |
+
|
29 |
+
prompt = PromptTemplate(template=prompt, input_variables=['instruction'])
|
30 |
+
|
31 |
+
llm = Clarifai(
|
32 |
+
pat = config.CLARIFAI_PAT,
|
33 |
+
user_id = config.USER_ID,
|
34 |
+
app_id = config.APP_ID,
|
35 |
+
model_id = config.MODEL_ID,
|
36 |
+
model_version_id=config.MODEL_VERSION_ID,
|
37 |
+
)
|
38 |
+
|
39 |
+
llmchain = LLMChain(
|
40 |
+
prompt=prompt,
|
41 |
+
llm=llm
|
42 |
+
)
|
43 |
+
|
44 |
+
app.state.llmchain = llmchain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
except mysql.connector.Error as err:
|
47 |
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
backend/router.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
from fastapi import Request, Depends, UploadFile
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
|
4 |
-
from
|
5 |
-
from
|
6 |
-
from
|
7 |
-
from
|
8 |
|
9 |
|
10 |
app.add_middleware(
|
@@ -56,10 +56,10 @@ async def regenerate_api_key(access_token: str = Depends(JWTBearer())):
|
|
56 |
|
57 |
return ops_regenerate_api_key(user_sub)
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
|
65 |
-
|
|
|
1 |
from fastapi import Request, Depends, UploadFile
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
3 |
|
4 |
+
from docguptea import app
|
5 |
+
from docguptea.utils import DBConnection
|
6 |
+
from docguptea.models import *
|
7 |
+
from docguptea.services.auth import *
|
8 |
|
9 |
|
10 |
app.add_middleware(
|
|
|
56 |
|
57 |
return ops_regenerate_api_key(user_sub)
|
58 |
|
59 |
+
@app.post("/api/inference", summary="Inference", response_model=Inference, tags=["Resource Server"], dependencies=[Depends(JWTBearer())])
|
60 |
+
async def inference(code_block:str, api_key: str,access_token:str=Depends(JWTBearer())):
|
61 |
+
user_sub=Auth.get_user_credentials(access_token)
|
62 |
|
63 |
+
print("after res")
|
64 |
|
65 |
+
return ops_inference(code_block,api_key,user_sub)
|