Sujithanumala commited on
Commit
fb4cef0
·
verified ·
1 Parent(s): d2a8e30

Added predictions using local LLM

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from typing import List
3
  import json
4
  from Classes.Owiki_Class import OWiki
 
5
 
6
  def predict(query :str , chat_history : List[tuple[str,str]] , invocation_type : str = "OIC" , schemas : dict= {}) -> str:
7
  with open("config.json",'r') as f:
@@ -11,7 +12,8 @@ def predict(query :str , chat_history : List[tuple[str,str]] , invocation_type :
11
  try:
12
  res = a.create_sql_agent(query,schemas)
13
  except Exception as e:
14
- return "Due to limited compute, I am unable to answer at this moment. Please upgrade your deployment space."
 
15
  elif invocation_type == "OIC":
16
  try:
17
  chat = ""
@@ -19,7 +21,8 @@ def predict(query :str , chat_history : List[tuple[str,str]] , invocation_type :
19
  chat+= f"User: {user} Bot: {bot}\n\n"
20
  res = a.search_from_db(query, chat)
21
  except Exception as e:
22
- return "Due to limited compute, I am unable to answer at this moment. Please upgrade your deployment space."
 
23
  return res
24
 
25
 
 
2
  from typing import List
3
  import json
4
  from Classes.Owiki_Class import OWiki
5
+ from Classes.run_local_LLM import LocalLLM
6
 
7
  def predict(query :str , chat_history : List[tuple[str,str]] , invocation_type : str = "OIC" , schemas : dict= {}) -> str:
8
  with open("config.json",'r') as f:
 
12
  try:
13
  res = a.create_sql_agent(query,schemas)
14
  except Exception as e:
15
+ res = local_llm.predict(query, invocation_type, schemas)
16
+ return res or "Due to limited compute, I am unable to answer at this moment. Please upgrade your deployment space."
17
  elif invocation_type == "OIC":
18
  try:
19
  chat = ""
 
21
  chat+= f"User: {user} Bot: {bot}\n\n"
22
  res = a.search_from_db(query, chat)
23
  except Exception as e:
24
+ res = local_llm.predict(query, invocation_type, schemas)
25
+ return res or "Due to limited compute, I am unable to answer at this moment. Please upgrade your deployment space."
26
  return res
27
 
28