NeMo-Guardrails icon indicating copy to clipboard operation
NeMo-Guardrails copied to clipboard

TypeError: can only concatenate list (not "dict") to list

Open pradeepdev-1995 opened this issue 1 year ago • 2 comments

I have given the app.py file and config.yml(inside config folder) file as follows

app.py

from nemoguardrails import RailsConfig, LLMRails

config = RailsConfig.from_path("./config")
rails = LLMRails(config)

response = rails.generate(messages=[{
    "role": "user",
    "content": "Hello! What can you do for me?"
}])
print(response["content"])

config.yml file

models:
  type: main
  engine: azure
  model: <model name>
  parameters:
      azure_endpoint: <base URL>
      api_version: <version name>
      deployment_name: <model name>
      api_key: <API KEY>

instructions:
  - type: general
    content: |
      Below is a conversation between a user and a bot called the ABC Bot.
      The bot is designed to answer employee questions about the ABC Company.
      The bot is knowledgeable about the employee handbook and company policies.
      If the bot does not know the answer to a question, it truthfully says it does not know.

but getting given error

packages/nemoguardrails/rails/llm/config.py", line 378, in _join_config
    dest_config["models"] = dest_config.get("models", []) + additional_config.get(
TypeError: can only concatenate list (not "dict") to list

pradeepdev-1995 avatar Mar 18 '24 14:03 pradeepdev-1995

@pradeepdev-1995: The syntax is incorrect, inside the YAML file. The models key should be an array. You're missing a dash:

models:
- type: main
  engine: azure
  model: <model name>
  parameters:
      azure_endpoint: <base URL>
      api_version: <version name>
      deployment_name: <model name>
      api_key: <API KEY>

drazvan avatar Mar 19 '24 10:03 drazvan

Thank you @drazvan

pradeepdev-1995 avatar Mar 19 '24 10:03 pradeepdev-1995