json.mdx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ---
  2. title: '📃 JSON'
  3. ---
  4. To add any json file, use the data_type as `json`. `json` allows remote urls and conventional file paths. Headers are included for each line, so if you have an `age` column, `18` will be added as `age: 18`. Eg:
  5. ```python
  6. import os
  7. from embedchain.apps.app import App
  8. os.environ["OPENAI_API_KEY"] = "openai_api_key"
  9. app = App()
  10. response = app.query("What is the net worth of Elon Musk as of October 2023?")
  11. print(response)
  12. "I'm sorry, but I don't have access to real-time information or future predictions. Therefore, I don't know the net worth of Elon Musk as of October 2023."
  13. source_id = app.add("temp.json")
  14. response = app.query("What is the net worth of Elon Musk as of October 2023?")
  15. print(response)
  16. "As of October 2023, Elon Musk's net worth is $255.2 billion."
  17. ```
  18. ```temp.json
  19. {
  20. "question": "What is your net worth, Elon Musk?",
  21. "answer": "As of October 2023, Elon Musk's net worth is $255.2 billion, making him one of the wealthiest individuals in the world."
  22. }
  23. ```