Skip to content

Commit

Permalink
Fix pending UI blocking calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pramitchoudhary committed Feb 17, 2024
2 parents da6c08b + 74a4b70 commit 6edc7c6
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 93 deletions.
2 changes: 1 addition & 1 deletion app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description = "QnA with tabular data using NLQ"
LongDescription = "about.md"
InstanceLifecycle = "MANAGED"
Tags = ["DATA_SCIENCE", "MACHINE_LEARNING", "NLP", "GENERATIVE_AI"]
Version = "0.2.3"
Version = "0.2.4"

[Runtime]
MemoryLimit = "64Gi"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sql-sidekick"
version = "0.2.3"
version = "0.2.4"
license = "Apache-2.0 license"
description = "An AI assistant for SQL generation"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion sidekick/prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
execute_query_pd, extract_table_names,
generate_suggestions, save_query, setup_dir)

__version__ = "0.2.3"
__version__ = "0.2.4"

# Load the config file and initialize required paths
app_base_path = (Path(__file__).parent / "../").resolve()
Expand Down
12 changes: 6 additions & 6 deletions sidekick/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def check_vulnerability(input_query: str):


def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: int=10):
results = []
text_completion = []

column_info = ','.join(column_names)
_system_prompt = f"Act as a data analyst, based on below data schema help answer the question"
Expand All @@ -640,12 +640,13 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
if "h2ogpt-" in recommender_model:
try:
client = H2OGPTE(address=remote_url, api_key=client_key)
text_completion = client.answer_question(
response = client.answer_question(
system_prompt=_system_prompt,
text_context_list=[],
question=_user_prompt,
llm=recommender_model
)
text_completion = response.content.split("\n")[2:]
except Exception as e:
remote_url = os.getenv("H2OGPT_BASE_URL", None)
client_key = os.getenv("H2OGPT_BASE_API_TOKEN", None)
Expand All @@ -660,7 +661,7 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
max_tokens=512,
temperature=0.5,
seed=42)
text_completion = completion.choices[0].message
text_completion = completion.choices[0].message.content.split("\n")[2:]
elif 'gpt-3.5' in recommender_model.lower() or 'gpt-4' in recommender_model.lower():
# Check if the API key is set, else inform user
logger.info(f"Using OpenAI model: {recommender_model}")
Expand All @@ -674,9 +675,8 @@ def generate_suggestions(remote_url, client_key:str, column_names: list, n_qs: i
seed=42,
temperature=0.7
)
text_completion = completion.choices[0].message
text_completion = completion.choices[0].message.content.split("\n")
else:
raise Exception("Model url or key is missing.")
_res = text_completion.content.split("\n")[2:]
results = "\n".join(_res)
results = "\n".join(text_completion)
return results
Loading

0 comments on commit 6edc7c6

Please sign in to comment.