const body = JSON.stringify({
question: 'YOUR QUESTION HERE',
graphqlEndpoint: "https://[YOUR_GRAPH_QL_ENDPOINT]/graphql",
graphqlSchema: "YOUR_GRAPHQL_SCHEMA_HERE", // Usually the generated_schema.graphql file
endpointAccessToken: "" // YOUR GRAPHQL ENDPOINT ACCESS_TOKEN if required
})
const response = await fetch("https://graphql.chat/api", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
//'Authorization': `Bearer GRAPHQL_CHAT_TOKEN` for access token please contact -> [email protected]
// Once you are using access token you can send only the question in the body
},
body,
});
const jsonResp = await response.json();
// Result will be in the format
// jsonResp.answer is the answer to your question
// jsonResp.graphqlQuery is the query sent to your graphql endpoint
// jsonResp.graphqlAnswer is the answer received from your graphql endpoint
// jsonResp.question is the question you asked
const tools = [
// For access token please reach to [email protected]
// new GraphqlChat({
// accessToken: "YOUR ACCESS TOKEN HERE"
// description: "Query XXX API to answer questions about YYYYY, // Put here your graphql api description
// })
new GraphqlChat({
description: "Query a remote github API to answer questions about code/repos ech", // Put here your graphql api description
graphqlEndpoint: "https://api.github.com/graphql", // graphqlEndpoint put here your graphql endpoint
graphqlSchema: `YOUR_SCHEMA_HERE`,
graphqlEndpointAccessToken: ''// Optional, if you need to pass the access token to your graphql endpoint
}),
];
const agent = await initializeAgentExecutor(
tools,
new ChatOpenAI({ temperature: 0 }),
"chat-zero-shot-react-description",
true
);
const result = await agent.call({
input: "What are the oldest open PRs in my repos?",
});
console.log({ result });