Skip to content

Commit

Permalink
tutorial110
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Aug 27, 2024
1 parent b2347ac commit e28fbb5
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 0 deletions.
Binary file added tutorial110/__pycache__/adduser.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file added tutorial110/__pycache__/reademail.cpython-312.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions tutorial110/adduser.py
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
18 changes: 18 additions & 0 deletions tutorial110/emailagent.py
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

19 changes: 19 additions & 0 deletions tutorial110/main.py
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)




22 changes: 22 additions & 0 deletions tutorial110/reademail.py
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 added tutorial110/tutorial110.pptx
Binary file not shown.

0 comments on commit e28fbb5

Please sign in to comment.