mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-10 07:10:31 +00:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
f13bd5a0a4
@ -38,12 +38,11 @@ class Standalone:
|
|||||||
if args is None:
|
if args is None:
|
||||||
args = type('Args', (), {})()
|
args = type('Args', (), {})()
|
||||||
env_file = os.path.expanduser(env_file)
|
env_file = os.path.expanduser(env_file)
|
||||||
|
self.client = None
|
||||||
load_dotenv(env_file)
|
load_dotenv(env_file)
|
||||||
assert 'OPENAI_API_KEY' in os.environ, "Error: OPENAI_API_KEY not found in environment variables. Please run fabric --setup and add a key."
|
if "OPENAI_API_KEY" in os.environ:
|
||||||
api_key = os.environ['OPENAI_API_KEY']
|
api_key = os.environ['OPENAI_API_KEY']
|
||||||
base_url = os.environ.get(
|
self.client = OpenAI(api_key=api_key)
|
||||||
'OPENAI_BASE_URL', 'https://api.openai.com/v1/')
|
|
||||||
self.client = OpenAI(api_key=api_key, base_url=base_url)
|
|
||||||
self.local = False
|
self.local = False
|
||||||
self.config_pattern_directory = config_directory
|
self.config_pattern_directory = config_directory
|
||||||
self.pattern = pattern
|
self.pattern = pattern
|
||||||
@ -280,33 +279,26 @@ class Standalone:
|
|||||||
def fetch_available_models(self):
|
def fetch_available_models(self):
|
||||||
gptlist = []
|
gptlist = []
|
||||||
fullOllamaList = []
|
fullOllamaList = []
|
||||||
claudeList = ['claude-3-opus-20240229',
|
claudeList = ['claude-3-opus-20240229', 'claude-3-sonnet-20240229',
|
||||||
'claude-3-sonnet-20240229',
|
'claude-3-haiku-20240307', 'claude-2.1']
|
||||||
'claude-3-haiku-20240307',
|
|
||||||
'claude-2.1']
|
|
||||||
try:
|
|
||||||
models = [model.id.strip()
|
|
||||||
for model in self.client.models.list().data]
|
|
||||||
except APIConnectionError as e:
|
|
||||||
if getattr(e.__cause__, 'args', [''])[0] == "Illegal header value b'Bearer '":
|
|
||||||
print("Error: Cannot connect to the OpenAI API Server because the API key is not set. Please run fabric --setup and add a key.")
|
|
||||||
|
|
||||||
else:
|
try:
|
||||||
print(
|
if self.client:
|
||||||
f"Error: {e.message} trying to access {e.request.url}: {getattr(e.__cause__, 'args', [''])}")
|
models = [model.id.strip()
|
||||||
sys.exit()
|
for model in self.client.models.list().data]
|
||||||
|
if "/" in models[0] or "\\" in models[0]:
|
||||||
|
gptlist = [item[item.rfind(
|
||||||
|
"/") + 1:] if "/" in item else item[item.rfind("\\") + 1:] for item in models]
|
||||||
|
else:
|
||||||
|
gptlist = [item.strip()
|
||||||
|
for item in models if item.startswith("gpt")]
|
||||||
|
gptlist.sort()
|
||||||
|
except APIConnectionError as e:
|
||||||
|
print("OpenAI API key not set. Skipping GPT models.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {getattr(e.__context__, 'args', [''])[0]}")
|
print(f"Error: {getattr(e.__context__, 'args', [''])[0]}")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if "/" in models[0] or "\\" in models[0]:
|
|
||||||
# lmstudio returns full paths to models. Iterate and truncate everything before and including the last slash
|
|
||||||
gptlist = [item[item.rfind(
|
|
||||||
"/") + 1:] if "/" in item else item[item.rfind("\\") + 1:] for item in models]
|
|
||||||
else:
|
|
||||||
# Keep items that start with "gpt"
|
|
||||||
gptlist = [item.strip()
|
|
||||||
for item in models if item.startswith("gpt")]
|
|
||||||
gptlist.sort()
|
|
||||||
import ollama
|
import ollama
|
||||||
try:
|
try:
|
||||||
if self.args.remoteOllamaServer:
|
if self.args.remoteOllamaServer:
|
||||||
@ -318,6 +310,7 @@ class Standalone:
|
|||||||
fullOllamaList.append(model['name'])
|
fullOllamaList.append(model['name'])
|
||||||
except:
|
except:
|
||||||
fullOllamaList = []
|
fullOllamaList = []
|
||||||
|
|
||||||
return gptlist, fullOllamaList, claudeList
|
return gptlist, fullOllamaList, claudeList
|
||||||
|
|
||||||
def get_cli_input(self):
|
def get_cli_input(self):
|
||||||
|
60
test.yaml
60
test.yaml
@ -1,44 +1,44 @@
|
|||||||
framework: crewai
|
framework: crewai
|
||||||
topic: 'write me a 20 word essay on apples
|
topic: 'give me the complete voting record of senator marco rubio
|
||||||
|
|
||||||
'
|
'
|
||||||
roles:
|
roles:
|
||||||
researcher:
|
data_researcher:
|
||||||
backstory: Has an extensive background in conducting research using digital tools
|
backstory: Skilled in using various data search tools to find accurate information.
|
||||||
to extract relevant information.
|
goal: Gather relevant data on Senator Marco Rubio's voting record
|
||||||
goal: Gather comprehensive information about apples
|
role: Data Researcher
|
||||||
role: Researcher
|
|
||||||
tasks:
|
tasks:
|
||||||
collect_information_on_apples:
|
data_collection:
|
||||||
description: Use digital tools to find credible sources of information on
|
description: Use provided search tools to collect voting records of Senator
|
||||||
apples covering history, types, and benefits.
|
Marco Rubio from different sources.
|
||||||
expected_output: Collected data on apples, including historical background,
|
expected_output: A collection of CSV, XML or other data files containing the
|
||||||
varieties, and health benefits.
|
required information.
|
||||||
tools:
|
tools:
|
||||||
- ''
|
- ''
|
||||||
analyst:
|
data_processor:
|
||||||
backstory: Expert in analyzing large volumes of data to identify the most relevant
|
backstory: Expert in processing and cleaning raw data, preparing it for analysis
|
||||||
and interesting facts.
|
or presentation.
|
||||||
goal: Analyze gathered information to distill key points
|
goal: Process and format collected data into a readable output
|
||||||
role: Analyst
|
role: Data Processor
|
||||||
tasks:
|
tasks:
|
||||||
synthesize_information:
|
data_processing:
|
||||||
description: Review the collected data and extract the most pertinent facts
|
description: Clean and process the collected voting records into a structured
|
||||||
about apples, focusing on uniqueness and impact.
|
JSON format.
|
||||||
expected_output: A summary highlighting key facts about apples, such as nutritional
|
expected_output: A JSON file containing Senator Marco Rubio's complete voting
|
||||||
benefits, global popularity, and cultural significance.
|
record.
|
||||||
tools:
|
tools:
|
||||||
- ''
|
- ''
|
||||||
writer:
|
presenter:
|
||||||
backstory: Specializes in creating short, impactful pieces of writing that capture
|
backstory: Skilled in extracting and summarizing information, presenting it in
|
||||||
the essence of the subject matter.
|
a clear and concise format.
|
||||||
goal: Craft a concise and engaging essay on apples
|
goal: Generate the final output for user consumption
|
||||||
role: Writer
|
role: Presenter
|
||||||
tasks:
|
tasks:
|
||||||
write_essay:
|
presentation_creation:
|
||||||
description: Based on the analyzed data, write a compelling 20-word essay
|
description: Create an easily digestible presentation from the processed data
|
||||||
on apples that encapsulates their essence and significance.
|
on Senator Marco Rubio's voting record.
|
||||||
expected_output: An engaging 20-word essay on apples.
|
expected_output: A well-structured text or multimedia output that highlights
|
||||||
|
key aspects of Senator Marco Rubio's voting history.
|
||||||
tools:
|
tools:
|
||||||
- ''
|
- ''
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
Loading…
Reference in New Issue
Block a user