Skip to content

Commit

Permalink
remove streaming from bot callback (too slow)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomarin committed Aug 4, 2023
1 parent e0f003e commit f3cd01e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 31 deletions.
10 changes: 9 additions & 1 deletion 06-SQLDB_QA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "66ab3cc5-aee4-415a-9391-1e5d37ccaf1d",
"metadata": {},
"source": [
"# Q&A against a SQL Database"
"# Q&A against a SQL Database (Azure SQL, Synape, SQL Managed Instance, etc)"
]
},
{
Expand Down Expand Up @@ -237,6 +237,14 @@
"# Query with LLM"
]
},
{
"cell_type": "markdown",
"id": "ea2ef524-565a-4f28-9955-fce0d01bbe21",
"metadata": {},
"source": [
"**Note**: We are here using Azure SQL, however the same code will work with Synapse, SQL Managed instance, or any other SQL engine. You just need to provide the right ENV variables and it will connect succesfully."
]
},
{
"cell_type": "code",
"execution_count": 6,
Expand Down
26 changes: 3 additions & 23 deletions 08-Smart_Agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 3,
"id": "643d1650-6416-46fd-8b21-f5fb298ec063",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -172,30 +172,10 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "dc11cb35-8817-4dd0-b123-27f9eb032f43",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Tool: @docsearch\n"
]
},
{
"data": {
"text/markdown": [
"I'm sorry, but the documents provided do not contain information about today's weather in Dallas."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"# Test the Documents Search Tool with a question we know it doesn't have the knowledge for\n",
"printmd(doc_search.run(\"what is the weather today in Dallas?\"))"
Expand Down
Binary file modified apps/backend/backend.zip
Binary file not shown.
7 changes: 2 additions & 5 deletions apps/backend/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class BotServiceCallbackHandler(BaseCallbackHandler):

def __init__(self, turn_context: TurnContext) -> None:
self.tc = turn_context

def on_llm_new_token(self, token: str, **kwargs: Any) -> Any:
asyncio.run(self.tc.send_activity(Activity(type=ActivityTypes.typing)))


def on_llm_error(self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any) -> Any:
asyncio.run(self.tc.send_activity(f"LLM Error: {error}\n"))

Expand Down Expand Up @@ -64,7 +61,7 @@ async def on_message_activity(self, turn_context: TurnContext):
cb_handler = BotServiceCallbackHandler(turn_context)
cb_manager = CallbackManager(handlers=[cb_handler])

llm = AzureChatOpenAI(deployment_name=self.MODEL_DEPLOYMENT_NAME, temperature=0.5, max_tokens=1000, callback_manager=cb_manager, streaming=True)
llm = AzureChatOpenAI(deployment_name=self.MODEL_DEPLOYMENT_NAME, temperature=0.5, max_tokens=1000, callback_manager=cb_manager)

# Initialize our Tools/Experts
indexes = ["cogsrch-index-files", "cogsrch-index-csv"]
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
st.markdown("""
This engine finds information from the following:
- ~10k [Computer Science Publications in Arxiv from 2020-2021](https://www.kaggle.com/datasets/1b6883fb66c5e7f67c697c2547022cc04c9ee98c3742f9a4d6c671b4f4eda591)
- ~90 [COVID-19 research articles from the CORD19 dataset](https://github.com/allenai/cord19)
- ~90k [COVID-19 research articles from the CORD19 dataset](https://github.com/allenai/cord19)
- [Covid Tracking Project Dataset](https://covidtracking.com/). Azure SQL with information of Covid cases and hospitalizations in the US from 2020-2021.
- The Bot Interface is just a window to a Bot Service app hosted in Azure.
Expand Down
Binary file modified apps/frontend/frontend.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/frontend/pages/1_Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def clear_submit():

coli1, coli2= st.columns([3,1])
with coli1:
query = st.text_input("Ask a question to your enterprise data lake", value= "What is CLP?", on_change=clear_submit)
query = st.text_input("Ask a question to your enterprise data lake", value= "What are the main risk factors for Covid-19?", on_change=clear_submit)
with coli2:
language= st.selectbox('Answer language',('English', 'Spanish', 'French', 'German', 'Portuguese', 'Italian'), index=0)

Expand Down

0 comments on commit f3cd01e

Please sign in to comment.