Skip to content

Commit

Permalink
anthropic docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Nov 6, 2023
1 parent 97aa8bc commit 4c6bbad
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 122 deletions.
93 changes: 0 additions & 93 deletions docs/prompt.txt

This file was deleted.

11 changes: 6 additions & 5 deletions docs/swarms/models/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ class Anthropic:
```python
# Import necessary modules and classes
from swarms.models import Anthropic
import torch

# Initialize an instance of the Anthropic class
anthropic_instance = Anthropic()
model = Anthropic(
anthropic_api_key="sk-"
)

# Using the generate method
completion_1 = anthropic_instance.generate("What is the capital of France?")
# Using the run method
completion_1 = model.run("What is the capital of France?")
print(completion_1)

# Using the __call__ method
completion_2 = anthropic_instance("How far is the moon from the earth?", stop=["miles", "km"])
completion_2 = model("How far is the moon from the earth?", stop=["miles", "km"])
print(completion_2)
```

Expand Down
16 changes: 0 additions & 16 deletions godmode.py

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion swarms/agents/idea_to_image_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import logging
from dataclasses import dataclass
from dalle3 import Dalle
from playground.models.dalle3 import Dalle
from swarms.models import OpenAIChat


Expand Down
17 changes: 11 additions & 6 deletions swarms/models/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class HuggingfaceLLM:
```
from swarms.models import HuggingfaceLLM
model_id = "gpt2-small"
model_id = "NousResearch/Yarn-Mistral-7b-128k"
inference = HuggingfaceLLM(model_id=model_id)
task = "Once upon a time"
Expand Down Expand Up @@ -74,15 +74,20 @@ def __init__(
bnb_config = BitsAndBytesConfig(**quantization_config)

try:
self.tokenizer = AutoTokenizer.from_pretrained(self.model_id)
self.tokenizer = AutoTokenizer.from_pretrained(self.model_id, *args, **kwargs)
self.model = AutoModelForCausalLM.from_pretrained(
self.model_id, quantization_config=bnb_config
self.model_id, quantization_config=bnb_config, *args, **kwargs
)

self.model # .to(self.device)
except Exception as e:
self.logger.error(f"Failed to load the model or the tokenizer: {e}")
raise
# self.logger.error(f"Failed to load the model or the tokenizer: {e}")
# raise
print(colored(f"Failed to load the model and or the tokenizer: {e}", "red"))

def print_error(self, error: str):
"""Print error"""
print(colored(f"Error: {error}", "red"))

def load_model(self):
"""Load the model"""
Expand Down Expand Up @@ -157,7 +162,7 @@ def run(self, task: str):
del inputs
return self.tokenizer.decode(outputs[0], skip_special_tokens=True)
except Exception as e:
self.logger.error(f"Failed to generate the text: {e}")
print(colored(f"HuggingfaceLLM could not generate text because of error: {e}, try optimizing your arguments", "red"))
raise

async def run_async(self, task: str, *args, **kwargs) -> str:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/dalle3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PIL import Image
from termcolor import colored

from dalle3 import Dalle3
from playground.models.dalle3 import Dalle3


# Mocking the OpenAI client to avoid making actual API calls during testing
Expand Down

0 comments on commit 4c6bbad

Please sign in to comment.