Skip to content

Commit

Permalink
fixes on apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablo Marin committed Jul 10, 2024
1 parent 0828c78 commit b40b2c2
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 35 deletions.
Binary file modified apps/backend/botservice/backend.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions apps/backend/botservice/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def on_message_activity(self, turn_context: TurnContext):
max_tokens=1500, callback_manager=cb_manager, streaming=True)

# Initialize our Tools/Experts
doc_indexes = ["cogsrch-index-files", "cogsrch-index-csv"]
doc_indexes = ["srch-index-files", "srch-index-csv"]

doc_search = DocSearchAgent(llm=llm, indexes=doc_indexes,
k=6, reranker_th=1,
Expand All @@ -122,7 +122,7 @@ async def on_message_activity(self, turn_context: TurnContext):
description="useful when the questions includes the term: docsearch",
callback_manager=cb_manager, verbose=False)

book_indexes = ["cogsrch-index-books"]
book_indexes = ["srch-index-books"]

book_search = DocSearchAgent(llm=llm, indexes=book_indexes,
k=6, reranker_th=1,
Expand Down
18 changes: 9 additions & 9 deletions apps/backend/langserve/app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

### uncomment this section to run server in local host #########

from pathlib import Path
from dotenv import load_dotenv
# Calculate the path three directories above the current script
library_path = Path(__file__).resolve().parents[4]
sys.path.append(str(library_path))
load_dotenv(str(library_path) + "/credentials.env")
os.environ["AZURE_OPENAI_MODEL_NAME"] = os.environ["GPT4_DEPLOYMENT_NAME"]
# from pathlib import Path
# from dotenv import load_dotenv
# # Calculate the path three directories above the current script
# library_path = Path(__file__).resolve().parents[4]
# sys.path.append(str(library_path))
# load_dotenv(str(library_path) + "/credentials.env")
# os.environ["AZURE_OPENAI_MODEL_NAME"] = os.environ["GPT4_DEPLOYMENT_NAME"]

###################################

Expand Down Expand Up @@ -138,7 +138,7 @@ def get_session_history(session_id: str, user_id: str) -> CosmosDBChatMessageHis
llm = AzureChatOpenAI(deployment_name=os.environ.get("AZURE_OPENAI_MODEL_NAME"), temperature=0, max_tokens=1500, streaming=True)

# Initialize our Tools/Experts
doc_indexes = ["cogsrch-index-files", "cogsrch-index-csv"]
doc_indexes = ["srch-index-files", "srch-index-csv"]

doc_search = DocSearchAgent(llm=llm, indexes=doc_indexes,
k=6, reranker_th=1,
Expand All @@ -147,7 +147,7 @@ def get_session_history(session_id: str, user_id: str) -> CosmosDBChatMessageHis
description="useful when the questions includes the term: docsearch",
verbose=False)

book_indexes = ["cogsrch-index-books"]
book_indexes = ["srch-index-books"]

book_search = DocSearchAgent(llm=llm, indexes=book_indexes,
k=6, reranker_th=1,
Expand Down
Binary file modified apps/backend/langserve/backend.zip
Binary file not shown.
Binary file modified apps/frontend/frontend.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions apps/frontend/pages/1_Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def clear_submit():
os.environ["OPENAI_API_VERSION"] = os.environ["AZURE_OPENAI_API_VERSION"]

MODEL = os.environ.get("AZURE_OPENAI_MODEL_NAME")
llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=1500)
llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=1000)

if button or st.session_state.get("submit"):
if not query:
Expand All @@ -81,7 +81,7 @@ def clear_submit():
# Azure Search

try:
indexes = ["cogsrch-index-files", "cogsrch-index-csv"]
indexes = ["srch-index-files", "srch-index-csv"]
k = 6
ordered_results = get_search_results(query, indexes, k=k, reranker_threshold=1, sas_token=os.environ['BLOB_SAS_TOKEN'])

Expand Down
15 changes: 7 additions & 8 deletions apps/frontend/pages/2_BotService_Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
Example questions:
- Hello, my name is Bob, what's yours?
- @bing, What's the main economic news of today?
- @chatgpt, How do I cook a chocolate cake?
- @booksearch, what normally rich dad do that is different from poor dad?
- @docsearch, Why Covid doesn't affect kids that much compared to adults?
- @apisearch, What is the state with most covid deaths in USA?
- @sqlsearch, How many people where hospitalized in Arkansas in June 2020?
- @docsearch, List the authors that talk about Boosting Algorithms
- @bing, what movies are showing tonight in Seattle?
- bing, What's the main economic news of today?
- chatgpt, How do I cook a chocolate cake?
- booksearch, what normally rich dad do that is different from poor dad?
- docsearch, Why Covid doesn't affect kids that much compared to adults?
- sqlsearch, How many people where hospitalized in Arkansas in June 2020?
- docsearch, List the authors that talk about Boosting Algorithms
- bing, what movies are showing tonight in Seattle?
- Please tell me a joke
""")

Expand Down
22 changes: 10 additions & 12 deletions apps/frontend/pages/3_FastAPI_Chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@
Example questions:
- Hello, my name is Bob, what's yours?
- @bing, What's the main economic news of today?
- @chatgpt, How do I cook a chocolate cake?
- @booksearch, what normally rich dad do that is different from poor dad?
- @docsearch, Why Covid doesn't affect kids that much compared to adults?
- @apisearch, What is the state with most covid deaths in USA?
- @sqlsearch, How many people where hospitalized in Arkansas in June 2020?
- @docsearch, List the authors that talk about Boosting Algorithms
- @bing, what movies are showing tonight in Seattle?
- bing, What's the main economic news of today?
- chatgpt, How do I cook a chocolate cake?
- booksearch, what normally rich dad do that is different from poor dad?
- docsearch, Why Covid doesn't affect kids that much compared to adults?
- sqlsearch, How many people where hospitalized in Arkansas in June 2020?
- docsearch, List the authors that talk about Boosting Algorithms
- bing, what movies are showing tonight in Seattle?
- Please tell me a joke
""")

st.markdown("""
<style>
.block-container {
padding-top: 1rem;
padding-top: 2rem;
padding-bottom: 0rem;
}
</style>
Expand All @@ -63,8 +62,7 @@
# ENTER HERE YOUR LANGSERVE FASTAPI ENDPOINT
# for example: "https://webapp-backend-botid-zf4fwhz3gdn64-staging.azurewebsites.net"

#url = "https://<name-of-backend-app-service>-staging.azurewebsites.net" + "/agent/stream_events"
url = "https://webapp-backend-botid-zf4fwhz3gdn64-slot1.azurewebsites.net" + "/agent/stream_events"
url = "https://<name-of-backend-app-service>-staging.azurewebsites.net" + "/agent/stream_events"

def get_or_create_ids():
"""Generate or retrieve session and user IDs."""
Expand Down Expand Up @@ -132,7 +130,7 @@ def consume_api(url, user_query, session_id, user_id):

# session state
if "chat_history" not in st.session_state:
st.session_state.chat_history = [AIMessage(content="Hello, I am a GPT-3.5 bot hosted in Azure using FastAPI Streaming. How can I help you?")]
st.session_state.chat_history = [AIMessage(content="Hello, I am a GPT-4o bot hosted in Azure using FastAPI Streaming. How can I help you?")]


# conversation
Expand Down
4 changes: 2 additions & 2 deletions common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ def __init__(self, **data):
description="useful to fetch the content of a url"
)

tools = [GetBingSearchResults_Tool(k=self.k)]
# tools = [GetBingSearchResults_Tool(k=self.k), web_fetch_tool] # Uncomment if using GPT-4
# tools = [GetBingSearchResults_Tool(k=self.k)]
tools = [GetBingSearchResults_Tool(k=self.k), web_fetch_tool] # Uncomment if using GPT-4

agent = create_openai_tools_agent(self.llm, tools, BINGSEARCH_PROMPT)

Expand Down

0 comments on commit b40b2c2

Please sign in to comment.