7 / 7
Sep 2023

Hi guys,

I wanna chat with the data in MongoDB :smiley: I have succeeded with data that is not stored in MongoDB.

Does anyone have experience in working with LangChain? and connecting OpenAI/ChatGPT to MongoDB with GraphQL API keys?

I have issues connecting to the database because I can’t find a way to add a header/apikey correctly so I don’t get an error 401 “401 Client Error: Unauthorized for url:…”

I have tested with a simple connect with requests, and i worked fine.
requests.post(url, json={‘query’: query}, headers=headers)

LangChain with GQL doc:

Code snippet:

API_KEY = “bdytnQMOwW…6zMZEY”
headers = {“api-key”: API_KEY}

tools = load_tools(
[“graphql”],
graphql_endpoint=“App Services”,
headers=headers
)

Hi Andrew,

Thanks for your input and link, appreciated :smiley:
Im have structured data in MDB (real estate data: sqm, address, sold price etc.), and kind of using LLM to create the GQL query and output the result from that. Prompting “What are the latest sales in x-zipcode?”.

Reviewing your link, seems like it’s for text or unstructured data or?
LLM is optimal for unstructured data, but also great for writing queries which makes it easy for non-code/tech ppl to extract data from db. I haven’t found another way/method to “ask the database” so far :smiley:

Awesome, I will have a look, thanks a lot @Prakul_Agarwal :smiley:

Yep, exactly. I have made a small demo using LangChain, ChatGPT and GraphQL API (not MDB). The verbose in the output shows the generated GQL query:

9 days later

Closed on Sep 23, 2023

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.


Want to read more? Browse other topics in Atlas GraphQL API or view latest topics.