# Warning control import warnings warnings.filterwarnings('ignore') from typing import List import json from pydantic import BaseModel # from langchain_community.llms import HuggingFaceHub from langchain_huggingface import HuggingFaceEndpoint from crewai import Agent, Task, Crew import os from dotenv import load_dotenv, find_dotenv _ = load_dotenv(find_dotenv()) # read local .env file # hf_api_key = os.environ['HF_API_KEY'] hf_api_key = os.getenv('HF_API_KEY') llm = HuggingFaceEndpoint( repo_id="HuggingFaceH4/zephyr-7b-beta", huggingfacehub_api_token=hf_api_key, task="text-generation" ) editor = Agent( role="Editor", goal="Extract the summary of user requirements based on the chat between user and Graphic designer. Chat: {chat}", backstory="You're working as an Editor" "You are provided with chat between user and graphic designer. Chat: {chat}." "Extract the summary of user requirements from the chat", llm=llm, allow_delegation=False, verbose=False ) summary = Task( description=( "Provide the summary of user requirements based on the chat between user and Graphic designer. Chat: {chat}" ), expected_output="Summary of user requirements. output only summary", agent=editor, ) crew = Crew( agents=[editor], tasks=[summary], verbose=False ) def Summarizer(chat, userDefinedQuestions=None): result = crew.kickoff(inputs={"chat": chat}) return result