poe_bot.mdx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ---
  2. title: '🔮 Poe Bot'
  3. ---
  4. ### 🚀 Getting started
  5. 1. Install embedchain python package:
  6. ```bash
  7. pip install fastapi-poe==0.0.16
  8. ```
  9. 2. Create a free account on [Poe](https://www.poe.com?utm_source=embedchain).
  10. 3. Click "Create Bot" button on top left.
  11. 4. Give it a handle and an optional description.
  12. 5. Select `Use API`.
  13. 6. Under `API URL` enter your server or ngrok address. You can use your machine's public IP or DNS. Otherwise, employ a proxy server like [ngrok](https://ngrok.com/) to make your local bot accessible.
  14. 7. Copy your api key and paste it in `.env` as `POE_API_KEY`.
  15. 8. You will need to set `OPENAI_API_KEY` for generating embeddings and using LLM. Copy your OpenAI API key from [here](https://platform.openai.com/account/api-keys) and paste it in `.env` as `OPENAI_API_KEY`.
  16. 9. Now create your bot using the following code snippet.
  17. ```bash
  18. # make sure that you have set OPENAI_API_KEY and POE_API_KEY in .env file
  19. from embedchain.bots import PoeBot
  20. poe_bot = PoeBot()
  21. # add as many data sources as you want
  22. poe_bot.add("https://en.wikipedia.org/wiki/Adam_D%27Angelo")
  23. poe_bot.add("https://www.youtube.com/watch?v=pJQVAqmKua8")
  24. # start the bot
  25. # this start the poe bot server on port 8080 by default
  26. poe_bot.start()
  27. ```
  28. 10. You can paste the above in a file called `your_script.py` and then simply do
  29. ```bash
  30. python your_script.py
  31. ```
  32. Now your bot will start running at port `8080` by default.
  33. 11. You can refer the [Supported Data formats](https://docs.embedchain.ai/advanced/data_types) section to refer the supported data types in embedchain.
  34. 12. Click `Run check` to make sure your machine can be reached.
  35. 13. Make sure your bot is private if that's what you want.
  36. 14. Click `Create bot` at the bottom to finally create the bot
  37. 15. Now your bot is created.
  38. ### 💬 How to use
  39. - To ask the bot questions, just type your query in the Poe interface:
  40. ```text
  41. <your-question-here>
  42. ```
  43. - If you wish to add more data source to the bot, simply update your script and add as many `.add` as you like. You need to restart the server.