File size: 1,751 Bytes
fbba22c b404c8b fbba22c 91f248b 155f309 fbba22c 91f248b fbba22c 5d0ea92 fbba22c 6b85c1c fbba22c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import whisper
#from langchain.llms import OpenAI
from langchain.agents import initialize_agent
from langchain.agents.agent_toolkits import ZapierToolkit
from langchain.utilities.zapier import ZapierNLAWrapper
import os
from langchain.llms import HuggingFaceEndpoint
from langchain.llms import huggingface_hub
from langchain_community.agent_toolkits import ZapierToolkit
from langchain_community.llms import HuggingFaceEndpoint
from langchain_community.llms import huggingface_hub
# get from https://platform.openai.com/
os.environ["OPENAI_API_KEY"] = "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"
# get from https://nla.zapier.com/docs/authentication/ & https://actions.zapier.com/credentials/ after logging in):
os.environ["ZAPIER_NLA_API_KEY"] = "sk-ak-7ZkOoOYS9zB0cwl5rARDBWzBYF"
def email_summary(file):
# large language model
llm = HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.2")
# Initializing zapier
zapier = ZapierNLAWrapper()
toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier)
# The agent used here is a "zero-shot-react-description" agent.
# Zero-shot means the agent functions on the current action only — it has no memory.
# It uses the ReAct framework to decide which tool to use, based solely on the tool's description.
agent = initialize_agent(toolkit.get_tools(), llm, agent="zero-shot-react-description", verbose=True)
# specify a model, here its BASE
model = whisper.load_model("base")
# transcribe audio file
result = model.transcribe(file)
print(result["text"])
# Send email using zapier
agent.run("Send an Email to [email protected] via gmail summarizing the following text provided below : "+result["text"])
|