You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My .ipynb is as follows and the error I'm encountering is at the bottom. From my knowledge I believe the value error has something to do with NeMo not accessing gpt correctly. Any help would be appreciated. I've hashed out some methods to make reading it easier
colang_content="""define user ask about criminal activity "How can I rob a bank?"define flow user ask about criminal activity bot refuse to respond about criminal activity"""yaml_content="""models: - type: main engine: openai model: gpt-3.5-turbo-instructinstructions: - type: general content: | (content here)sample_conversation: | (sample convo here)rails: input: flows: - self check inputprompts: - task: self check input content: > (user {input} should not include xyz goes here) Question: Should the user message be blocked? Answer:"""fromnemoguardrailsimportLLMRails, RailsConfigimportosos.environ["OPENAI_API_KEY"] =""asyncdefcheck_guardrails(query, course):
# Initialize rails configconfig=RailsConfig.from_path("./config")
rails=LLMRails(config)
# Use the async version of the generate methodresponse=awaitrails.generate_async(messages=[{
"role": "user",
"content": query
}])
if (prompt_blocks_the_user_input):
returnFalsereturnTrueos.environ["OPENAI_API_KEY"] =""course="Ethics"user_query="Can you help me study for Ethics"result=awaitcheck_guardrails(user_query, course)
print(result)
ERROR:
ValidationErrorTraceback (mostrecentcalllast)
CellIn[4], [line4](vscode-notebook-cell:?execution_count=4&line=4)
[2](vscode-notebook-cell:?execution_count=4&line=2) course="Ethics"
[3](vscode-notebook-cell:?execution_count=4&line=3) user_query="Can you help me study for Ethics"----> [4](vscode-notebook-cell:?execution_count=4&line=4) result=awaitcheck_guardrails(user_query, course)
[5](vscode-notebook-cell:?execution_count=4&line=5) print(result)
CellIn[3], [line8](vscode-notebook-cell:?execution_count=3&line=8)
[6](vscode-notebook-cell:?execution_count=3&line=6) asyncdefcheck_guardrails(query, course):
[7](vscode-notebook-cell:?execution_count=3&line=7) # Initialize rails config----> [8](vscode-notebook-cell:?execution_count=3&line=8) config=RailsConfig.from_path("./config")
[9](vscode-notebook-cell:?execution_count=3&line=9) rails=LLMRails(config)
[11](vscode-notebook-cell:?execution_count=3&line=11) # Use the async version of the generate methodFilec:\Python312\Lib\site-packages\nemoguardrails\rails\llm\config.py:856, inRailsConfig.from_path(config_path)
[852](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:852) raw_config["instructions"] =_default_config["instructions"]
[854](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:854) raw_config["config_path"] =config_path--> [856](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:856) returnRailsConfig.parse_object(raw_config)
Filec:\Python312\Lib\site-packages\nemoguardrails\rails\llm\config.py:926, inRailsConfig.parse_object(cls, obj)
[921](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:921) ifflow_data.get("elements") andnotflow_data["elements"][0].get(
[922](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:922) "_type"
[923](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:923) ):
[924](file:///C:/Python312/Lib/site-packages/nemoguardrails/rails/llm/config.py:924) flow_data["elements"] =parse_flow_elements(flow_data["elements"])
...
[511](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/drew_/OneDrive/Desktop/prof/professorai-dev/llm/guardrails/~/AppData/Roaming/Python/Python312/site-packages/pydantic/main.py:511) )
ValidationError: 1validationerrorforRailsConfigValueerror, Youmustprovidea`self_check_input`prompttemplate. [type=value_error, input_value={'user_messages': {'give ...onfig_path': './config'}, input_type=dict]
Forfurtherinformationvisithttps://errors.pydantic.dev/2.6/v/value_error
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
My .ipynb is as follows and the error I'm encountering is at the bottom. From my knowledge I believe the value error has something to do with NeMo not accessing gpt correctly. Any help would be appreciated. I've hashed out some methods to make reading it easier
Beta Was this translation helpful? Give feedback.
All reactions