mlc / app.py
TRaw's picture
Update app.py
6d5f337
raw
history blame
924 Bytes
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain.llms import Together
from langchain.tools import ElevenLabsText2SpeechTool
from elevenlabs import set_api_key
set_api_key("866c88e3fe83f2b0de18226738445c8f")
# Initialize ElevenLabsText2SpeechTool
tts = ElevenLabsText2SpeechTool()
# Initialize LLM and agent
llm = Together(
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
temperature=0.7,
max_tokens=128,
top_k=1,
together_api_key="f722a9f6e3afd6b9999e6aee02aeac9e751ea3a67b124c3667ab50c85c7fa99e"
)
tools = load_tools(["eleven_labs_text2speech"])
agent = initialize_agent(
tools=tools,
llm=llm,
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
# Request a joke and get the path to the audio file
response = agent.run("Please provide me with an audio file containing a joke about a tiger")
print(response)
tts.play(response)