huggingface example

pull/53/head
Kye 1 year ago
parent acdeff81de
commit fc0ec27405

@ -53,10 +53,11 @@ swarm(objective)
## Usage ## Usage
```python ```python
from swarms import OpenAI
chat = OpenAI() from swarms import HuggingFaceLLM
response = chat("Hello world!")
hugging_face_model = HuggingFaceLLM(model_id="Voicelab/trurl-2-13b")
generated_text = hugging_face_model.generate("In a world where AI")
``` ```

@ -76,10 +76,8 @@ class Agent:
user_input = ( user_input = (
"Determine which next command to use, and respond using the format specified above:" "Determine which next command to use, and respond using the format specified above:"
) )
# Interaction Loop
loop_count = 0 loop_count = 0
while True: while True:
# Discontinue if continuous limit is reached
loop_count += 1 loop_count += 1
# Send message to AI, get response # Send message to AI, get response
@ -90,7 +88,6 @@ class Agent:
user_input=user_input, user_input=user_input,
) )
# Print Assistant thoughts
print(assistant_reply) print(assistant_reply)
self.chat_history_memory.add_message(HumanMessage(content=user_input)) self.chat_history_memory.add_message(HumanMessage(content=user_input))
self.chat_history_memory.add_message(AIMessage(content=assistant_reply)) self.chat_history_memory.add_message(AIMessage(content=assistant_reply))

Loading…
Cancel
Save