Skip to content

Commit

Permalink
anthropic + kosmo2 + fastvit
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Nov 8, 2023
1 parent f74a4da commit 6b4c2d4
Show file tree
Hide file tree
Showing 7 changed files with 1,202 additions and 14 deletions.
16 changes: 12 additions & 4 deletions demos/accountant_team/accountant_team.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# !pip install --upgrade swarms==2.0.6



from swarms.models import OpenAIChat
from swarms.models.nougat import Nougat
from swarms.structs import Flow
Expand All @@ -11,20 +10,25 @@
IMAGE_OF_FINANCIAL_DOC_URL = "bank_statement_2.jpg"

# Example usage
api_key = "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" # Your actual API key here
api_key = (
"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" # Your actual API key here
)


# Initialize the OCR model
def ocr_model(img: str):
ocr = Nougat()
analyze_finance_docs = ocr(img)
return str(analyze_finance_docs)


# Initialize the language flow
llm = OpenAIChat(
openai_api_key=api_key,
temperature=0.5,
)


# Create a prompt for the language model
def summary_agent_prompt(analyzed_doc: str):
analyzed_doc = ocr_model(img=analyzed_doc)
Expand All @@ -36,6 +40,7 @@ def summary_agent_prompt(analyzed_doc: str):
{analyzed_doc}
"""


# Initialize the Flow with the language flow
flow1 = Flow(llm=llm, max_loops=1, dashboard=False)

Expand All @@ -49,11 +54,14 @@ def summary_agent_prompt(analyzed_doc: str):
workflow.add(summary_agent_prompt(IMAGE_OF_FINANCIAL_DOC_URL), flow1)

# Suppose the next task takes the output of the first task as input
workflow.add("Provide an actionable step by step plan on how to cut costs from the analyzed financial document.", flow2)
workflow.add(
"Provide an actionable step by step plan on how to cut costs from the analyzed financial document.",
flow2,
)

# Run the workflow
workflow.run()

# Output the results
for task in workflow.tasks:
print(f"Task: {task.description}, Result: {task.result}")
print(f"Task: {task.description}, Result: {task.result}")
6 changes: 2 additions & 4 deletions playground/models/anthropic_example.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from swarms.models.anthropic import Anthropic


model = Anthropic(
anthropic_api_key=""
)
model = Anthropic(anthropic_api_key="")


task = "Say hello to"

print(model(task))
print(model(task))
2 changes: 1 addition & 1 deletion swarms/models/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,4 @@ def get_num_tokens(self, text: str) -> int:
"""Calculate number of tokens."""
if not self.count_tokens:
raise NameError("Please ensure the anthropic package is loaded")
return self.count_tokens(text)
return self.count_tokens(text)

0 comments on commit 6b4c2d4

Please sign in to comment.