Skip to content

Sephack #157

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
12 changes: 12 additions & 0 deletions scenarios/incubations/copilot/data/dataprep/command_run.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SET AZURE_STORAGE_ACCOUNT=""
SET AZURE_STORAGE_CONTAINER="content"
SET AZURE_SEARCH_SERVICE="cogsearch001"
SET AZURE_OPENAI_SERVICE="openai002"
SET AZURE_OPENAI_EMB_DEPLOYMENT="text-embedding-ada-002"
SET AZURE_FORMRECOGNIZER_RESOURCE_GROUP="rg-azure-search-demo-dev"
SET AZURE_FORMRECOGNIZER_SERVICE="cog-fr-tyf3apvjit5gg"
SET AZURE_TENANT_ID="0fbe7234-45ea-498b-b7e4-1a8b2d3be4d9"
SET AZURE_SEARCH_ADMIN_KEY=""
SET AZURE_SEARCH_INDEX_NAME=""

python prepdocs.py "../EVA_documents/*/*.pdf" --storageaccount "%AZURE_STORAGE_ACCOUNT%" --container "%AZURE_STORAGE_CONTAINER%" --searchservice "%AZURE_SEARCH_SERVICE%" --openaiservice "%AZURE_OPENAI_SERVICE%" --openaideployment "%AZURE_OPENAI_EMB_DEPLOYMENT%" --searchkey "%AZURE_SEARCH_ADMIN_KEY%" --index "%AZURE_SEARCH_INDEX_NAME%" --formrecognizerservice "%AZURE_FORMRECOGNIZER_SERVICE%" --tenantid "%AZURE_TENANT_ID%" -v
378 changes: 378 additions & 0 deletions scenarios/incubations/copilot/data/dataprep/prepdocs.py

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions scenarios/incubations/copilot/data/dataprep/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pypdf==3.9.0
azure-identity==1.13.0
azure-search-documents==11.4.0b8
azure-ai-formrecognizer==3.2.1
azure-storage-blob==12.14.1
openai[datalib]==0.27.8
tenacity==8.2.2
4 changes: 3 additions & 1 deletion scenarios/incubations/copilot/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ streamlit-extras
python-dotenv
plotly
scipy
scikit-learn
scikit-learn
azure-search-documents==11.4.0b10
faiss-cpu
85 changes: 85 additions & 0 deletions scenarios/incubations/copilot/smart_agent/copilot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import streamlit as st
from streamlit_extras.add_vertical_space import add_vertical_space
from utils import PERSONA, AVAILABLE_FUNCTIONS, FUNCTIONS_SPEC, Smart_Agent, add_to_cache
import sys
import time
import random
import os
from pathlib import Path
import json
with open('./user_profile.json') as f:
user_profile = json.load(f)
functions = FUNCTIONS_SPEC.copy()
# functions[0]["parameters"]["properties"]["products"]["description"] = functions[0]["parameters"]["properties"]["products"]["description"].format(products=user_profile['products'])

agent = Smart_Agent(persona=PERSONA.format(username=user_profile['username']),functions_list=AVAILABLE_FUNCTIONS, functions_spec=functions, init_message=f"Hi {user_profile['username']}, this is Maya, technical specialist helping with questions about networking and system, what can I do for you?")

st.set_page_config(layout="wide",page_title="Enterprise Copilot- A demo of Copilot application using GPT")
styl = f"""
<style>
.stTextInput {{
position: fixed;
bottom: 3rem;
}}
</style>
"""
st.markdown(styl, unsafe_allow_html=True)


MAX_HIST= 5
# Sidebar contents
with st.sidebar:
st.title('Tech Copilot')
st.markdown('''
This is a demo of Copilot Concept for Enterprise Networking Technical Support.

''')
add_vertical_space(5)
st.write('Created by James N')
if st.button('Clear Chat'):

if 'history' in st.session_state:
st.session_state['history'] = []

if 'history' not in st.session_state:
st.session_state['history'] = []
if 'input' not in st.session_state:
st.session_state['input'] = ""


user_input= st.chat_input("You:")

## Conditional display of AI generated responses as a function of user provided prompts
history = st.session_state['history']

if len(history) > 0:
for message in history:
if message.get("role") != "system" and message.get("name") is None:
with st.chat_message(message["role"]):
st.markdown(message["content"])
else:
history, agent_response = agent.run(user_input=None)
with st.chat_message("assistant"):
st.markdown(agent_response)
user_history=[]
if user_input:
with st.chat_message("user"):
st.markdown(user_input)
stream_out, query_used, history, agent_response = agent.run(user_input=user_input, conversation=history, stream=False)
with st.chat_message("assistant"):
if stream_out:
message_placeholder = st.empty()
full_response = ""
for response in agent_response:
if len(response.choices)>0:
full_response += response.choices[0].delta.get("content", "")
message_placeholder.markdown(full_response + "▌")
message_placeholder.markdown(full_response)
if query_used: #add to cache
add_to_cache(query_used, full_response)
print(f"query {query_used} added to cache")
history.append({"role": "assistant", "content": full_response})
else:
st.markdown(agent_response)

st.session_state['history'] = history
9 changes: 9 additions & 0 deletions scenarios/incubations/copilot/smart_agent/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
streamlit
openai
streamlit-extras
python-dotenv
plotly
scipy
scikit-learn
azure-search-documents==11.4.0b9
faiss-cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"products":"ExtremeCloud, AP3000, AP302W, AP305C, AP305CX, 7720", "username":"John Doe"}
Loading