Help using GraphQL tool 
Labels: name: auto:question

### Issue you'd like to raise.

Hello every one! 

Im triying to  use an LLM models to consult data from OpenTargetPlatform (theyive information about disaeses and its bond with some molecules etc). They have and endpoint which can be access using Graph QL.  OpenTargetPlatform have several query structures for different kind of data requests. In the following example I give to the model 3 different query structures: 



```python
from langchain import OpenAI
from langchain.agents import load_tools, initialize_agent, AgentType, Tool
from langchain.utilities import GraphQLAPIWrapper
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain

# 1.1) Promt Template (in case we need to make a prompt engineering)
prompt = PromptTemplate(
input_variables=["query"],
template="{query}"
)

# 1.2) LLM Model , in this case a LLM modelo from OpenAI
llm = OpenAI(openai_api_key="YOURKEY",
                    model_name="gpt-3.5-turbo", temperature=0.85)

# 1.3) Creation of the chain object (integrates the llm and the prompt template)
llm_chain = LLMChain(llm=llm, prompt=prompt)


# 2.1) We set up the LLM as a tool in order to answer general questions
llm_tool = Tool(name='Language Model',
                func=llm_chain.run,
                description='use this tool for general purpose queries and logic')

# 2.2) We set up the graphql tool
graph_tool = load_tools( # IMPORTANT: usamos load_tools porque ya es una herramienta interna de Langchaing
    tool_names = ["graphql"],
    graphql_endpoint="https://api.platform.opentargets.org/api/v4/graphql",
    llm=llm)

# 2.3)  List of tools that the agent will take
tools = [llm_tool, graph_tool[0]]


agent = initialize_agent(
    agent="zero-shot-react-description", # Type of agent
    tools=tools, # herramienta que le doy
    llm=llm,
    verbose=True,
    max_iterations=3)

# IMPORANT: The zero shot react agent has no memory, all the answers that it will give  are just for one question. It case you want to use a agent with memoory you have to use other type of agent such as Conversational React

type(agent)


prefix = "This questions are related to get medical information, specifically data from OpenTargetPlatform, " \
         "If the question is about the relation among a target and a diseases use the query TargetDiseases, " \
         "If the question is about the relation among diseases and targets then use the query DiseasesTargets, " \
         "If the question request evidence between a disease and targets then use the query targetDiseaseEvidence"


graphql_fields = """

query TargetDiseases {
  target(ensemblId: "target") {
    id
    approvedSymbol
    associatedDiseases  {
      count
      rows {
        disease {
          id
          name
        }
        datasourceScores {
          id
          score
        }
      }
    }
  }
}




query DiseasesTargets {
  disease(efoId: "disease") {
    id
    name
    associatedTargets {
      count
      rows {
        target {
          id
          approvedSymbol
        }
        score
      }
    }
  }
}


query targetDiseaseEvidence {
  disease(efoId: "disease") {
    id
    name
    evidences(datasourceIds: ["intogen"], ensemblIds: ["target"]) {
      count
      rows {
        disease {
          id
          name
        }
        diseaseFromSource
        target {
          id
          approvedSymbol
        }
        mutatedSamples {
          functionalConsequence {
            id
            label
          }
          numberSamplesTested
          numberMutatedSamples
        }
        resourceScore
        significantDriverMethods
        cohortId
        cohortShortName
        cohortDescription
      }
    }
  }
}


"""


suffix = "What are the targets of vorinostat?"

#answer= agent.run(prefix+ suffix + graphql_fields)
answer= agent.run(suffix + prefix+ graphql_fields)

answer


```


When I have 2  structures of  queries it works well. However, when I add the thid like in this examples different kinf of errors start to show. 

Any recomentation about this? shoul I separete the query structure? or the order of elements is wrong in my agent ? 

I would apreciate so much your help ! 

Orlando 


### Suggestion:

_No response_