Spaces:
Sleeping
Sleeping
File size: 1,475 Bytes
cd87477 f35cb88 | 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 50 51 52 | # 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 |