flow class AI: preprended to responses

Former-commit-id: 5c7157a916
dockerize
Kye 1 year ago
parent f635f40c34
commit 19ec72a9bc

@ -57,7 +57,7 @@ from swarms.structs import Flow
flow = Flow(llm=my_language_model, max_loops=5)
# Define a starting task or message
initial_task = "Hello, can you provide me with some information?"
initial_task = "Generate a 10,000 word blog on health and wellness."
# Run the conversation loop
final_response = flow.run(initial_task)
@ -68,7 +68,7 @@ final_response = flow.run(initial_task)
You can collect feedback during the conversation using the `provide_feedback` method:
```python
flow.provide_feedback("The response was not accurate.")
flow.provide_feedback("Generate an SOP for new sales employees on the best cold sales practices")
```
### Stopping Condition
@ -112,7 +112,7 @@ from swarms.structs import Flow
flow = Flow(llm=my_language_model, max_loops=5)
# Define a starting task or message
initial_task = "Hello, can you provide me with some information?"
initial_task = "Generate an long form analysis on the transformer model architecture."
# Run the conversation loop
final_response = flow.run(initial_task)
@ -137,7 +137,7 @@ from swarms.structs import Flow
flow = Flow(llm=my_language_model, max_loops=5, interactive=True)
# Provide initial task
initial_task = "Hello, can you tell me a joke?"
initial_task = "Rank and prioritize the following financial documents and cut out 30% of our expenses"
# Run the conversation loop
final_response = flow.run(initial_task)

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
from swarms.models import OpenAIChat
from swarms.structs import Flow
api_key = "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"
api_key = ""
# Initialize the language model,
@ -16,4 +16,5 @@ llm = OpenAIChat(
flow = Flow(llm=llm, max_loops=5, dashboard=True)
out = flow.run("Generate a 10,000 word blog on health and wellness.")
print(out)

@ -281,7 +281,7 @@ def social_media_prompt(article: str, goal: str = "Clicks and engagement"):
# Agent that generates topics
topic_selection_task = (
"Generate 10 topics on gaining mental clarity using ancient Taosim practices"
"Generate 10 topics on gaining mental clarity using ancient practices"
)
topics = llm(
f"Your System Instructions: {TOPIC_GENERATOR}, Your current task: {topic_selection_task}"

@ -212,7 +212,7 @@ class Flow:
"""
response = task
history = [task]
history = [f"Human: {task}"]
# If dashboard = True then print the dashboard
if self.dashboard:
@ -232,7 +232,18 @@ class Flow:
while attempt < self.retry_attempts:
try:
response = self.llm(response)
print(f"Next query: {response}")
# print(f"Next query: {response}")
# break
if self.interactive:
print(f"AI: {response}")
history.append(f"AI: {response}")
response = input("You: ")
history.append(f"Human: {response}")
else:
print(f"AI: {response}")
history.append(f"AI: {response}")
print(response)
break
except Exception as e:
logging.error(f"Error generating response: {e}")

Loading…
Cancel
Save