Skip to content

Commit

Permalink
chore(wren-ai-service): fix sql-to-answer issue (#827)
Browse files Browse the repository at this point in the history
* update

* fix output

* update logging
  • Loading branch information
cyyeh authored Oct 25, 2024
1 parent 97b401b commit f2a855d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ wren-ai-service/src/eval/wren-engine/etc/archived
wren-ai-service/src/eval/data
wren-ai-service/**/outputs/
wren-ai-service/**/spider/
wren-ai-service/tests/data/hubspot/
!wren-ai-service/**/metrics/spider/
!wren-ai-service/tests/data
!wren-ai-service/src/eval/data/book_2*.json
Expand Down
8 changes: 5 additions & 3 deletions wren-ai-service/src/pipelines/generation/sql_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@
sql_to_answer_system_prompt = """
### TASK
You are a data analyst that great at answering user's questions based on the data, sql and sql summary. Please answer the user's question in concise and clear manner.
You are a data analyst that great at answering user's questions based on the data, sql and sql summary so that even non technical users can easily understand.
Please answer the user's question in concise and clear manner in Markdown format.
### INSTRUCTIONS
1. Read the user's question and understand the user's intention.
2. Read the sql summary and understand the data.
3. Read the sql and understand the data.
4. Generate an answer in string format and a reasoning process in string format to the user's question based on the data, sql and sql summary.
4. Generate a consice and clear answer in string format and a reasoning process in string format to the user's question based on the data, sql and sql summary.
5. If answer is in list format, only list top few examples, and tell users there are more results omitted.
### OUTPUT FORMAT
Return the output in the following JSON format:
{
"reasoning": "<STRING>",
"answer": "<STRING>",
"answer": "<STRING_IN_MARKDOWN_FORMAT>",
}
"""

Expand Down
2 changes: 2 additions & 0 deletions wren-ai-service/src/providers/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ def __getattr__(self, name: str) -> Any:
self._vertexai_creds.refresh(auth_req)

if not self._vertexai_creds.valid:
logger.error("Vertex AI token can't be refreshed")
raise RuntimeError("Unable to refresh auth")

self.client.api_key = self._vertexai_creds.token
logger.info("Vertex AI token is refreshed")
return getattr(self.client, name)

@component.output_types(replies=List[str], meta=List[Dict[str, Any]])
Expand Down

0 comments on commit f2a855d

Please sign in to comment.