mayureshagashe2105 commited on
Commit
2fbfd97
·
1 Parent(s): 6ac8f07

Update router

Browse files
Files changed (2) hide show
  1. backend/__init__.py +19 -31
  2. 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
- # with open("backend/utils/prompt.txt",'r') as f:
27
- # prompt = f.read()
28
- # prompt = """You are an AI Coding Assitant and your task is to generate an elaborate, high quality docstring for the query function given by the user. A docstring consists of the following sections:
29
- # 1. Description: Is the description of what the function does.
30
- # 2. Arguments:
31
- # 1. Argument Name: Description of the argument and its type.
32
- # 3. Returns: Description of the return value of the function if any.
33
- # 4. Raises: Description of the errors that can be raised by the function if any.
34
-
35
- # Instruction: {instruction}
36
-
37
- # Your task is to generate a docstring for the above query.
38
- # Response:
39
- # """
40
-
41
- # prompt = PromptTemplate(template=prompt, input_variables=['instruction'])
42
-
43
- # llm = Clarifai(
44
- # pat = config.CLARIFAI_PAT,
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 backend import app
5
- from backend.utils import DBConnection
6
- from backend.models import *
7
- from backend.services.auth import *
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
- # @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)
 
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)