-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import boto3 | ||
client=boto3.client("iam") | ||
|
||
def createuser(user): | ||
response=client.create_user(UserName=user) | ||
return response |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from langchain_community.agent_toolkits.gmail.toolkit import GmailToolkit | ||
from langchain_openai import ChatOpenAI | ||
from langchain.agents import AgentType,initialize_agent | ||
llm=ChatOpenAI(model="gpt-4o") | ||
toolkit=GmailToolkit() | ||
agent=initialize_agent(tools=toolkit.get_tools(), | ||
llm=llm, | ||
verbose=True, | ||
max_iterations=1000, | ||
max_execution_time=1600, | ||
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION) | ||
def runagent(input): | ||
try: | ||
response=agent.run(input) | ||
return response | ||
except Exception as e: | ||
return response | ||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from streamlit_mic_recorder import speech_to_text | ||
import streamlit as st | ||
from emailagent import runagent | ||
from reademail import readbody | ||
from adduser import createuser | ||
|
||
st.title("voice driven service desk agent") | ||
st.write("ask anything") | ||
text=speech_to_text(language="en",use_container_width=True,just_once=True,key="STT") | ||
if text: | ||
output=runagent(text) | ||
if output: | ||
response=readbody(output) | ||
userdata=createuser(response["username"]) | ||
st.write(userdata) | ||
|
||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from langchain.prompts import PromptTemplate | ||
from langchain_openai import ChatOpenAI | ||
import json | ||
llm=ChatOpenAI(model="gpt-4o") | ||
template=""" | ||
you are intelligent assistant , who can read any group of {text} related one email and identify the body of the email, | ||
then create a json with the following key only, | ||
"username": | ||
output must be only json nothing extra | ||
""" | ||
prompt=PromptTemplate.from_template(template) | ||
chain=prompt|llm | ||
|
||
def readbody(text): | ||
response=chain.invoke({"text":text}) | ||
data=response.content | ||
data=data.replace("json","") | ||
data=data.replace("`","") | ||
data=json.loads(data) | ||
return data | ||
|
||
|
Binary file not shown.