Skip to content

Commit

Permalink
Add FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
bonk1t committed Nov 29, 2024
1 parent 68ab4d9 commit 089ff64
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 36 deletions.
73 changes: 61 additions & 12 deletions docs_new/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,77 @@ Find answers to common questions about Agency Swarm.

<AccordionGroup defaultOpen={true}>

<Accordion title="What is Agency Swarm?" icon="bee" iconType="solid">
**A**: Agency Swarm is an open-source framework designed to facilitate the creation and orchestration of multi-agent AI systems.
<Accordion title="How can I restart or continue an agency creation run with Genesis after encountering an error?" icon="rotate">
**A**: You can implement thread callbacks to save and load thread IDs in a local file. This allows you to maintain conversation context even after interruptions. Here's the basic approach:

- Create load and save callback functions
- Use these callbacks in your `GenesisAgency` initialization
- Control threads via a `chat_id` parameter
</Accordion>

<Accordion title="How do I install Agency Swarm?" icon="download" iconType="solid">
**A**: Install via pip using:
<Accordion title="How do I implement thread callbacks for conversation continuity?" icon="messages">
**A**: You can use threads callbacks to save thread ids in a local file:

Create load function:

```python
def load_threads(chat_id):
if os.path.exists(f"{chat_id}_threads.json"):
with open(f"{chat_id}_threads.json", "r") as file:
return json.load(file)
return []
```

Create save function:

```bash
pip install agency-swarm
```python
def save_threads(new_threads, chat_id):
with open(f"{chat_id}_threads.json", "w") as file:
json.dump(new_threads, file)
```
Implement in agency:

```python
agency = GenesisAgency(
with_browsing=False,
threads_callbacks={
'load': lambda: load_threads(chat_id=chat_id),
'save': lambda new_threads: save_threads(new_threads, chat_id=chat_id)
})
```
Note: These code examples are simplified for illustration. Production implementations should include proper error handling, security measures, and scalability considerations.
</Accordion>

<Accordion title="Can I use custom models with Agency Swarm?" icon="gear" iconType="solid">
**A**: Yes, you can integrate open-source models or custom language models that mimic the OpenAI Assistants API.
<Accordion title="Should I use local file storage for thread management in a production environment?" icon="rocket">
**A**: No, for production environments, especially with multiple users or stateless containers, you should:

- Use a database instead of local file storage
- Implement proper state management
- Consider scalability requirements
- Handle concurrent users appropriately
</Accordion>

<Accordion title="How do agents communicate within an agency?" icon="comments" iconType="solid">
**A**: Agents communicate using the `SendMessage` tool, with communication flows defined in the `agency_chart` parameter of the `Agency` class.
<Accordion title="Will previous messages be visible in Gradio when continuing a conversation?" icon="comments">
**A**: No, previous messages won't be displayed in the Gradio interface. However, the agents will retain the context of these messages and continue the conversation appropriately.
</Accordion>

<Accordion title="Where can I find examples and tutorials?" icon="book" iconType="solid">
**A**: Examples are available in the [agency-swarm-lab](https://github.com/VRSEN/agency-swarm-lab) repository and on the [YouTube channel](https://youtube.com/@vrsen).
<Accordion title="How can I serve an Agency as an API using FastAPI?" icon="book">
**A**: Here's an example of how to serve an Agency as an API using FastAPI:

- Define the agency within the chat endpoint:
```python
@app.post("/chat")
async def chat(user_request: UserRequest):
chat_id = user_request.chat_id or str(uuid4())
agency = Agency([...],
threads_callbacks={
'load': lambda: load_threads(chat_id=chat_id),
'save': lambda new_threads: save_threads(new_threads, chat_id=chat_id)
})
response = agency.get_completion(user_request.message)
return {"chat_id": chat_id, "response": response}
```

</Accordion>

</AccordionGroup>
Expand Down
24 changes: 0 additions & 24 deletions docs_new/how-to-guides/managing-communication-flows.mdx

This file was deleted.

0 comments on commit 089ff64

Please sign in to comment.