-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(wren-ai-service): minor updates #833
Merged
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6bd2cb2
add weekday name
cyyeh f7d0c74
add timezone in api request
cyyeh a5c5ded
update timezone and add engine timeout
cyyeh 1d7035e
fix openai api error backoff
cyyeh 72936f0
make engine timeout bigger
cyyeh f40b217
update timezone
cyyeh da6b167
fix typo
cyyeh 2e3a006
fix import issue
cyyeh fa7885d
update timezone
cyyeh 8dcda78
fix bug
cyyeh 7865044
fix bug
cyyeh 2413ced
fix bug
cyyeh cd6ccdb
one sql generation only
cyyeh c4580c5
Merge branch 'main' into chore/ai-service/fix-pipeline
cyyeh 9022d47
add query to langfuse metadata and fix api doc error
cyyeh 7ddc427
fix test bug
cyyeh ab47437
fix generation_kwargs empty issue
cyyeh c2208ba
add language support for sql2answer
cyyeh 2a494a2
add language to demo app
cyyeh 4261d3e
revert one sql generation
cyyeh 438582f
allow sql correction concurrent
cyyeh 1bc6fc3
fix bug
cyyeh 7709299
refactor
cyyeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import asyncio | ||
import logging | ||
from datetime import datetime | ||
from pprint import pformat | ||
from typing import Any, Dict, List, Optional | ||
|
||
import aiohttp | ||
import orjson | ||
import pytz | ||
from haystack import component | ||
|
||
from src.core.engine import ( | ||
|
@@ -111,13 +113,21 @@ def __init__(self, engine: Engine): | |
) | ||
async def run( | ||
self, | ||
replies: List[str], | ||
replies: List[str] | List[List[str]], | ||
project_id: str | None = None, | ||
) -> dict: | ||
try: | ||
cleaned_generation_result = orjson.loads( | ||
clean_generation_result(replies[0]) | ||
)["results"] | ||
if isinstance(replies[0], dict): | ||
cleaned_generation_result = [ | ||
orjson.loads(clean_generation_result(reply["replies"][0]))[ | ||
"results" | ||
][0] | ||
for reply in replies | ||
] | ||
else: | ||
cleaned_generation_result = orjson.loads( | ||
clean_generation_result(replies[0]) | ||
)["results"] | ||
Comment on lines
+116
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering to know which scenario we encountered to do the change |
||
|
||
if isinstance(cleaned_generation_result, dict): | ||
cleaned_generation_result = [cleaned_generation_result] | ||
|
@@ -361,3 +371,13 @@ def construct_instructions(configurations: AskConfigurations | None): | |
instructions += f"- For calendar year related computation, it should be started from {configurations.fiscal_year.start} to {configurations.fiscal_year.end}" | ||
|
||
return instructions | ||
|
||
|
||
def show_current_time(timezone: AskConfigurations.Timezone): | ||
# Get the current time in the specified timezone | ||
tz = pytz.timezone( | ||
timezone.name | ||
) # Assuming timezone.name contains the timezone string | ||
current_time = datetime.now(tz) | ||
|
||
return f'{current_time.strftime("%Y-%m-%d %A")}' # YYYY-MM-DD weekday_name, ex: 2024-10-23 Wednesday |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could remove printing the exception here, FastAPI handle the exception and also leave the log in console