muryshev commited on
Commit
7be11b2
·
1 Parent(s): 13e17af
Files changed (4) hide show
  1. fastapi_app.py +4 -4
  2. llm/common.py +2 -0
  3. llm/deepinfra_api.py +1 -1
  4. llm/vllm_api.py +1 -0
fastapi_app.py CHANGED
@@ -76,6 +76,8 @@ def log_query_result(query, top, request_id, result):
76
  @app.post('/search')
77
  async def search_route(query: Query) -> dict:
78
 
 
 
79
  try:
80
  question = getattr(query, "query", None)
81
  if not question:
@@ -89,12 +91,10 @@ async def search_route(query: Query) -> dict:
89
  find_transaction_maps_by_question = getattr(query, "find_transaction_maps_by_question", False)
90
  find_transaction_maps_by_operation = getattr(query, "find_transaction_maps_by_operation", False)
91
 
92
- llm_params = getattr(query, "llm_params", None)
93
-
94
- if llm_params is None:
95
- llm_params = LlmParams(url=LLM_API_URL,api_key=LLM_API_KEY, model="mistralai/Mixtral-8x7B-Instruct-v0.1", predict_params=LlmPredictParams(temperature=0.15, top_p=0.95, min_p=0.05, seed=42, repetition_penalty=1.2, presence_penalty=1.1, max_tokens=6000))
96
 
97
  if LLM_USE_DEEPINFRA:
 
98
  llm_api = DeepInfraApi(llm_params)
99
 
100
 
 
76
  @app.post('/search')
77
  async def search_route(query: Query) -> dict:
78
 
79
+ default_llm_params = LlmParams(url=LLM_API_URL,api_key=LLM_API_KEY, model="mistralai/Mixtral-8x7B-Instruct-v0.1", predict_params=LlmPredictParams(temperature=0.15, top_p=0.95, min_p=0.05, seed=42, repetition_penalty=1.2, presence_penalty=1.1, max_tokens=6000))
80
+
81
  try:
82
  question = getattr(query, "query", None)
83
  if not question:
 
91
  find_transaction_maps_by_question = getattr(query, "find_transaction_maps_by_question", False)
92
  find_transaction_maps_by_operation = getattr(query, "find_transaction_maps_by_operation", False)
93
 
94
+ llm_params = getattr(query, "llm_params", default_llm_params)
 
 
 
95
 
96
  if LLM_USE_DEEPINFRA:
97
+ print(llm_params.model)
98
  llm_api = DeepInfraApi(llm_params)
99
 
100
 
llm/common.py CHANGED
@@ -53,6 +53,8 @@ class LlmApi:
53
  """
54
  params: LlmParams = None
55
 
 
 
56
 
57
  def set_params(self, params: LlmParams):
58
  self.params = params
 
53
  """
54
  params: LlmParams = None
55
 
56
+ def __init__(self):
57
+ self.params = None
58
 
59
  def set_params(self, params: LlmParams):
60
  self.params = params
llm/deepinfra_api.py CHANGED
@@ -9,6 +9,7 @@ class DeepInfraApi(LlmApi):
9
  """
10
 
11
  def __init__(self, params: LlmParams):
 
12
  super().set_params(params)
13
 
14
  async def get_models(self) -> List[str]:
@@ -80,7 +81,6 @@ class DeepInfraApi(LlmApi):
80
  Returns:
81
  dict: Словарь с параметрами для выполнения запроса.
82
  """
83
-
84
  request = {
85
  "stream": False,
86
  "model": super().params.model,
 
9
  """
10
 
11
  def __init__(self, params: LlmParams):
12
+ super().__init__()
13
  super().set_params(params)
14
 
15
  async def get_models(self) -> List[str]:
 
81
  Returns:
82
  dict: Словарь с параметрами для выполнения запроса.
83
  """
 
84
  request = {
85
  "stream": False,
86
  "model": super().params.model,
llm/vllm_api.py CHANGED
@@ -11,6 +11,7 @@ class LlmApi(LlmApi):
11
  """
12
 
13
  def __init__(self, params: LlmParams):
 
14
  super().set_params(params)
15
 
16
  async def get_models(self) -> List[str]:
 
11
  """
12
 
13
  def __init__(self, params: LlmParams):
14
+ super().__init__()
15
  super().set_params(params)
16
 
17
  async def get_models(self) -> List[str]: